Skip to content

Generate Paparazzi Golden Images #22

Generate Paparazzi Golden Images

Generate Paparazzi Golden Images #22

name: Generate Paparazzi Golden Images
env:
# The name of the main module repository
main_project_module: designsystem
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
ci_job:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
lfs: 'true'
fetch-depth: 0
# Bot token, as in dhis2-android-capture-app: credentials are persisted
# so `git lfs push` can upload the recorded snapshot objects, and a bot
# commit (unlike a GITHUB_TOKEN one) still triggers CI.
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set Up JDK
uses: actions/setup-java@v5
with:
distribution: 'zulu' # See 'Supported distributions' for available options
# 21 runs the build (Paparazzi needs it); 17 satisfies jvmToolchain(17).
# Last entry wins as JAVA_HOME, so keep 21 last.
java-version: |
17
21
cache: 'gradle'
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Validate existing Paparazzi images
id: verify
run: ./gradlew ${{ env.main_project_module }}:verifyPaparazziDebug --no-daemon
continue-on-error: true
- name: Check Verification Status
if: steps.verify.outcome == 'failure'
run: |
echo "::warning::Existing tests failed verification. This might indicate:"
echo " - New tests were added that need golden images"
echo " - Existing tests have been modified"
echo " - There are legitimate test failures"
echo ""
echo "Proceeding with golden image generation..."
- name: Generate Golden images
if: steps.verify.outcome == 'failure'
run: ./gradlew ${{ env.main_project_module }}:recordPaparazziDebug
- name: Revalidate with new recorded images
if: steps.verify.outcome == 'failure'
run: ./gradlew ${{ env.main_project_module }}:verifyPaparazziDebug --no-daemon
- name: Upload recorded images as artifact
if: steps.verify.outcome == 'failure'
uses: actions/upload-artifact@v7.0.1
with:
name: paparazzi-golden-images
path: ${{ env.main_project_module }}/src/androidUnitTest/snapshots/images
# Uploads the LFS objects and leaves pointer text in the working tree, which
# is what gh-commit below must read. See the script for why.
- name: Stage recorded images as LFS pointers
if: steps.verify.outcome == 'failure'
run: .github/workflows/scripts/stage-golden-images.sh
# Commits via the GitHub API (like dhis2-android-capture-app), so the commit
# is signed with GitHub's web-flow key and counts as Verified -- required
# because the "Require signed commits" ruleset covers ~ALL branches with no
# bypass actors, and a plain push of a bot commit is rejected with GH013.
- name: Commit golden images
if: steps.verify.outcome == 'failure'
uses: flex-development/gh-commit@177be4b5bca1b102400ca7220932d9ff7980fddb
with:
message: 'Paparazzi Golden Images'
ref: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}