feat: react 19 codemod #994
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: test-storybook | |
on: | |
pull_request: | |
types: [labeled, unlabeled, opened, synchronize, reopened] | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
prepare-base-branch: | |
name: Prepare base branch image snapshots | |
timeout-minutes: 20 | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout base branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.base.ref }} | |
fetch-depth: 0 | |
- name: Check commit hash | |
id: commit-hash | |
run: echo "hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Restore image snapshot from cache | |
uses: actions/cache@v4 | |
id: cache-image-snapshots | |
with: | |
path: __image_snapshots__ | |
key: image-snapshots-${{ steps.commit-hash.outputs.hash }} | |
- name: setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: '10.4.0' | |
- uses: actions/setup-node@v4 | |
if: steps.cache-image-snapshots.outputs.cache-hit != 'true' | |
with: | |
node-version-file: '.node-version' | |
cache: pnpm | |
- name: Install dependencies | |
if: steps.cache-image-snapshots.outputs.cache-hit != 'true' | |
run: pnpm install --frozen-lockfile | |
- name: Cache Playwright runners | |
if: steps.cache-image-snapshots.outputs.cache-hit != 'true' | |
uses: actions/cache@v4 | |
with: | |
path: | | |
/home/runner/.cache/ms-playwright/ | |
key: ${{ runner.os }}-playwright-runner | |
- name: Install Playwright | |
if: steps.cache-image-snapshots.outputs.cache-hit != 'true' | |
run: pnpm playwright install --with-deps | |
- name: Build Storybook | |
if: steps.cache-image-snapshots.outputs.cache-hit != 'true' | |
run: pnpm build | |
- name: Serve Storybook and run tests | |
if: steps.cache-image-snapshots.outputs.cache-hit != 'true' | |
run: pnpm test:image-snapshot --updateSnapshot | |
- name: Upload base branch snapshots | |
uses: actions/upload-artifact@v4 | |
with: | |
name: base__image-snapshots__ | |
path: __image_snapshots__/ | |
test-storybook: | |
name: Build Storybook | |
timeout-minutes: 20 | |
runs-on: ubuntu-22.04 | |
needs: prepare-base-branch | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v4 | |
- name: setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: '10.4.0' | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.node-version' | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Cache Playwright runners | |
uses: actions/cache@v4 | |
with: | |
path: | | |
/home/runner/.cache/ms-playwright/ | |
key: ${{ runner.os }}-playwright-runner | |
- name: Install Playwright | |
run: pnpm playwright install --with-deps | |
- name: Build Storybook | |
run: pnpm build | |
- name: Check label | |
uses: actions/github-script@v7 | |
id: label-checking | |
env: | |
SNAPSHOT_UPDATE_LABEL: image snapshots update | |
with: | |
result-encoding: string | |
script: | | |
const { issue, repo } = context | |
const { data: pull } = await github.rest.issues.get({ | |
issue_number: issue.number, | |
owner: repo.owner, | |
repo: repo.repo | |
}) | |
const labels = pull.labels.map(({ name }) => name) | |
if(labels.includes(process.env.SNAPSHOT_UPDATE_LABEL)){ | |
console.log(`Found "${process.env.SNAPSHOT_UPDATE_LABEL}" label, image snapshots will be updated."`) | |
return 'true' | |
} | |
console.log(`Not fount "${process.env.SNAPSHOT_UPDATE_LABEL}" label. Compare with image snapshots of main branch.`) | |
return 'false' | |
- name: Load base branch image snapshots | |
uses: actions/download-artifact@v4 | |
if: steps.label-checking.outputs.result != 'true' | |
with: | |
name: base__image-snapshots__ | |
path: __image_snapshots__/ | |
- name: Verify Storybook server can start | |
run: | | |
pnpm http-server storybook-static --port 6006 --silent & | |
PID=$! | |
pnpm wait-on -t 60000 tcp:127.0.0.1:6006 | |
kill $PID | |
- name: Serve Storybook and run tests | |
if: steps.label-checking.outputs.result != 'true' | |
run: pnpm test:image-snapshot:ci | |
- name: Serve Storybook and take new image snapshots | |
if: steps.label-checking.outputs.result == 'true' | |
run: pnpm test:image-snapshot:ci --updateSnapshot | |
- name: Archive image snapshot diffs | |
uses: actions/upload-artifact@v4 | |
if: failure() && steps.label-checking.outputs.result != 'true' | |
with: | |
path: __diff_output__/ | |
- name: Archive new image snapshots | |
if: steps.label-checking.outputs.result == 'true' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: new__image_snapshots__ | |
path: __image_snapshots__/ |