Browse Source

test: move argos-ci from github action to circleci (#38091)

* Add .circleci/config.yml (#1)

* Add .circleci/config.yml

* Update config.yml

* Update config.yml

* Update config.yml

* Update config.yml

* Update config.yml

* Update config.yml

* Update config.yml

* Update config.yml

* Update config.yml

* Update config.yml

* Update package.json

* Update config.yml

* Update argos-upload.js

* test: replace github action to circleci
pull/38095/head
afc163 2 years ago
committed by GitHub
parent
commit
3359f535fe
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 38
      .circleci/config.yml
  2. 69
      .github/workflows/ui-upload.yml
  3. 93
      .github/workflows/ui.yml
  4. 6
      Dockerfile.ui-test
  5. 17
      docker-compose.yml
  6. 3
      package.json
  7. 2
      scripts/argos-upload.js

38
.circleci/config.yml

@ -0,0 +1,38 @@
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
test-argos-ci:
docker:
- image: circleci/node:16-browsers
steps:
- checkout
- run:
name: Install node_modules
command: npm i
- run:
name: Install argos cli
command: npm i fast-glob lodash @argos-ci/core
- run:
name: Install puppeteer
command: node node_modules/puppeteer/install.js
- run:
name: Build dist file
command: npm run dist
- run:
name: Run image screenshot tests
command: npm run test-image
- run:
name: Upload screenshots to Argos CI
command: npm run argos
# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
test-argos-ci-workflow:
jobs:
- test-argos-ci

69
.github/workflows/ui-upload.yml

@ -1,69 +0,0 @@
# Upload 📷 UI snapshots to argos server, help visual regression testing.
name: 📷 UI Upload
on:
workflow_run:
workflows: ["📷 UI"]
types:
- completed
permissions:
contents: read
jobs:
wait:
runs-on: ubuntu-latest
steps:
- name: Wait
run: sleep 60
upload-ui:
permissions:
actions: read # for dawidd6/action-download-artifact to query and download artifacts
pull-requests: read # for dawidd6/action-download-artifact to query commit hash
name: deploy preview
runs-on: ubuntu-latest
needs: wait
if: >
github.repository == 'ant-design/ant-design' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: checkout
uses: actions/checkout@v3
- name: Download commit artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: commit
- name: Save commit id
id: commit
run: echo "::set-output name=id::$(<commit.txt)"
- name: Download branch artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: branch
- name: Save branch id
id: branch
run: echo "::set-output name=id::$(<branch.txt)"
- name: Download snapshots artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success
name: snapshots
path: imageSnapshots
- name: Install
run: npm i fast-glob lodash @argos-ci/core
- name: Upload on Argos
id: deploy
run: npm run argos
env:
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
ARGOS_PARALLEL_NONCE: ${{ github.run_id }}

93
.github/workflows/ui.yml

@ -1,93 +0,0 @@
name: 📷 UI
on:
pull_request:
types: [opened, synchronize, reopened]
push:
# Cancel prev CI if new commit come
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
imagesnapshot:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: cache package-lock.json
uses: actions/cache@v3
with:
path: package-temp-dir
key: lock-${{ github.sha }}
- uses: actions/setup-node@v3
with:
node-version: '16'
- 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
- name: test
run: npm run test-image
- name: upload snapshots artifact
uses: actions/upload-artifact@v3
with:
name: snapshots
path: imageSnapshots/
retention-days: 3
- name: Save commit
if: github.event_name == 'pull_request' && github.base_ref == 'master'
run: echo ${{ github.event.pull_request.head.sha }} > ./commit.txt
- name: Save commit
if: github.event_name == 'push'
run: echo ${{ github.sha }} > ./commit.txt
- name: Upload commit
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: commit
path: ./commit.txt
- name: Save branch
if: github.event_name == 'pull_request' && github.base_ref == 'master'
run: echo pull/${{ github.event.pull_request.number }}/merge > ./branch.txt
- name: Save branch
if: github.event_name == 'push'
run: echo ${GITHUB_REF##*/} > ./branch.txt
- name: Upload branch
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: branch
path: ./branch.txt

6
Dockerfile.ui-test

@ -1,6 +0,0 @@
FROM buildkite/puppeteer:10.0.0
RUN mkdir /app
WORKDIR /app
COPY package.json ./
ENV PATH="${PATH}:/app/node_modules/.bin"
COPY . .

17
docker-compose.yml

@ -1,17 +0,0 @@
version: '3'
services:
tests:
build:
context: .
dockerfile: Dockerfile.ui-test
volumes:
- './node_modules:/app/node_modules'
- './components:/app/components'
- './tests:/app/tests'
- './jest-stare:/app/jest-stare'
- './dist:/app/dist'
- '.jest.image.js:/app/.jest.image.js'
- './jest-puppeteer.config.js:/app/jest-puppeteer.config.js'
- './imageSnapshots:/app/imageSnapshots'
- './imageDiffSnapshots:/app/imageDiffSnapshots'
entrypoint: "npm run test-image:docker"

3
package.json

@ -98,8 +98,7 @@
"test-node": "jest --config .jest.node.js --cache=false",
"tsc": "tsc --noEmit",
"site:test": "jest --config .jest.site.js --cache=false --force-exit",
"test-image": "npm run dist && docker-compose run tests",
"test-image:docker": "node node_modules/puppeteer/install.js && jest --config .jest.image.js --no-cache -i",
"test-image": "npm run dist && jest --config .jest.image.js --no-cache -i -u",
"argos": "node ./scripts/argos-upload.js",
"version": "node ./scripts/generate-version",
"install-react-16": "npm i --no-save --legacy-peer-deps react@16 react-dom@16",

2
scripts/argos-upload.js

@ -47,7 +47,7 @@ async function run() {
token: process.env.ARGOS_TOKEN,
parallel: {
total: chunks.length,
nonce: process.env.ARGOS_PARALLEL_NONCE,
nonce: process.env.ARGOS_PARALLEL_NONCE || process.env.CIRCLE_BUILD_NUM,
},
});
// eslint-disable-next-line no-console -- pipe stdout

Loading…
Cancel
Save