Merge pull request #833 from openameba/release/major #2396
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: visual regression test | |
on: | |
push: | |
branches: | |
- main | |
pull_request_target: | |
paths: | |
- 'packages/spindle-ui/**' | |
workflow_dispatch: | |
jobs: | |
check_condition: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
outputs: | |
result: ${{ steps.condition.outputs.result }} | |
steps: | |
- if: github.event_name == 'pull_request' | |
uses: actions/checkout@v3 | |
with: | |
ref: 'refs/pull/${{ github.event.number }}/merge' | |
- run: echo 'RESULT=false' >> "$GITHUB_ENV" | |
- name: execute if triggered by members | |
if: > | |
github.event_name == 'push' || | |
github.event_name == 'workflow_dispatch' | |
run: echo 'RESULT=true' >> "$GITHUB_ENV" | |
- name: execute if the PR from a forked repository, it have the [allow execute workflow] label | |
if: > | |
github.event_name == 'pull_request' && | |
github.event.pull_request.head.repo.full_name != github.repository && | |
contains(github.event.pull_request.labels.*.name, 'allow execute workflow') | |
run: echo 'RESULT=true' >> "$GITHUB_ENV" | |
- name: execute if the PR from a this repository | |
if: > | |
github.event_name == 'pull_request' && | |
github.event.pull_request.head.repo.full_name == github.repository | |
run: echo 'RESULT=true' >> "$GITHUB_ENV" | |
- id: condition | |
run: echo "result=${RESULT}" >> "$GITHUB_OUTPUT" | |
visual_regression_test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
needs: check_condition | |
if: needs.check_condition.outputs.result == 'true' | |
steps: | |
- run: sudo apt-get --yes update | |
- run: sudo apt-get --yes install fonts-noto | |
- if: github.event_name == 'pull_request' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: 'refs/pull/${{ github.event.number }}/merge' | |
- if: github.event_name != 'pull_request' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: restore lerna | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
*/*/node_modules | |
key: ${{ runner.os }}-${{ github.event_name }}-${{ hashFiles('**/yarn.lock') }}-v2 | |
- run: yarn install --frozen-lockfile | |
- run: | | |
yarn lerna run --scope @openameba/spindle-hooks build | |
yarn lerna run --scope @openameba/spindle-ui storybook:build | |
- run: yarn workspace @openameba/spindle-ui add reg-keygen-git-hash-plugin reg-notify-github-plugin reg-publish-gcs-plugin --dev | |
- name: capture stories | |
run: > | |
npx storycap | |
--outDir packages/spindle-ui/.reg-suit/actual_images/ | |
--serverCmd 'npx serve -p 5000 packages/spindle-ui/public' | |
http://localhost:5000 | |
- run: git checkout ${{ github.head_ref || github.ref_name }} | |
- run: | | |
printf -- '%s' "$GOOGLE_APPLICATION_CREDENTIALS_JSON" | base64 --decode > "${PWD}/storage-key.json" | |
export GOOGLE_APPLICATION_CREDENTIALS="${PWD}/storage-key.json" | |
yarn lerna run --scope @openameba/spindle-ui test:regression | |
env: | |
GCS_BUCKET_NAME_REG_SUIT: ${{ secrets.GCS_BUCKET_NAME_REG_SUIT }} | |
GOOGLE_APPLICATION_CREDENTIALS_JSON: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }} | |
REG_SUIT_NOTIFY_CLIENT_ID: ${{ secrets.REG_SUIT_NOTIFY_CLIENT_ID }} |