From f7aab976397d4580e52c1144b9a33b3972fe196a Mon Sep 17 00:00:00 2001 From: Dillon Nys Date: Wed, 16 Nov 2022 13:53:28 -0700 Subject: [PATCH] ci: Add `setup` step Allows packages to declare a `setup.sh` script to run before running tests to allow for pluggable package-specific setup work. --- .github/workflows/dart_dart2js.yaml | 8 ++++++++ .github/workflows/dart_ddc.yaml | 8 ++++++++ .github/workflows/dart_native.yaml | 8 ++++++++ .github/workflows/dart_vm.yaml | 8 ++++++++ .github/workflows/flutter_vm.yaml | 8 ++++++++ .../tool/{test-desktop.sh => setup.sh} | 6 ++---- 6 files changed, 42 insertions(+), 4 deletions(-) rename packages/secure_storage/amplify_secure_storage_test/tool/{test-desktop.sh => setup.sh} (79%) diff --git a/.github/workflows/dart_dart2js.yaml b/.github/workflows/dart_dart2js.yaml index 66bfab04a76..86793193b8d 100644 --- a/.github/workflows/dart_dart2js.yaml +++ b/.github/workflows/dart_dart2js.yaml @@ -57,6 +57,14 @@ jobs: timeout-minutes: 10 run: aft bootstrap + - name: Setup Package + if: "always() && steps.bootstrap.conclusion == 'success'" + shell: bash # Run in bash regardless of platform + run: | + if [ -e tool/setup.sh ]; then + ./tool/setup.sh + fi + - name: Run Tests if: "always() && steps.bootstrap.conclusion == 'success'" run: dart run build_runner test --release --delete-conflicting-outputs -- -p ${{ matrix.browser }} diff --git a/.github/workflows/dart_ddc.yaml b/.github/workflows/dart_ddc.yaml index abdd0386577..fb384c8b1a4 100644 --- a/.github/workflows/dart_ddc.yaml +++ b/.github/workflows/dart_ddc.yaml @@ -61,6 +61,14 @@ jobs: timeout-minutes: 10 run: aft bootstrap + - name: Setup Package + if: "always() && steps.bootstrap.conclusion == 'success'" + shell: bash # Run in bash regardless of platform + run: | + if [ -e tool/setup.sh ]; then + ./tool/setup.sh + fi + - name: Run Tests if: "always() && steps.bootstrap.conclusion == 'success' && (matrix.sdk == 'dev' || inputs.test-ddc-stable)" run: dart run build_runner test --delete-conflicting-outputs -- -p ${{ matrix.browser }} --exclude-tags=no-ddc diff --git a/.github/workflows/dart_native.yaml b/.github/workflows/dart_native.yaml index c8ced85a260..ce0d6b09bc5 100644 --- a/.github/workflows/dart_native.yaml +++ b/.github/workflows/dart_native.yaml @@ -58,6 +58,14 @@ jobs: timeout-minutes: 15 # macOS needs extra time run: aft bootstrap + - name: Setup Package + if: "always() && steps.bootstrap.conclusion == 'success'" + shell: bash # Run in bash regardless of platform + run: | + if [ -e tool/setup.sh ]; then + ./tool/setup.sh + fi + - name: Run Tests if: "always() && steps.bootstrap.conclusion == 'success'" run: dart test --exclude-tags=build diff --git a/.github/workflows/dart_vm.yaml b/.github/workflows/dart_vm.yaml index 4048b456a94..fb5fd2b7a1d 100644 --- a/.github/workflows/dart_vm.yaml +++ b/.github/workflows/dart_vm.yaml @@ -73,6 +73,14 @@ jobs: echo "analysisDirs=lib" >> $GITHUB_OUTPUT fi + - name: Setup Package + if: "always() && steps.bootstrap.conclusion == 'success'" + shell: bash # Run in bash regardless of platform + run: | + if [ -e tool/setup.sh ]; then + ./tool/setup.sh + fi + - name: Analyze if: "always() && steps.bootstrap.conclusion == 'success'" run: dart analyze --fatal-infos --fatal-warnings ${{ steps.testCheck.outputs.analysisDirs }} diff --git a/.github/workflows/flutter_vm.yaml b/.github/workflows/flutter_vm.yaml index b8d55ab5089..b84c7581384 100644 --- a/.github/workflows/flutter_vm.yaml +++ b/.github/workflows/flutter_vm.yaml @@ -56,6 +56,14 @@ jobs: echo "analysisDirs=lib" >> $GITHUB_OUTPUT fi + - name: Setup Package + if: "always() && steps.bootstrap.conclusion == 'success'" + shell: bash # Run in bash regardless of platform + run: | + if [ -e tool/setup.sh ]; then + ./tool/setup.sh + fi + - name: Analyze if: "always() && steps.bootstrap.conclusion == 'success'" run: flutter analyze --fatal-infos --fatal-warnings ${{ steps.testCheck.outputs.analysisDirs }} diff --git a/packages/secure_storage/amplify_secure_storage_test/tool/test-desktop.sh b/packages/secure_storage/amplify_secure_storage_test/tool/setup.sh similarity index 79% rename from packages/secure_storage/amplify_secure_storage_test/tool/test-desktop.sh rename to packages/secure_storage/amplify_secure_storage_test/tool/setup.sh index 90374ce218a..f986e84268f 100755 --- a/packages/secure_storage/amplify_secure_storage_test/tool/test-desktop.sh +++ b/packages/secure_storage/amplify_secure_storage_test/tool/setup.sh @@ -7,8 +7,8 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then sudo apt-get update && sudo apt-get install -y libsecret-1-dev gnome-keyring # If running in headless mode, re-run script in dbus session. - if [ -z $DBUS_SESSION_BUS_ADDRESS ]; then - exec dbus-run-session -- $0 + if [ -z $DBUS_SESSION_BUS_ADDRESS && -n $1 ]; then + exec dbus-run-session -- $@ fi # Set up keyring in CI env @@ -16,5 +16,3 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then echo 'password' | gnome-keyring-daemon --start --replace --daemonize --unlock fi fi - -dart test