Skip to content

Instantly share code, notes, and snippets.

@loukwn
Last active May 16, 2023 12:56
Show Gist options
  • Save loukwn/baf52d5cf603ee7819a5936ba5ce1f1c to your computer and use it in GitHub Desktop.
Save loukwn/baf52d5cf603ee7819a5936ba5ce1f1c to your computer and use it in GitHub Desktop.
name: PR checks
on:
issue_comment:
types: [ created, edited ]
pull_request:
branches:
- master
jobs:
test:
if: github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && contains(github.event.comment.html_url, '/pull/') && github.event.comment.body == '!snapshot')
name: Test against snapshots
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Set up Java 11
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- name: Gradle - Verify snapshots with Paparazzi
id: testStep
run: ./gradlew clean snapshot-test:verifyPaparazziDebug
- name: Upload snapshot failure deltas
if: failure()
uses: actions/upload-artifact@v2
with:
name: snapshot-failure-deltas
path: snapshot-test/out/failures/delta-*.png
- name: Find PR number
uses: jwalton/gh-find-current-pr@v1
id: findPr
if: always()
with:
state: open
- name: Find Comment on PR
uses: peter-evans/find-comment@v1
id: fc
if: always()
with:
issue-number: ${{ steps.findPr.outputs.pr }}
comment-author: 'github-actions[bot]'
body-includes: Snapshot testing result
- name: Create or update comment on PR (Success)
uses: peter-evans/create-or-update-comment@v1
if: always() && steps.testStep.outcome == 'success'
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ steps.findPr.outputs.pr }}
body: |
Snapshot testing result: :heavy_check_mark:
Everything looks good!
edit-mode: replace
- name: Create or update comment on PR (Failure)
uses: peter-evans/create-or-update-comment@v1
if: always() && steps.testStep.outcome == 'failure'
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ steps.findPr.outputs.pr }}
body: |
Snapshot testing result: :x:
Some of the snapshot tests seem to have failed. Please:
- Head over to the artifacts section of the [CI Run](https://github.com/loukwn/StageStepBar/actions/runs/${{ github.run_id }}).
- Download the zip.
- Unzip and you can find one or more images that show the expected and the actual test results.
- If these changes are fixing an issue or are part of a new feature then please speak to the maintainer. If they are not intended then please fix them and repush again.
edit-mode: replace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment