From 936656b6cc0ebae27c9e80bef73c56c511ff7c51 Mon Sep 17 00:00:00 2001 From: westito Date: Mon, 1 Aug 2022 22:09:36 +0200 Subject: [PATCH] Add docker test --- .dockerignore | 3 +++ Dockerfile | 32 ++++++++++++++++++++++++++++++++ tool/docker_test.sh | 7 +++++++ tool/misc_integration_test.sh | 8 ++------ tool/pubget_all.sh | 1 - tool/test_all.sh | 26 +++++++++++++++----------- tool/upgrade_all.sh | 1 + 7 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 tool/docker_test.sh delete mode 100755 tool/pubget_all.sh create mode 100755 tool/upgrade_all.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..dcb95b55 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +**/.dart_tool +**/pubspec.lock +**/build \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9089b04f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM dart + +RUN apt update +RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y chromium build-essential gcc +RUN ln -s /usr/bin/chromium /usr/bin/google-chrome +RUN chmod +x /usr/bin/google-chrome + +RUN useradd -ms /bin/bash developer +RUN mkdir -p /app + +USER developer +WORKDIR /home/developer + +RUN cd /tmp/ &&\ + mkdir sqlite &&\ + cd sqlite &&\ + curl https://sqlite.org/2022/sqlite-autoconf-3380000.tar.gz --output sqlite.tar.gz &&\ + tar zxvf sqlite.tar.gz &&\ + cd sqlite-autoconf-3380000 &&\ + ./configure &&\ + make &&\ + mkdir ../out &&\ + cp sqlite3 ../out &&\ + cp .libs/libsqlite3.so ../out + +USER developer +COPY --chown=developer:developer . /app/ +WORKDIR /app/tool +RUN ./upgrade_all.sh + +CMD export LD_LIBRARY_PATH=/tmp/sqlite/out ; ./test_all.sh +#; (cd .. && ./tool/misc_integration_test.sh) \ No newline at end of file diff --git a/tool/docker_test.sh b/tool/docker_test.sh new file mode 100755 index 00000000..2fb54057 --- /dev/null +++ b/tool/docker_test.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +cd .. +DOCKER_BUILDKIT=0 docker build -t drift-test . +docker run --rm --privileged -it drift-test +docker image rm drift-test diff --git a/tool/misc_integration_test.sh b/tool/misc_integration_test.sh index 0ba0a28b..c616fced 100755 --- a/tool/misc_integration_test.sh +++ b/tool/misc_integration_test.sh @@ -1,17 +1,15 @@ #!/usr/bin/env bash -EXIT_CODE=0 - pushd extras/drift_postgres echo "Running integration tests with Postgres" dart pub upgrade -dart test || EXIT_CODE=$? +dart test || true popd pushd examples/with_built_value echo "Running build runner in with_built_value" dart pub upgrade -dart run build_runner build --delete-conflicting-outputs || EXIT_CODE=$? +dart run build_runner build --delete-conflicting-outputs popd pushd examples/migrations_example @@ -19,5 +17,3 @@ echo "Testing migrations in migrations_example" dart pub upgrade dart test popd - -exit $EXIT_CODE diff --git a/tool/pubget_all.sh b/tool/pubget_all.sh deleted file mode 100755 index cfdfc9d6..00000000 --- a/tool/pubget_all.sh +++ /dev/null @@ -1 +0,0 @@ -find ../ -name pubspec.yaml -execdir dart pub get \; diff --git a/tool/test_all.sh b/tool/test_all.sh index 587373a0..5ee88d97 100755 --- a/tool/test_all.sh +++ b/tool/test_all.sh @@ -8,12 +8,12 @@ function run_test() { dart format -o none --set-exit-if-changed . dart analyze --fatal-infos --fatal-warnings if [[ "$2" == 'vm+web' ]]; then - dart test + dart test -p vm dart test -p chrome elif [[ "$2" == 'web-only' ]]; then dart test -p chrome else - dart test + dart test -p vm fi popd > /dev/null } @@ -30,12 +30,16 @@ function run_test_flutter() { } cd .. -run_test 'drift' 'vm+web' -run_test 'drift_dev' -run_test 'sqlparser' -run_test_flutter 'drift_sqflite' 'integration_test' -run_test_flutter 'examples/app' -run_test 'examples/migrations_example' -run_test_flutter 'extras/integration_tests/ffi_on_flutter' 'integration_test/drift_native.dart' -run_test 'extras/integration_tests/web' 'web-only' -run_test 'extras/drift_postgres' \ No newline at end of file + +if [[ "$1" == 'flutter' ]]; then + run_test_flutter 'drift_sqflite' 'integration_test' + run_test_flutter 'examples/app' + run_test_flutter 'extras/integration_tests/ffi_on_flutter' 'integration_test/drift_native.dart' +else + run_test 'drift' 'vm+web' + run_test 'drift_dev' + run_test 'sqlparser' + run_test 'examples/migrations_example' + run_test 'extras/integration_tests/web' 'web-only' + run_test 'extras/drift_postgres' +fi diff --git a/tool/upgrade_all.sh b/tool/upgrade_all.sh new file mode 100755 index 00000000..6e6f850e --- /dev/null +++ b/tool/upgrade_all.sh @@ -0,0 +1 @@ +find ../ -name pubspec.yaml -execdir dart pub upgrade \;