Skip to content

Visual Regression Test (on GitHub-hosted) #268

Visual Regression Test (on GitHub-hosted)

Visual Regression Test (on GitHub-hosted) #268

Workflow file for this run

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:
lookup:
runs-on: ${{ (vars.RUNS_ON_SELF_HOSTED == null && 'ubuntu-latest') || 'self-hosted' }}
timeout-minutes: 30
outputs:
actual-sha: ${{ steps.lookup.outputs.actual-sha }}
actual-cache-hit: ${{ steps.lookup.outputs.actual-cache-hit }}
expected-sha: ${{ steps.lookup.outputs.expected-sha }}
expected-cache-hit: ${{ steps.lookup.outputs.expected-cache-hit }}
steps:
- uses: yorifuji/easy-vrt@fa200819e456c851c11c1a2d534098c8a0e0d9be # v1.0.7
id: lookup
with:
mode: lookup
expected:
if: ${{ !cancelled() && !failure() && needs.lookup.outputs.expected-cache-hit != 'true' }}
needs: lookup
runs-on: ${{ (vars.RUNS_ON_SELF_HOSTED == null && 'ubuntu-latest') || 'self-hosted' }}
timeout-minutes: 30
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ needs.lookup.outputs.expected-sha }}
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # v2.16.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@fa200819e456c851c11c1a2d534098c8a0e0d9be # v1.0.7
with:
mode: expected
expected-dir: test/golden_test/goldens
expected-cache-key: ${{ needs.lookup.outputs.expected-sha }}
actual:
if: ${{ !cancelled() && !failure() && needs.lookup.outputs.actual-cache-hit != 'true' }}
needs: lookup
runs-on: ${{ (vars.RUNS_ON_SELF_HOSTED == null && 'ubuntu-latest') || 'self-hosted' }}
timeout-minutes: 30
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ needs.lookup.outputs.actual-sha }}
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # v2.16.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@fa200819e456c851c11c1a2d534098c8a0e0d9be # v1.0.7
with:
mode: actual
actual-dir: test/golden_test/goldens
actual-cache-key: ${{ needs.lookup.outputs.actual-sha }}
compare:
if: ${{ !cancelled() && !failure() }}
needs: [lookup, expected, actual]
runs-on: ubuntu-latest
steps:
- uses: yorifuji/easy-vrt@fa200819e456c851c11c1a2d534098c8a0e0d9be # v1.0.7
with:
mode: compare
expected-cache-key: ${{ needs.lookup.outputs.expected-sha }}
actual-cache-key: ${{ needs.lookup.outputs.actual-sha }}
summary-comment: true
review-comment: true
action-timeline:
needs: [compare]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- uses: Kesin11/actions-timeline@3046833d9aacfd7745c5264b7f3af851c3e2a619 # v2.2.1