From 467f13e5e41f78ed1a1fb1ccdf98928949f0b71a Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Thu, 11 Apr 2024 20:22:07 +0200 Subject: [PATCH] run golden tests on ci --- .github/workflows/pr_check.yml | 10 +++- .github/workflows/run_golden_tests.yml | 68 ++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/run_golden_tests.yml diff --git a/.github/workflows/pr_check.yml b/.github/workflows/pr_check.yml index 75ef37e..0b1863e 100644 --- a/.github/workflows/pr_check.yml +++ b/.github/workflows/pr_check.yml @@ -12,7 +12,7 @@ on: branches: ["main"] jobs: - analyze_and_test: + analyze-and-test: name: Analyze & test runs-on: macos-11 timeout-minutes: 10 @@ -61,4 +61,10 @@ jobs: run: | bash ./.github/scripts/stub_iap.sh flutter pub get - flutter analyze lib --fatal-infos \ No newline at end of file + flutter analyze lib --fatal-infos + + run-golden-tests: + name: Run golden tests + needs: [analyze-and-test] + uses: ./.github/workflows/run_golden_tests.yml + secrets: inherit diff --git a/.github/workflows/run_golden_tests.yml b/.github/workflows/run_golden_tests.yml new file mode 100644 index 0000000..48f6df7 --- /dev/null +++ b/.github/workflows/run_golden_tests.yml @@ -0,0 +1,68 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Run golden tests + +on: + workflow_dispatch: + inputs: + update-goldens: + type: boolean + description: Update goldens + default: false + workflow_call: + inputs: + update-goldens: + type: boolean + description: Update goldens + default: false + +jobs: + run-golden-tests: + name: Run golden tests + timeout-minutes: 5 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + flutter-version: "3.13.9" + + - name: Prepare app + run: | + flutter --version + flutter pub get + flutter pub run intl_utils:generate + + - name: Run tests + env: + UPDATE_GOLDENS: ${{inputs.update-goldens && '--update-goldens' || '' }}ƒ + run: | + goldens=$(find ./test -name "*_golden_test.dart" -print) + for f in $goldens; do + flutter test "$f"\ + --dart-define cameraStubImage=assets/camera_stub_image.jpg \ + $UPDATE_GOLDENS + done + + - name: Commit changes + if: ${{ inputs.update-goldens }} + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add -A + git commit -m "Updated goldens" + + - name: Push to main + if: ${{ inputs.update-goldens }} + uses: CasperWA/push-protected@v2 + with: + token: ${{ secrets.PUSH_TO_MAIN_TOKEN }} + branch: ${{ github.ref_name }} + unprotect_reviews: true