mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 19:42:54 +08:00
test: speed up test workflow (#50346)
* 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>
This commit is contained in:
parent
d6be2b22af
commit
0c97a6fa43
2
.github/workflows/mock-project-build.yml
vendored
2
.github/workflows/mock-project-build.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
node-version: 20
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
|
2
.github/workflows/site-deploy.yml
vendored
2
.github/workflows/site-deploy.yml
vendored
@ -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
|
||||
|
256
.github/workflows/test.yml
vendored
256
.github/workflows/test.yml
vendored
@ -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
|
||||
@ -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
|
||||
@ -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:
|
||||
@ -90,39 +92,7 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: restore cache from package-lock.json
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: package-temp-dir
|
||||
key: lock-${{ github.sha }}
|
||||
|
||||
- name: restore cache from node_modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
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 }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
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
|
||||
@ -144,53 +114,101 @@ jobs:
|
||||
if: ${{ matrix.react == '17' }}
|
||||
run: npm run install-react-17
|
||||
|
||||
- name: restore cache from dist
|
||||
if: ${{ matrix.module == 'dist' }}
|
||||
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
|
||||
env:
|
||||
LIB_DIR: dist
|
||||
|
||||
# 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
|
||||
|
||||
normal-test-latest:
|
||||
name: test-latest
|
||||
strategy:
|
||||
matrix:
|
||||
react: ['18']
|
||||
module: ['dom', 'node', 'dist', 'dist-min']
|
||||
shard: ['1/2', '2/2']
|
||||
env:
|
||||
REACT: ${{ matrix.react }}
|
||||
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
|
||||
with:
|
||||
path: package-temp-dir
|
||||
key: lock-${{ github.sha }}
|
||||
|
||||
- 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: install react 18
|
||||
run: npm run install-react-18
|
||||
|
||||
- name: node test
|
||||
run: npm run test:node
|
||||
|
||||
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: package-temp-dir
|
||||
key: lock-${{ github.sha }}
|
||||
|
||||
- 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: install react 18
|
||||
run: npm run install-react-18
|
||||
|
||||
# dom test
|
||||
- name: dom test
|
||||
run: npm test -- --maxWorkers=2 --shard=${{matrix.shard}} --coverage
|
||||
|
||||
- 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/
|
||||
|
||||
test-react-latest-dist:
|
||||
name: test-react-latest-dist
|
||||
strategy:
|
||||
matrix:
|
||||
module: ['dist', 'dist-min']
|
||||
shard: ['1/2', '2/2']
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
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
|
||||
@ -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
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
- name: dist test
|
||||
if: ${{ matrix.module == 'dist' }}
|
||||
run: npm test
|
||||
env:
|
||||
LIB_DIR: dist
|
||||
|
||||
############################ 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:
|
||||
@ -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
|
||||
@ -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:
|
||||
@ -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'
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
|
2
.github/workflows/upgrade-deps.yml
vendored
2
.github/workflows/upgrade-deps.yml
vendored
@ -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
|
||||
|
@ -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
|
||||
@ -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
|
||||
|
@ -60,9 +60,9 @@ if ! has_arg '--skip-dekko' "$@"; then
|
||||
echo "[TEST ALL] dekko dist" > ~test-all.txt
|
||||
node ./tests/dekko/dist.test.js
|
||||
|
||||
echo "[TEST ALL] dekko lib"
|
||||
echo "[TEST ALL] dekko lib" > ~test-all.txt
|
||||
node ./tests/dekko/lib.test.js
|
||||
echo "[TEST ALL] dekko lib and es"
|
||||
echo "[TEST ALL] dekko lib and es" > ~test-all.txt
|
||||
node ./tests/dekko/lib-es.test.js
|
||||
else
|
||||
echo "[TEST ALL] dekko test...skip"
|
||||
fi
|
||||
|
@ -1,3 +1,3 @@
|
||||
require('./dist.test');
|
||||
require('./lib.test');
|
||||
require('./lib-es.test');
|
||||
require('./use-client.test');
|
||||
|
26
tests/dekko/lib-es.test.js
Normal file
26
tests/dekko/lib-es.test.js
Normal file
@ -0,0 +1,26 @@
|
||||
const $ = require('dekko');
|
||||
const chalk = require('chalk');
|
||||
|
||||
$('lib').isDirectory().hasFile('index.js').hasFile('index.d.ts');
|
||||
|
||||
$('lib/*')
|
||||
.filter((filename) => !['index.js', 'index.d.ts', '.map'].some((ext) => filename.endsWith(ext)))
|
||||
.isDirectory()
|
||||
.filter((filename) => !['style', '_util', 'locale'].some((ext) => filename.endsWith(ext)))
|
||||
.hasFile('index.js')
|
||||
.hasFile('index.d.ts');
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(chalk.green('✨ `lib` directory is valid.'));
|
||||
|
||||
$('es').isDirectory().hasFile('index.js').hasFile('index.d.ts');
|
||||
|
||||
$('es/*')
|
||||
.filter((filename) => !['index.js', 'index.d.ts', '.map'].some((ext) => filename.endsWith(ext)))
|
||||
.isDirectory()
|
||||
.filter((filename) => !['style', '_util', 'locale'].some((ext) => filename.endsWith(ext)))
|
||||
.hasFile('index.js')
|
||||
.hasFile('index.d.ts');
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(chalk.green('✨ `es` directory is valid.'));
|
@ -1,22 +0,0 @@
|
||||
const $ = require('dekko');
|
||||
const chalk = require('chalk');
|
||||
|
||||
$('lib').isDirectory().hasFile('index.js').hasFile('index.d.ts');
|
||||
|
||||
$('lib/*')
|
||||
.filter(
|
||||
(filename) =>
|
||||
!filename.endsWith('index.js') &&
|
||||
!filename.endsWith('index.d.ts') &&
|
||||
!filename.endsWith('.map'),
|
||||
)
|
||||
.isDirectory()
|
||||
.filter(
|
||||
(filename) =>
|
||||
!filename.endsWith('style') && !filename.endsWith('_util') && !filename.endsWith('locale'),
|
||||
)
|
||||
.hasFile('index.js')
|
||||
.hasFile('index.d.ts');
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(chalk.green('✨ `lib` directory is valid.'));
|
@ -5,29 +5,25 @@ const fs = require('fs');
|
||||
const includeUseClient = (filename) =>
|
||||
fs.readFileSync(filename).toString().includes('"use client"');
|
||||
|
||||
if (process.env.LIB_DIR === 'dist') {
|
||||
$('dist/*')
|
||||
.isFile()
|
||||
.assert("doesn't contain use client", (filename) => !includeUseClient(filename));
|
||||
} else {
|
||||
$('{es,lib}/index.js')
|
||||
.isFile()
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
$('dist/*')
|
||||
.isFile()
|
||||
.assert("doesn't contain use client", (filename) => !includeUseClient(filename));
|
||||
$('{es,lib}/index.js')
|
||||
.isFile()
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
$('{es,lib}/*/index.js')
|
||||
.isFile()
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
|
||||
$('{es,lib}/*/index.js')
|
||||
.isFile()
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
// check tsx files
|
||||
$('{es,lib}/typography/*.js')
|
||||
.isFile()
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
|
||||
// check tsx files
|
||||
$('{es,lib}/typography/*.js')
|
||||
.isFile()
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
|
||||
$('{es,lib}/typography/Base/*.js')
|
||||
.isFile()
|
||||
.filter((filename) => !filename.endsWith('/util.js'))
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
}
|
||||
$('{es,lib}/typography/Base/*.js')
|
||||
.isFile()
|
||||
.filter((filename) => !filename.endsWith('/util.js'))
|
||||
.assert('contain use client', (filename) => includeUseClient(filename));
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(chalk.green('✨ use client passed!'));
|
||||
|
Loading…
Reference in New Issue
Block a user