Skip to content

Commit

Permalink
Automate updating screenshots (#1633)
Browse files Browse the repository at this point in the history
* Test screenshot updates in PR

* Fix screenshots
  • Loading branch information
yschimke authored Aug 31, 2023
1 parent 347b2be commit e957c9c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,32 @@ jobs:

- name: Unit Tests
uses: gradle/gradle-build-action@v2
id: screenshotsverify
continue-on-error: true
with:
arguments: testDebug --rerun

- name: Prevent pushing new screenshots if this is a fork
id: checkfork
continue-on-error: false
if: steps.screenshotsverify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "::error::Screenshot tests failed, please create a PR in your fork first." && exit 1
- name: Generate new screenshots if verification failed and it's a PR
id: screenshotsrecord
if: steps.screenshotsverify.outcome == 'failure' && github.event_name == 'pull_request'
run: |
./gradlew testDebug -P screenshot.record=repair
- name: Push new screenshots if available
uses: stefanzweifel/git-auto-commit-action@v4
if: steps.screenshotsrecord.outcome == 'success'
with:
file_pattern: '**/snapshots/images/*.png'
disable_globbing: true
commit_message: "🤖 Updates screenshots"

- name: Upload test results and reports
if: always()
uses: actions/upload-artifact@v3
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ on a Linux host. Alternatively uncomment the same property in gradle.properties.
./gradlew testDebug -P screenshot.record=repair
```

This can be automated For a PR against the same branch, the Github action should commit against
PR if possible. For maintainers, this means creating the branch in the google/horologist repo.
For contributors, once your PR fails, create a second PR in your fork, that will fix the issue.

## Contributor License Agreement

Expand Down

0 comments on commit e957c9c

Please sign in to comment.