Skip to content

Commit

Permalink
Fix new actions (#513)
Browse files Browse the repository at this point in the history
* Fix pr.yml syntax error

* Update insufficient labeler.yml permissions

* Update insufficient labeler.yml permissions

* Update pr.yml

* Don't attempt to commit when no files change

* fix auto commit

* only detect png changes
  • Loading branch information
derdilla authored Jan 21, 2025
1 parent 469c93a commit 6e3d1eb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Label PRs & Issues
description: Allows external contributors to add labels to add labels to issues and PRs.
# Note for maintainers: Don't add labels that can be abused

on:
Expand All @@ -12,6 +11,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- run: gh issue edit "$NUMBER" --add-label "$LABELS"
env:
Expand All @@ -24,6 +24,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- run: gh issue edit "$NUMBER" --add-label "$LABELS"
env:
Expand Down
39 changes: 21 additions & 18 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ jobs:
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
Expand All @@ -52,26 +47,33 @@ jobs:
- name: Update app dependencies
run: flutter pub get
working-directory: app
# Golden tests don't need mocks if they ever do this would be a good oportunity to
# introduce test mock testign
# TODO: cache using non-generated dart files in the test dir as key
- name: Generate app mock code
run: flutter pub run build_runner build
working-directory: app
- name: Update goldens
id: gold-upd
run: flutter test --update-goldens --fail-fast --name="\[gold\].*" --dart-define="channel=${{ matrix.channel }}"
working-directory: app
- name: PR golden changes
- name: Push 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: ${{ 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 add app/test/**/*.png
git commit -m "Update goldens"
git push
if [[ $(git status -s | grep png) ]]; then
git config user.name "GitHub Action (update goldens)"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add app/test/
git commit -m "Update goldens"
git push
else
echo "no changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}%
test:
if: contains(github.event.pull_request.labels.*.name, 'auto-test')
runs-on: ubuntu-latest
needs: update-goldens # this is guaranteed to fail if goldens need to be updated
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -106,7 +108,8 @@ jobs:
- name: Update app dependencies
run: flutter pub get
working-directory: app
- name: Generate app mock code # no efficient caching possible
# TODO: cache using non-generated dart files in the test dir as key
- name: Generate app mock code
run: flutter pub run build_runner build
working-directory: app
- name: Run tests
Expand Down Expand Up @@ -149,15 +152,15 @@ jobs:
channel: ${{ matrix.channel }}
cache: true
- name: Disable analytics
run:
flutter config --no-analytics --suppress-analytics
run: flutter config --no-analytics --suppress-analytics
- name: Update app dependencies
run: flutter pub get
working-directory: app
- name: Build
run: flutter build apk --debug --flavor=github
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-results
path: app/build/app/outputs/flutter-apk
- name: Build
run: flutter build apk --debug --flavor=github

0 comments on commit 6e3d1eb

Please sign in to comment.