m3_lightmeter/.github/workflows/run_golden_tests.yml

70 lines
2.1 KiB
YAML
Raw Normal View History

2024-04-11 18:22:07 +00:00
# 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
jobs:
run-golden-tests:
name: Run golden tests
timeout-minutes: 5
2024-04-12 07:32:23 +00:00
runs-on: macos-latest
2024-04-11 18:22:07 +00:00
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
2024-04-12 06:12:42 +00:00
- name: Override iap package with stub
id: override-iap
run: bash ./.github/scripts/stub_iap.sh
- name: Restore constants.dart
run: bash .github/scripts/restore_from_base64.sh "${{ secrets.CONSTANTS }}" "lib/constants.dart"
2024-04-11 18:22:07 +00:00
- 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:
2024-04-12 06:15:58 +00:00
UPDATE_GOLDENS: ${{inputs.update-goldens && '--update-goldens' || '' }}
2024-04-11 18:22:07 +00:00
run: |
2024-04-12 07:27:27 +00:00
defaults -currentHost write -g AppleFontSmoothing -int 0
2024-04-11 18:22:07 +00:00
goldens=$(find ./test -name "*_golden_test.dart" -print)
for f in $goldens; do
2024-04-12 07:53:01 +00:00
flutter test "$f" --dart-define cameraStubImage=assets/camera_stub_image.jpg $UPDATE_GOLDENS
2024-04-11 18:22:07 +00:00
done
2024-04-12 07:27:27 +00:00
defaults -currentHost write -g AppleFontSmoothing
2024-04-11 18:22:07 +00:00
- 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 **/goldens/*.png
2024-04-11 18:22:07 +00:00
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