Files
radicle-explorer/.github/workflows/explorer-visual.yml
T
Rūdolfs Ošiņš b522155767 explorer: Key visual test caches on the OS release
ubuntu-latest is moving to Ubuntu 26.04, and runners on the new image
restored the 24.04 WebKit build from the cache. It couldn't find
libicudata.so.74 and failed to launch, so the visual tests failed
without any visual diffs.
2026-11-06 10:38:02 +01:00

129 lines
4.0 KiB
YAML

name: explorer-visual
# Only explorer, shared/ui and root npm changes, or changes to this workflow,
# run it. Rust-only changes don't affect the web app: its tests run against a
# pinned, pre-built radicle-httpd.
on:
push:
paths:
- "explorer/**"
- "shared/**"
- "package.json"
- "package-lock.json"
- ".npmrc"
- ".nvmrc"
- "!explorer/crates/**"
- "!explorer/Cargo.toml"
- "!explorer/Cargo.lock"
- "!explorer/rust-toolchain"
- "!explorer/.cargo/**"
- ".github/workflows/explorer-visual.yml"
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
defaults:
run:
working-directory: explorer
jobs:
generate-visual-diffs:
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# Cached browser builds and snapshots are specific to the OS release, so
# key the caches on it and never restore them on a different runner image.
- name: Get runner OS release
id: os
run: echo "release=$(. /etc/os-release && echo "$ID-$VERSION_ID")" >> $GITHUB_OUTPUT
- name: Evict playwright snapshot cache when pushing to master
run: |
if [ ${{ github.ref }} = "refs/heads/master" ]; then
echo "Deleting ${{ steps.os.outputs.release }}-snapshots cache"
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ steps.os.outputs.release }}-snapshots --confirm || true
echo "Done"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v6
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm ci
- name: Get installed Playwright version
id: playwright-version
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
- name: Cache Playwright browsers
uses: actions/cache@v5
id: playwright-dep-cache
with:
path: ~/.cache/ms-playwright
key: ${{ steps.os.outputs.release }}-playwright-${{ steps.playwright-version.outputs.version }}
- name: Cache Playwright visual snapshots
uses: actions/cache@v5
id: playwright-snapshot-cache
with:
path: explorer/tests/visual/snapshots/**/*
key: ${{ steps.os.outputs.release }}-snapshots
- name: Install Playwright browsers
if: steps.playwright-dep-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium webkit --with-deps
- name: Install Playwright dependencies
if: steps.playwright-dep-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps
- name: Install Radicle binaries
run: |
mkdir -p tests/artifacts;
./scripts/install-binaries;
- name: Run Playwright tests
run: |
if [ ${{ github.ref }} = "refs/heads/master" ]; then
npm run test:e2e -- --project visual-desktop visual-mobile --update-snapshots || true;
else
npm run test:e2e -- --project visual-desktop visual-mobile;
fi
# We don't care about logs in visual snapshot tests, only the images.
- name: Cleanup artifacts
if: always()
run: |
shopt -s globstar;
rm -rf tests/artifacts/**/*.log;
- name: Upload artifacts
id: artifacts
uses: actions/upload-artifact@v7
if: always()
with:
name: test-artifacts-${{ runner.os }}
retention-days: 30
if-no-files-found: "ignore"
path: |
explorer/tests/artifacts/**/*
- name: Check for artifacts
id: check_artifacts
run: |
if find ./tests/artifacts/**/*.png; then
echo "present=true" >> $GITHUB_OUTPUT
else
echo "present=false" >> $GITHUB_OUTPUT
fi