Commit 41315cf

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2024-08-24 09:43:02
Update goldens in CI (#392)
* Update CI action to update goldens Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com> * fix not running PR Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com> * fix bash syntax Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com> * fix bash syntax Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com> * push before making PR Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com> * fix push upstream Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com> * fix action permissions Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com> --------- Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent bd0135a
Changed files (1)
.github
workflows
.github/workflows/app-CI.yml
@@ -20,7 +20,9 @@ jobs:
   unit-test:
     name: "🧩🧪 Run unit tests"
     runs-on: ubuntu-latest
- 
+    permissions:
+      contents: write
+      pull-requests: write
     steps:
     - name: Checkout code
       uses: actions/checkout@v4
@@ -50,10 +52,30 @@ jobs:
     - name: Run tests
       run: flutter test --coverage
       working-directory: app
-    - uses: actions/upload-artifact@v4
-      with:
-        name: app-coverage
-        path: app/coverage/lcov.info
+    - name: Update goldens
+      id: gold-upd
+      if: failure()
+      run: flutter test --update-goldens --fail-fast
+      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 }}
 
 #  Disabled: Integration tests are disabled as emulator setup fails on
 #  GH-actions. Actions images no longer provide enough disk space to create