forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch master into master-merge-feature
- Loading branch information
Showing
17 changed files
with
266 additions
and
50 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Each `push on master` will persist image-snapshots that used as compare target in visual regression. | ||
|
||
name: Visual Regression Persist Finish | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["name: Visual Regression Persist Start"] | ||
types: | ||
- completed | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
upstream-workflow-summary: | ||
name: upstream workflow summary | ||
runs-on: ubuntu-latest | ||
outputs: | ||
jobs: ${{ steps.persist_start_job_status.outputs.result }} | ||
build-success: ${{ steps.persist_start_job_status.outputs.build-success }} | ||
build-failure: ${{ steps.persist_start_job_status.outputs.build-failure }} | ||
steps: | ||
- name: summary jobs status | ||
uses: actions/github-script@v6 | ||
id: persist_start_job_status | ||
with: | ||
# todo: split it out as github actions | ||
script: | | ||
const response = await github.rest.actions.listJobsForWorkflowRun({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{ github.event.workflow_run.id }}, | ||
}); | ||
// { [name]: [conclusion] }, e.g. { 'test image': 'success' } | ||
const jobs = (response.data?.jobs ?? []).reduce((acc, job) => { | ||
if(job?.status === 'completed' && 'name' in job && 'conclusion' in job) { | ||
acc[job.name] = job.conclusion; | ||
} | ||
return acc; | ||
}, {}); | ||
const total = Object.keys(jobs).length; | ||
if(total === 0) core.setFailed('no jobs found'); | ||
// the name here must be the same as `jobs.xxx.{name}` in preview-build.yml | ||
// set output | ||
core.setOutput('build-success', jobs['test image'] === 'success'); | ||
core.setOutput('build-failure', jobs['test image'] === 'failure'); | ||
return jobs; | ||
persist-image-snapshots: | ||
name: persist image-snapshots | ||
permissions: | ||
actions: read # for dawidd6/action-download-artifact to query and download artifacts | ||
runs-on: ubuntu-latest | ||
needs: upstream-workflow-summary | ||
steps: | ||
# We need get persist key first | ||
- name: Download Visual Regression Ref | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
run_id: ${{ github.event.workflow_run.id }} | ||
name: visual-regression-persist-ref | ||
|
||
# Save visual-regression ref to output | ||
- name: Extra Visual Regression Ref | ||
id: visuall-regression | ||
run: echo "id=$(<visual-regression-ref.txt)" >> $GITHUB_OUTPUT | ||
|
||
- name: Download Visual-Regression Artifact | ||
if: ${{ fromJSON(needs.upstream-workflow-summary.outputs.build-success) }} | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
run_id: ${{ github.event.workflow_run.id }} | ||
name: image-snapshots | ||
path: imageSnapshots | ||
|
||
- name: Persist to Snapshot Repo | ||
if: github.event.pull_request.head.ref == 'master' | ||
id: persist | ||
continue-on-error: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.ANTD_IMAGE_SNAP_REPO_TOKEN }} | ||
# should push to snapshot repo firstly | ||
# push the single folder to the repo | ||
run: | | ||
git config user.name "Antd Visual-Regression Bot" | ||
git config user.email "<>" | ||
git clone [email protected]:ant-design/antd-image-snapshots.git | ||
rm antd-image-snapshots/*.txt | ||
rm -rf antd-image-snapshots/imageSnapshots | ||
mv visual-regression-ref.txt antd-image-snapshots/ | ||
mv ./imageSnapshots antd-image-snapshots/ | ||
cd antd-image-snapshots | ||
git add . | ||
git cm -m 'feat: update snapshot from ${{steps.visuall-regression.outputs.id}}' | ||
git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | \ | ||
xargs -L1 git config --unset-all | ||
git push --prune https://token:[email protected]/ant-design/antd-image-snapshots.git +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Each `push on master` will persist image-snapshots that used as compare target in visual regression. | ||
|
||
name: Visual Regression Persist Start | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
# Prepare node modules. Reuse cache if available | ||
setup: | ||
name: prepare node_modules | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/puppeteer/puppeteer:21.5.2 | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: cache package-lock.json | ||
uses: actions/cache@v3 | ||
with: | ||
path: package-temp-dir | ||
key: lock-${{ github.sha }} | ||
|
||
- name: create package-lock.json | ||
run: npm i --package-lock-only --ignore-scripts | ||
|
||
- name: hack for single file | ||
run: | | ||
if [ ! -d "package-temp-dir" ]; then | ||
mkdir package-temp-dir | ||
fi | ||
cp package-lock.json package-temp-dir | ||
- name: cache node_modules | ||
id: node_modules_cache_id | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} | ||
|
||
- name: install | ||
if: steps.node_modules_cache_id.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
test-image: | ||
name: test image | ||
runs-on: ubuntu-latest | ||
needs: setup | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: restore cache from package-lock.json | ||
uses: actions/cache@v3 | ||
with: | ||
path: package-temp-dir | ||
key: lock-${{ github.sha }} | ||
|
||
- name: restore cache from node_modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} | ||
|
||
- name: generate image snapshots | ||
id: site | ||
run: | | ||
npm run version | ||
npm run test-image | ||
env: | ||
SITE_ENV: development | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
|
||
# Upload `imageSnapshots` on master | ||
- name: upload report artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: image-snapshots | ||
path: imageSnapshots/ | ||
|
||
# Upload git ref for next workflow `visual-regression-persist-finish` use | ||
- name: Save persist key | ||
if: ${{ always() }} | ||
run: echo ${{ github.sha }} > ./visual-regression-ref.txt | ||
|
||
- name: Upload persist key | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: visual-regression-persist-ref | ||
path: ./visual-regression-ref.txt |
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
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
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
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
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
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
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
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
Oops, something went wrong.