Skip to content

Commit

Permalink
test: speed up test workflow (ant-design#50346)
Browse files Browse the repository at this point in the history
* test: faster test.yml

* test: upgrade to node 20

* fix depends

* fix needs

* fix needs

* fix needs

* fix needs

* test: update test.yml

* test: update test.yml

* test: update test.yml

* test: update test.yml

* test: update test.yml

* test: update test.yml

* test: update test.yml

* test: update test.yml

* test: update test.yml

* fix: lib es test

* fix: lib es test

* fix: lib es test

* skip dist test in react lagacy

* Update test.yml

Signed-off-by: afc163 <afc163@gmail.com>

---------

Signed-off-by: afc163 <afc163@gmail.com>
  • Loading branch information
afc163 authored and linxianxi committed Aug 14, 2024
1 parent 15448a3 commit 19a3087
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 164 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mock-project-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- uses: actions/cache@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/site-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: restore cache from package-lock.json
uses: actions/cache@v4
Expand Down
204 changes: 92 additions & 112 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: cache package-lock.json
uses: actions/cache@v4
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: restore cache from package-lock.json
uses: actions/cache@v4
Expand All @@ -75,13 +75,15 @@ jobs:
- name: lint
run: npm run lint

- name: lint:react-16
run: npm run compile && npm run install-react-16 && npm run tsc:old

- name: lint:react-17
run: npm run compile && npm run install-react-17 && npm run tsc:old

check_metadata:
################################ Test ################################
test-react-legacy:
name: test-react-legacy
strategy:
matrix:
react: ['16', '17']
shard: ['1/2', '2/2']
env:
REACT: ${{ matrix.react }}
runs-on: ubuntu-latest
needs: setup
steps:
Expand All @@ -90,7 +92,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: restore cache from package-lock.json
uses: actions/cache@v4
Expand All @@ -104,25 +106,29 @@ jobs:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

################################ Test ################################
normal-test-legacy:
name: test-legacy
strategy:
matrix:
react: ['16', '17']
module: ['dom', 'dist']
shard: ['1/2', '2/2']
env:
REACT: ${{ matrix.react }}
- name: install react 16
if: ${{ matrix.react == '16' }}
run: npm run install-react-16

- name: install react 17
if: ${{ matrix.react == '17' }}
run: npm run install-react-17

# dom test
- name: dom test
run: npm test -- --maxWorkers=2 --shard=${{matrix.shard}} --coverage

test-node:
name: test-node
runs-on: ubuntu-latest
needs: build
needs: setup
steps:
- name: checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: restore cache from package-lock.json
uses: actions/cache@v4
Expand All @@ -136,52 +142,64 @@ jobs:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: install react 16
if: ${{ matrix.react == '16' }}
run: npm run install-react-16
- name: install react 18
run: npm run install-react-18

- name: install react 17
if: ${{ matrix.react == '17' }}
run: npm run install-react-17
- name: node test
run: npm run test:node

- name: restore cache from dist
if: ${{ matrix.module == 'dist' }}
test-react-latest:
name: test-react-latest
strategy:
matrix:
module: ['dom']
shard: ['1/2', '2/2']
runs-on: ubuntu-latest
needs: setup
steps:
- name: checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20

- name: restore cache from package-lock.json
uses: actions/cache@v4
with:
path: dist
key: dist-${{ github.sha }}
path: package-temp-dir
key: lock-${{ github.sha }}

- name: check
if: ${{ matrix.module == 'dist' }}
run: node ./tests/dekko/dist.test.js
- name: restore cache from node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: check use client
if: ${{ matrix.module == 'dist' }}
run: node ./tests/dekko/use-client.test.js
env:
LIB_DIR: dist
- name: install react 18
run: npm run install-react-18

# dom test
- name: dom test
if: ${{ matrix.module == 'dom' }}
run: npm test -- --maxWorkers=2 --shard=${{matrix.shard}} --coverage

# dist test
- name: dist test
if: ${{ matrix.module == 'dist' }}
run: npm test
env:
LIB_DIR: dist
- name: persist coverages
run: |
mkdir persist-coverage
mv coverage/coverage-final.json persist-coverage/react-test-${{matrix.module}}-${{strategy.job-index}}.json
- uses: actions/upload-artifact@v4
name: upload coverages
with:
name: coverage-artifacts-${{ matrix.module }}-${{ strategy.job-index }}
path: persist-coverage/

normal-test-latest:
name: test-latest
test-react-latest-dist:
name: test-react-latest-dist
strategy:
matrix:
react: ['18']
module: ['dom', 'node', 'dist', 'dist-min']
module: ['dist', 'dist-min']
shard: ['1/2', '2/2']
env:
REACT: ${{ matrix.react }}
runs-on: ubuntu-latest
needs: build
steps:
Expand All @@ -190,7 +208,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: restore cache from package-lock.json
uses: actions/cache@v4
Expand All @@ -205,74 +223,37 @@ jobs:
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: install react 18
if: ${{ matrix.react == '18' }}
run: npm run install-react-18

- name: restore cache from dist
if: ${{ matrix.module == 'dist' || matrix.module == 'dist-min' }}
uses: actions/cache@v4
with:
path: dist
key: dist-${{ github.sha }}

- name: check
if: ${{ matrix.module == 'dist' }}
run: node ./tests/dekko/dist.test.js

- name: check use client
if: ${{ matrix.module == 'dist' }}
run: node ./tests/dekko/use-client.test.js
- name: dist-min test
if: ${{ matrix.module == 'dist-min' }}
run: npm test
env:
LIB_DIR: dist

# dom test
- name: dom test
if: ${{ matrix.module == 'dom' }}
run: npm test -- --maxWorkers=2 --shard=${{matrix.shard}} --coverage

- name: persist coverages
if: ${{ matrix.module == 'dom' && matrix.react == '18' }}
run: |
mkdir persist-coverage
mv coverage/coverage-final.json persist-coverage/react-${{matrix.react}}-test-${{matrix.module}}-${{strategy.job-index}}.json
- uses: actions/upload-artifact@v4
if: ${{ matrix.module == 'dom' && matrix.react == '18' }}
name: upload coverages
with:
name: coverage-artifacts-${{ matrix.module }}-${{ matrix.react }}-${{ strategy.job-index }}
path: persist-coverage/

# node test
- name: node test
if: ${{ matrix.module == 'node' }}
run: npm run test:node
LIB_DIR: dist-min

# dist test
- name: dist test
if: ${{ matrix.module == 'dist' }}
run: npm test
env:
LIB_DIR: dist

# dist min test
- name: dist-min test
if: ${{ matrix.module == 'dist-min' }}
run: npm test
env:
LIB_DIR: dist-min

############################ Test Coverage ###########################
upload-test-coverage:
name: test-coverage
runs-on: ubuntu-latest
needs: normal-test-latest
needs: test-react-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -300,7 +281,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: restore cache from package-lock.json
uses: actions/cache@v4
Expand Down Expand Up @@ -329,12 +310,6 @@ jobs:
- name: compile
run: npm run compile

- name: check
run: node ./tests/dekko/lib.test.js

- name: check use client
run: node ./tests/dekko/use-client.test.js

- name: cache dist
uses: actions/cache@v4
with:
Expand All @@ -347,6 +322,9 @@ jobs:
NODE_OPTIONS: "--max_old_space_size=4096"
CI: 1

- name: check build files
run: node ./tests/dekko/index.test.js

# Artifact build files
- uses: actions/upload-artifact@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
Expand All @@ -369,17 +347,14 @@ jobs:
echo "🤖 Uploading"
node scripts/visual-regression/upload.js ./oss-artifacts.zip --ref=$HEAD_SHA
compiled-module-test:
name: module test
test-lib-es:
name: test lib/es module
runs-on: ubuntu-latest
needs: build
needs: setup
strategy:
matrix:
react: ['18']
module: [lib, es]
shard: ['1/2', '2/2']
env:
REACT: ${{ matrix.react }}
steps:
- name: checkout
# lib only run in master branch not in pull request
Expand All @@ -388,7 +363,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: restore cache from package-lock.json
# lib only run in master branch not in pull request
Expand All @@ -414,8 +389,13 @@ jobs:
path: ${{ matrix.module }}
key: ${{ matrix.module }}-${{ github.sha }}

- name: compile
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
run: npm run compile

- name: install react 18
if: ${{ matrix.react == '18' && (github.event_name != 'pull_request' || matrix.module != 'lib') }}
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
run: npm run install-react-18

- name: test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: upgrade deps
id: upgrade
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/visual-regression-diff-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: restore cache from package-lock.json
uses: actions/cache@v4
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: restore cache from package-lock.json
uses: actions/cache@v4
Expand Down
Loading

0 comments on commit 19a3087

Please sign in to comment.