Skip to content

Commit

Permalink
test: try github actions integration
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed Oct 30, 2020
1 parent 2a484a4 commit 2064e92
Show file tree
Hide file tree
Showing 9 changed files with 377 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/run_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Run CI
on: push

jobs:
test:
name: Test on ${{ matrix.os }} / ${{ matrix.flutter }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./sqflite_support
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
flutter: [stable, beta, dev]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
channel: ${{ matrix.flutter }}
- run: dart --version
- run: flutter --version
- run: flutter upgrade
- run: dart pub get
- run: dart run tool/run_ci.dart
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ dev_dependencies:
ref: dart2
version: '>=0.1.0'
process_run: '>=0.10.10+1'
dev_test: '>=0.13.4-dev.2'
test:

dependency_overrides:
pedantic: '>=1.9.0 <3.0.0'
58 changes: 58 additions & 0 deletions sqflite_support/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# See https://www.dartlang.org/guides/libraries/private-files

# Files and directories created by pub
.dart_tool/
.packages
.pub/
build/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock

# Directory created by dartdoc
/doc/api/

# flutter root folder wrongly created
/ios
/android
.symlinks

# IDE
.idea/
*.iml
.vscode/
/sqflite/example/.flutter-plugins-dependencies

# Copied from flutter plugins
.DS_Store
.atom/
flutter_export_environment.sh

Podfile
Podfile.lock
Pods/
.symlinks/
**/Flutter/App.framework/
**/Flutter/Flutter.framework/
**/Flutter/Generated.xcconfig
**/Flutter/flutter_assets/
ServiceDefinitions.json
xcuserdata/
*.xcworkspace
**/DerivedData/

local.properties
keystore.properties
.gradle/
gradlew
gradlew.bat
gradle-wrapper.jar
.flutter-plugins-dependencies

GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m
GeneratedPluginRegistrant.java
.flutter-plugins

.project
.classpath
.settings
12 changes: 12 additions & 0 deletions sqflite_support/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: dart
sudo: required
dist: bionic
dart:
- stable
- beta
- dev
before_script:
- pub run tekartik_travis_ci_flutter:install
- source $(pub run tekartik_travis_ci_flutter:env)
script:
- dart tool/travis.dart
19 changes: 19 additions & 0 deletions sqflite_support/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Defines a default set of lint rules enforced for
# projects at Google. For details and rationale,
# see https://github.com/dart-lang/pedantic#enabled-lints.
include: package:pedantic/analysis_options.yaml

analyzer:
strong-mode:
implicit-casts: false

errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODOs in the code
todo: ignore
# Ignore errors like
# 'super_goes_last' is a deprecated lint rule and should not be used • included_file_warning
included_file_warning: ignore
22 changes: 22 additions & 0 deletions sqflite_support/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: sqflite_repo
description: Sqflite repo
version: 0.1.0
homepage: https://github.com/tekartik/sqflite
publish_to: none

environment:
sdk: '>=2.7.0 <3.0.0'

dev_dependencies:
pedantic: '>=1.4.0 <3.0.0'
tekartik_travis_ci_flutter:
git:
url: git://github.com/tekartik/travis_ci_flutter.dart
ref: dart2
version: '>=0.1.0'
process_run: '>=0.10.10+1'
dev_test: '>=0.13.4-dev.2'
test:

dependency_overrides:
pedantic: '>=1.9.0 <3.0.0'
174 changes: 174 additions & 0 deletions sqflite_support/test/workflow_build_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
@TestOn('vm')
import 'dart:io';

import 'package:dev_test/package.dart';
import 'package:dev_test/build_support.dart';
import 'package:dev_test/src/run_ci.dart';
import 'package:path/path.dart';
import 'package:process_run/shell_run.dart';
import 'package:test/test.dart';

void main() {
test('flutter config', () async {
if (isFlutterSupportedSync) {
await run('flutter config');
}
});
group('flutter test', () {
setUpAll(() async {
await buildInitFlutter();
});
var dir = join('.dart_tool', 'sqflite_support', 'raw_flutter_test1', 'test',
'project');
var _ensureCreated = false;
var shell = Shell(workingDirectory: dir);
Future<void> _create() async {
await flutterCreateProject(
path: dir,
);
await shell.run('flutter config');
}

Future<void> _ensureCreate() async {
if (!_ensureCreated) {
if (!Directory(dir).existsSync()) {
await _create();
}
_ensureCreated = true;
}
}

Future<void> _iosBuild() async {
if (buildSupportsIOS) {
await shell.run('flutter build ios --release --no-codesign');
}
}

Future<void> _androidBuild() async {
if (buildSupportsAndroid) {
await shell.run('flutter build apk');
}
}

Future<void> _runCi() async {
// Allow failure
try {
await packageRunCi(dir);
} catch (e) {
stderr.writeln('run_ci error $e');
}
}

test('create', () async {
await _create();
}, timeout: const Timeout(Duration(minutes: 5)));
test('run_ci', () async {
await _ensureCreate();
await _runCi();
}, timeout: const Timeout(Duration(minutes: 5)));

test('build ios', () async {
await _ensureCreate();
await _iosBuild();
}, timeout: const Timeout(Duration(minutes: 5)));

test('build android', () async {
await _ensureCreate();
await _androidBuild();
}, timeout: const Timeout(Duration(minutes: 5)));
test('add sqflite', () async {
await _ensureCreate();
if (await pathPubspecAddDependency(dir, 'sqflite')) {
await _iosBuild();
await _androidBuild();
await _runCi();
}
}, timeout: const Timeout(Duration(minutes: 10)));
test('add sqflite', () async {
await _ensureCreate();
var readDependencyLines =
await pathPubspecGetDependencyLines(dir, 'sqflite');
if (readDependencyLines == ['sqflite:']) {
return;
}
if (await pathPubspecAddDependency(dir, 'sqflite')) {
await shell.run('dart pub get');
await _runCi();
}
}, timeout: const Timeout(Duration(minutes: 10)));

test('add sqflite relative', () async {
await _ensureCreate();
var dependencyLines = [
'path: ${join('..', '..', '..', '..', '..', '..', 'sqflite')}'
];

var readDependencyLines =
await pathPubspecGetDependencyLines(dir, 'sqflite');
if (readDependencyLines == dependencyLines) {
return;
}
if (await pathPubspecRemoveDependency(dir, 'sqflite')) {
await shell.run('dart pub get');
}

if (await pathPubspecAddDependency(dir, 'sqflite',
dependencyLines: dependencyLines)) {
await shell.run('dart pub get');
await _runCi();
}
}, timeout: const Timeout(Duration(minutes: 10)));
}, skip: !isFlutterSupportedSync && !isRunningOnTravis);
// TODO @alex find a better to know the flutter build status

group(
'dart test',
() {
setUpAll(() async {
await buildInitDart();
});
var dir = join(
'.dart_tool', 'dev_test', 'sqflite_dart_test1', 'test', 'project');
var _ensureCreated = false;
Future<void> _create() async {
await dartCreateProject(
path: dir,
);
}

Future<void> _ensureCreate() async {
if (!_ensureCreated) {
if (!Directory(dir).existsSync()) {
await _create();
}
_ensureCreated = true;
}
}

Future<void> _runCi() async {
// Don't allow failure
try {
await packageRunCi(dir);
} catch (e) {
stderr.writeln('run_ci error $e');
rethrow;
}
}

test('create', () async {
await _create();
}, timeout: const Timeout(Duration(minutes: 5)));
test('run_ci', () async {
await _ensureCreate();
await _runCi();
}, timeout: const Timeout(Duration(minutes: 5)));

test('add sqflite_common_ffi', () async {
await _ensureCreate();
if (await pathPubspecAddDependency(dir, 'sqflite_common_ffi')) {
await _runCi();
}
}, timeout: const Timeout(Duration(minutes: 10)));
},
);
}
22 changes: 22 additions & 0 deletions sqflite_support/tool/run_ci.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:process_run/shell.dart';
import 'package:dev_test/package.dart';
import 'package:path/path.dart';

Future main() async {
// await packageRunCi('.');

var shell = Shell().cd('..');

await shell.run('flutter doctor');

for (var dir in [
'.',
...[
'sqflite_common',
// 'sqflite_common_test',
// 'sqflite_common_ffi',
].map((dir) => join('..', dir))
]) {
await packageRunCi(dir);
}
}
41 changes: 41 additions & 0 deletions tool/run_ci.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:process_run/shell.dart';
import 'package:dev_test/package.dart';

Future main() async {
// await packageRunCi('.');

var shell = Shell();

await shell.run('flutter doctor');

/*
for (var dir in [
'sqflite/example',
'sqflite',
'sqflite_test_app',
]) {
shell = shell.pushd(dir);
await shell.run('''
flutter packages get
dart tool/travis.dart
''');
shell = shell.popd();
}
*/
for (var dir in [
'sqflite_common',
// 'sqflite_common_test',
// 'sqflite_common_ffi',
]) {
shell = shell.pushd(dir);
await shell.run('''
pub get
dart tool/travis.dart
''');
shell = shell.popd();
}
}

0 comments on commit 2064e92

Please sign in to comment.