Visual Regression Test (on GitHub-hosted) #317
This file contains 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: VRT | |
run-name: Visual Regression Test ${{ (vars.RUNS_ON_SELF_HOSTED == null && '(on GitHub-hosted)') || '(on self-hosted)' }} | |
on: | |
pull_request: | |
paths: | |
- 'lib/**' | |
- 'test/**' | |
- 'android/**' | |
- 'ios/**' | |
- 'pubspec.yaml' | |
- 'pubspec.lock' | |
- '.github/workflows/vrt.yml' # this file | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pull-requests: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash -euo pipefail {0} | |
jobs: | |
prepare: | |
runs-on: ${{ (vars.RUNS_ON_SELF_HOSTED == null && 'ubuntu-24.04') || 'self-hosted' }} | |
timeout-minutes: 30 | |
outputs: | |
actual-sha: ${{ steps.prepare.outputs.actual-sha }} | |
actual-cache-hit: ${{ steps.prepare.outputs.actual-cache-hit }} | |
expected-sha: ${{ steps.prepare.outputs.expected-sha }} | |
expected-cache-hit: ${{ steps.prepare.outputs.expected-cache-hit }} | |
steps: | |
- uses: yorifuji/easy-vrt/prepare@768a9164b6969de17cbcdfb559cb011383a4a059 # v2.0.0 | |
id: prepare | |
expected: | |
if: ${{ !cancelled() && !failure() && needs.prepare.outputs.expected-cache-hit != 'true' }} | |
needs: prepare | |
runs-on: ${{ (vars.RUNS_ON_SELF_HOSTED == null && 'ubuntu-24.04') || 'self-hosted' }} | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
ref: ${{ needs.prepare.outputs.expected-sha }} | |
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # v2.18.0 | |
with: | |
flutter-version: ${{ (vars.FLUTTER_VERSION != null && vars.FLUTTER_VERSION) || '' }} | |
channel: stable | |
cache: ${{ (vars.RUNS_ON_SELF_HOSTED == null && true) || false }} | |
- run: flutter pub get | |
- name: Run pre-process script | |
env: | |
PREPROCESS_SCRIPT_BASE64: ${{ secrets.PREPROCESS_SCRIPT_BASE64 }} | |
run: | | |
if [ -n "$PREPROCESS_SCRIPT_BASE64" ]; then | |
echo "$PREPROCESS_SCRIPT_BASE64" | base64 --decode > ${{ runner.temp }}/pre-process.sh && bash ${{ runner.temp }}/pre-process.sh | |
fi | |
- name: Create golden images | |
run: | | |
flutter test --update-goldens --tags=golden || exit 0 | |
- uses: yorifuji/easy-vrt/expected@768a9164b6969de17cbcdfb559cb011383a4a059 # v2.0.0 | |
with: | |
expected-dir: test/golden_test/goldens | |
expected-cache-key: ${{ needs.prepare.outputs.expected-sha }} | |
actual: | |
if: ${{ !cancelled() && !failure() && needs.prepare.outputs.actual-cache-hit != 'true' }} | |
needs: prepare | |
runs-on: ${{ (vars.RUNS_ON_SELF_HOSTED == null && 'ubuntu-24.04') || 'self-hosted' }} | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
ref: ${{ needs.prepare.outputs.actual-sha }} | |
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # v2.18.0 | |
with: | |
flutter-version: ${{ (vars.FLUTTER_VERSION != null && vars.FLUTTER_VERSION) || '' }} | |
channel: stable | |
cache: ${{ (vars.RUNS_ON_SELF_HOSTED == null && true) || false }} | |
- run: flutter pub get | |
- name: Run pre-process script | |
env: | |
PREPROCESS_SCRIPT_BASE64: ${{ secrets.PREPROCESS_SCRIPT_BASE64 }} | |
run: | | |
if [ -n "$PREPROCESS_SCRIPT_BASE64" ]; then | |
echo "$PREPROCESS_SCRIPT_BASE64" | base64 --decode > ${{ runner.temp }}/pre-process.sh && bash ${{ runner.temp }}/pre-process.sh | |
fi | |
- name: Create golden images | |
run: | | |
flutter test --update-goldens --tags=golden || exit 0 | |
- uses: yorifuji/easy-vrt/actual@768a9164b6969de17cbcdfb559cb011383a4a059 # v2.0.0 | |
with: | |
actual-dir: test/golden_test/goldens | |
actual-cache-key: ${{ needs.prepare.outputs.actual-sha }} | |
compare: | |
if: ${{ !cancelled() && !failure() }} | |
needs: [prepare, expected, actual] | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: yorifuji/easy-vrt/compare@768a9164b6969de17cbcdfb559cb011383a4a059 # v2.0.0 | |
with: | |
expected-cache-key: ${{ needs.prepare.outputs.expected-sha }} | |
actual-cache-key: ${{ needs.prepare.outputs.actual-sha }} | |
summary-comment: true | |
review-comment: true | |
action-timeline: | |
needs: [compare] | |
if: ${{ !cancelled() }} | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: Kesin11/actions-timeline@3046833d9aacfd7745c5264b7f3af851c3e2a619 # v2.2.1 |