Skip to content

Allow action and dynamicLayout as root template nodes #103

Allow action and dynamicLayout as root template nodes

Allow action and dynamicLayout as root template nodes #103

Workflow file for this run

name: Snapshot Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
record:
description: "Re-record baselines and open PR"
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# ── Pin runner and tool versions ─────────────────────────────────
# Snapshot tests are pixel-sensitive. Changing any of these versions
# will likely require re-recording baselines via workflow dispatch.
env:
MACOS_RUNNER: macos-26
UBUNTU_RUNNER: ubuntu-24.04
NODE_VERSION: "20"
JAVA_VERSION: "17"
IOS_SIMULATOR: iPhone 17 Pro
jobs:
# ── Verify mode (push / PR) ──────────────────────────────────
web:
name: Web (Playwright)
if: ${{ !inputs.record }}
runs-on: ${{ vars.MACOS_RUNNER || 'macos-26' }}
defaults:
run:
working-directory: web
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: web/package-lock.json
- run: npm ci
- run: npm run build
- run: npx playwright install chromium
- run: npx playwright test
- name: Upload diff artifacts
if: failure()
uses: actions/upload-artifact@v5
with:
name: web-snapshot-diffs
path: web/test-results/
ios:
name: iOS (swift-snapshot-testing)
if: ${{ !inputs.record }}
runs-on: ${{ vars.MACOS_RUNNER || 'macos-26' }}
defaults:
run:
working-directory: ios
steps:
- uses: actions/checkout@v5
- name: Select Xcode
run: |
XCODE_PATH=$(ls -d /Applications/Xcode_26.4* 2>/dev/null | head -1)
if [ -z "$XCODE_PATH" ]; then
echo "Xcode 26.4 not found, using default"
else
sudo xcode-select -s "$XCODE_PATH"
fi
xcodebuild -version
- run: >-
xcodebuild test
-scheme Jist
-destination 'platform=iOS Simulator,name=${{ env.IOS_SIMULATOR }}'
-skipPackagePluginValidation
- name: Upload diff artifacts
if: failure()
uses: actions/upload-artifact@v5
with:
name: ios-snapshot-diffs
path: ios/Tests/JistTests/__Snapshots__/
android:
name: Android (Paparazzi)
if: ${{ !inputs.record }}
runs-on: ${{ vars.UBUNTU_RUNNER || 'ubuntu-24.04' }}
defaults:
run:
working-directory: android
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
distribution: zulu
java-version: ${{ env.JAVA_VERSION }}
cache: gradle
- run: ./gradlew :example:verifyPaparazziDebug
- name: Upload diff artifacts
if: failure()
uses: actions/upload-artifact@v5
with:
name: android-snapshot-diffs
path: android/example/build/reports/paparazzi/
# ── Record mode (workflow dispatch) ──────────────────────────
record:
name: Record baselines & open PR
if: ${{ inputs.record }}
runs-on: ${{ vars.MACOS_RUNNER || 'macos-26' }}
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v5
# ── Xcode ──
- name: Select Xcode
run: |
XCODE_PATH=$(ls -d /Applications/Xcode_26.4* 2>/dev/null | head -1)
if [ -z "$XCODE_PATH" ]; then
echo "Xcode 26.4 not found, using default"
else
sudo xcode-select -s "$XCODE_PATH"
fi
xcodebuild -version
# ── Web ──
- uses: actions/setup-node@v5
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: web/package-lock.json
- name: Record web baselines
working-directory: web
run: |
npm ci
npm run build
npx playwright install chromium
npx playwright test --update-snapshots || true
# ── iOS ──
- name: Record iOS baselines
working-directory: ios
run: |
sed -i '' 's|// isRecording = true|isRecording = true|' Tests/JistTests/SnapshotTests.swift Tests/JistTests/ComponentSnapshotTests.swift
xcodebuild test \
-scheme Jist \
-destination 'platform=iOS Simulator,name=${{ env.IOS_SIMULATOR }}' \
-skipPackagePluginValidation || true
# ── Android ──
- uses: actions/setup-java@v5
with:
distribution: zulu
java-version: ${{ env.JAVA_VERSION }}
- name: Record Android baselines
working-directory: android
run: ./gradlew :example:recordPaparazziDebug
# ── Open PR ──
- name: Create PR with updated baselines
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout -- ios/Tests/JistTests/SnapshotTests.swift ios/Tests/JistTests/ComponentSnapshotTests.swift
BRANCH="ci/update-snapshots-$(date +%Y%m%d-%H%M%S)"
git checkout -b "$BRANCH"
git add \
web/tests/__snapshots__ \
ios/Tests/JistTests/__Snapshots__ \
android/example/src/test/snapshots
if git diff --cached --quiet; then
echo "No snapshot changes detected"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "Update snapshot baselines from CI"
git push origin "$BRANCH"
gh pr create \
--title "Update snapshot baselines" \
--base "${{ github.ref_name }}" \
--body "Re-recorded snapshot baselines from CI runners.
Triggered via workflow dispatch."