Update Transitive Dependencies #193
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Visual Diff | |
| on: | |
| pull_request: | |
| types: [labeled, unlabeled, opened, synchronize, reopened] | |
| concurrency: | |
| group: visual-diff-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| baseline: | |
| name: Baseline | |
| runs-on: ubuntu-latest | |
| outputs: | |
| ref: ${{ steps.ref.outputs.ref }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.base_ref }} | |
| - id: ref | |
| run: | | |
| echo "$(git rev-parse HEAD)" | |
| echo "ref=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| - name: Cache Screenshots | |
| id: screenshot-cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: build | |
| key: screenshots-${{ steps.ref.outputs.ref }} | |
| - uses: pnpm/action-setup@v5 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| - name: Install Dependencies | |
| if: steps.screenshot-cache.outputs.cache-hit != 'true' | |
| run: | | |
| pnpm install | |
| pnpm exec playwright install --with-deps | |
| - name: Capture Screenshots | |
| if: steps.screenshot-cache.outputs.cache-hit != 'true' | |
| run: pnpm run test:screenshots | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: baseline | |
| path: build | |
| candidate: | |
| name: Candidate | |
| runs-on: ubuntu-latest | |
| outputs: | |
| ref: ${{ steps.ref.outputs.ref }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - id: ref | |
| run: | | |
| echo "$(git rev-parse HEAD)" | |
| echo "ref=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| - name: Cache Screenshots | |
| id: screenshot-cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: build | |
| key: screenshots-${{ steps.ref.outputs.ref }}-${{ matrix.name }} | |
| - uses: pnpm/action-setup@v5 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| - name: Install Dependencies | |
| if: steps.screenshot-cache.outputs.cache-hit != 'true' | |
| run: | | |
| pnpm install | |
| pnpm exec playwright install --with-deps | |
| - name: Capture Screenshots | |
| if: steps.screenshot-cache.outputs.cache-hit != 'true' | |
| run: pnpm test:screenshots | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: candidate | |
| path: build | |
| compare: | |
| name: Visual Diff | |
| needs: [baseline, candidate] | |
| runs-on: ubuntu-latest | |
| env: | |
| OUTPUT_DIR: visual-diff-${{ github.event.pull_request.number }} | |
| BASELINE_REF: ${{needs.baseline.outputs.ref}} | |
| CANDIDATE_REF: ${{needs.candidate.outputs.ref}} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - uses: pnpm/action-setup@v5 | |
| - name: Restore Comparison Cache | |
| id: comparison-cache | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: | | |
| ${{ env.OUTPUT_DIR }} | |
| results | |
| key: comparison-${{ env.BASELINE_REF }}-${{ env.CANDIDATE_REF }} | |
| - uses: actions/download-artifact@v8 | |
| if: steps.comparison-cache.outputs.cache-hit != 'true' | |
| - run: ls -lh baseline candidate 2>/dev/null || true | |
| - run: | | |
| mkdir -p ./results | |
| echo ${{ github.event.pull_request.number }} > ./results/pr_number | |
| - run: pnpm install | |
| if: steps.comparison-cache.outputs.cache-hit != 'true' | |
| - run: pnpm build | |
| if: steps.comparison-cache.outputs.cache-hit != 'true' | |
| - name: Create Visual Diff | |
| if: steps.comparison-cache.outputs.cache-hit != 'true' | |
| run: | | |
| set +e | |
| node ./dist/bin/visual-differ.js --threshold=0.1 baseline candidate ${{ env.OUTPUT_DIR }} > results/visual-diff.txt | |
| exit_code=$? | |
| echo $exit_code > ./results/exit_code | |
| cp ${{ env.OUTPUT_DIR }}/report.md results/ | |
| cat results/report.md results/visual-diff.txt | |
| - uses: actions/upload-artifact@v7 | |
| id: upload-output | |
| with: | |
| name: ${{ env.OUTPUT_DIR }} | |
| path: ${{ env.OUTPUT_DIR }} | |
| - run: | | |
| echo ${{ steps.upload-output.outputs.artifact-url }} > ./results/artifact_url | |
| echo ${{ contains(github.event.pull_request.labels.*.name, 'approve visual diff') }} > ./results/approved | |
| - name: Save Comparison Cache | |
| if: steps.comparison-cache.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: | | |
| ${{ env.OUTPUT_DIR }} | |
| results | |
| key: ${{ steps.comparison-cache.outputs.cache-primary-key }} | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: results | |
| path: results | |
| - name: Check Status | |
| run: | | |
| exitCode=$(cat ./results/exit_code) | |
| approved=$(cat ./results/approved) | |
| echo "visual-differ exit code: $exitCode" | |
| echo "approve visual diff label present: $approved" | |
| if [ "$exitCode" != "0" ] && [ "$approved" != "true" ]; then | |
| echo "Visual diff detected and 'approve visual diff' label not present." | |
| exit 1 | |
| fi |