Fix test failure intorduced in #504 (#507) #150
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: '📱 Application' | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- "app/**" | |
- "health_data_store/**" | |
- "extendend-testing.yml" | |
workflow_dispatch: | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
channel: | |
- beta | |
- stable | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
# ensures there are no unexpected directories needed | |
sparse-checkout: | | |
app | |
health_data_store | |
- name: Cache generated health data store | |
id: cache-generated | |
uses: actions/cache@v4 | |
with: | |
path: health_data_store/lib | |
key: builder-${{ matrix.channel }}-${{ hashFiles('health_data_store/pubspec.yaml', 'health_data_store/lib/*', 'health_data_store/lib/**/*dart') }} | |
- name: Setup dart | |
if: steps.cache-generated.outputs.cache-hit != 'true' | |
uses: dart-lang/setup-dart@v1 | |
with: | |
sdk: ${{ matrix.channel }} | |
- name: Generate code | |
if: steps.cache-generated.outputs.cache-hit != 'true' | |
run: dart run build_runner build | |
working-directory: health_data_store | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: ${{ matrix.channel }} | |
cache: true | |
- name: Disable analytics | |
run: | |
flutter config --no-analytics --suppress-analytics | |
- name: Update app dependencies | |
run: flutter pub get | |
working-directory: app | |
- name: Generate app mock code # no efficient caching possible | |
run: flutter pub run build_runner build | |
working-directory: app | |
- name: Run tests | |
run: flutter test --coverage --dart-define="channel=${{ matrix.channel }}" | |
working-directory: app | |
- name: Update goldens | |
id: gold-upd | |
if: failure() | |
run: flutter test --update-goldens --fail-fast --name="\[gold\].*" --dart-define="channel=${{ matrix.channel }}" | |
working-directory: app | |
- name: PR golden changes | |
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#example-of-failure-with-conditions | |
if: ${{ failure() && steps.gold-upd.conclusion == 'success' }} | |
run: | | |
git config user.name "GitHub Action (update goldens)" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git checkout -B action-update-goldens | |
export STATUS=$(git status) | |
git commit -am "Update goldens" | |
git push --set-upstream origin action-update-goldens | |
gh pr create \ | |
--base main \ | |
--head action-update-goldens \ | |
--title "Update goldens" \ | |
--body "$STATUS" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |