Commit 6e3d1eb

derdilla <82763757+derdilla@users.noreply.github.com>
2025-01-21 14:31:05
Fix new actions (#513) tag: v1.8.4
* 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
1 parent 469c93a
Changed files (2)
.github
.github/workflows/labeler.yml
@@ -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:
@@ -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:
@@ -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:
.github/workflows/pr.yml
@@ -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
@@ -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
@@ -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
@@ -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
+