From ceba0d5c2396eae42692423053f6d0aa95bd31d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Tue, 29 Mar 2022 20:46:37 +0800 Subject: [PATCH] chore: comiple use matrix (#34770) * chore: comiple use matrix * chore: 16 deps * chore: not install 16 * chore: update * chore: to 16 * chore: install 16 * chore: install 16 * chore: install 16 * chore: install 16 * chore: concurrent * chore: back all * chore: fix lines * chore: cancel if new comes * chore: single dist speed up * chore: fix * chore: fix * chore: update * fix: deps --- .github/workflows/compressed-size.yml | 5 + .github/workflows/preview-build.yml | 5 + .github/workflows/test.yml | 354 +++++++++----------------- .github/workflows/ui.yml | 5 + 4 files changed, 131 insertions(+), 238 deletions(-) diff --git a/.github/workflows/compressed-size.yml b/.github/workflows/compressed-size.yml index c3fa8b6767..04e8a356f9 100644 --- a/.github/workflows/compressed-size.yml +++ b/.github/workflows/compressed-size.yml @@ -4,6 +4,11 @@ on: pull_request: types: [opened, synchronize] +# Cancel prev CI if new commit come +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: compressed-size: runs-on: ubuntu-latest diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 542edd5fb5..b50497d7a1 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -6,6 +6,11 @@ on: pull_request: types: [opened, synchronize, reopened] +# Cancel prev CI if new commit come +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: # Prepare node modules. Reuse cache if available setup: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0c2d477a0d..9c8ae7f3b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,11 @@ name: ✅ test on: [push, pull_request] +# Cancel prev CI if new commit come +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: setup: runs-on: ubuntu-latest @@ -37,43 +42,6 @@ jobs: if: steps.node_modules_cache_id.outputs.cache-hit != 'true' run: npm ci - compile: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v3 - - - 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: cache lib - uses: actions/cache@v3 - with: - path: lib - key: lib-${{ github.sha }} - - - name: cache es - uses: actions/cache@v3 - with: - path: es - key: es-${{ github.sha }} - - - name: compile - run: npm run compile - - - name: check - run: node ./tests/dekko/lib.test.js - needs: setup - lint: runs-on: ubuntu-latest steps: @@ -140,8 +108,9 @@ jobs: run: node ./scripts/check-demo.js needs: setup - react-17-dom: - name: react@17.x / dom + ################################ Dist ################################ + dist: + name: dist runs-on: ubuntu-latest steps: - name: checkout @@ -159,38 +128,21 @@ jobs: path: node_modules key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} - - name: test - run: npm test -- -w 1 --coverage - - - name: coverage - run: bash <(curl -s https://codecov.io/bash) - needs: setup - - react-17-node: - name: react@17.x / node - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v3 - - - 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 + - name: cache dist uses: actions/cache@v3 with: - path: node_modules - key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} + path: dist + key: dist-${{ github.sha }} - - name: test - run: npm run test-node + - name: dist + run: npm run dist + env: + NODE_OPTIONS: --max_old_space_size=4096 needs: setup - react-17-lib: - name: react@17.x / lib + ############################### Style ################################ + style-compile: + name: es style compile runs-on: ubuntu-latest steps: - name: checkout @@ -214,45 +166,21 @@ jobs: path: lib key: lib-${{ github.sha }} - - name: test - run: npm test - env: - LIB_DIR: lib - needs: compile - - react-17-es: - name: react@17.x / es - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v3 - - - 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: restore cache from es uses: actions/cache@v3 with: path: es key: es-${{ github.sha }} - - name: test - run: npm test - env: - LIB_DIR: es + - name: lessc component + run: npx lessc --js ./es/button/style/index.less + + - name: lessc mixins + run: npx lessc --js ./es/style/mixins/index.less needs: compile - react-17-dist: - name: react@17.x / dist + style-dist: + name: dist style compile runs-on: ubuntu-latest steps: - name: checkout @@ -270,58 +198,44 @@ jobs: path: node_modules key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} - - name: dist - run: npm run dist - env: - NODE_OPTIONS: --max_old_space_size=4096 - - - name: check - run: node ./tests/dekko/dist.test.js - - - name: bundlesize - run: npm run bundlesize - env: - BUNDLESIZE_GITHUB_TOKEN: ${{ secrets.BUNDLESIZE_GITHUB_TOKEN }} - - - name: test - run: npm test - env: - LIB_DIR: dist - needs: setup - - react-16-dom: - name: react@16.x / dom - runs-on: ubuntu-latest - env: - REACT: 16 - steps: - - name: checkout - uses: actions/checkout@v3 + - name: restore cache from lib + uses: actions/cache@v3 + with: + path: lib + key: lib-${{ github.sha }} - - name: restore cache from package-lock.json + - name: restore cache from es uses: actions/cache@v3 with: - path: package-temp-dir - key: lock-${{ github.sha }} + path: es + key: es-${{ github.sha }} - - name: restore cache from node_modules + - name: restore cache from dist uses: actions/cache@v3 with: - path: node_modules - key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} + path: dist + key: dist-${{ github.sha }} - - name: install react 16 - run: npm run install-react-16 + - name: lessc default + run: npx lessc --js ./dist/antd.less - - name: test - run: npm test -- -w 1 --coverage - needs: setup + - name: lessc dark + run: npx lessc --js ./dist/antd.dark.less - react-16-node: - name: react@16.x / node - runs-on: ubuntu-latest + - name: lessc variable + run: npx lessc --js ./dist/antd.variable.less + needs: [compile, dist] + + ################################ Test ################################ + normal-test: + name: test + strategy: + matrix: + react: ['16', '17'] + module: ['dom', 'node', 'dist'] env: - REACT: 16 + REACT: ${{ matrix.react }} + runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@v3 @@ -339,53 +253,53 @@ jobs: 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: test - run: npm run test-node - needs: setup - - react-16-lib: - name: react@16.x / lib - runs-on: ubuntu-latest - env: - REACT: 16 - steps: - - name: checkout - uses: actions/checkout@v3 - - - name: restore cache from package-lock.json + - name: restore cache from dist + if: ${{ matrix.module == 'dist' }} uses: actions/cache@v3 with: - path: package-temp-dir - key: lock-${{ github.sha }} + path: dist + key: dist-${{ 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: check + if: ${{ matrix.module == 'dist' }} + run: node ./tests/dekko/dist.test.js - - name: restore cache from lib - uses: actions/cache@v3 - with: - path: lib - key: lib-${{ github.sha }} + # 17 only + - name: bundlesize + if: ${{ matrix.module == 'dist' && matrix.react == '17' }} + run: npm run bundlesize + env: + BUNDLESIZE_GITHUB_TOKEN: ${{ secrets.BUNDLESIZE_GITHUB_TOKEN }} - - name: install react 16 - run: npm run install-react-16 + # dom test + - name: dom test + if: ${{ matrix.module == 'dom' }} + run: npm test -- -w 1 --coverage - - name: test + # > 17 only + - name: coverage + if: ${{ matrix.module == 'dom' && matrix.react == '17' }} + run: bash <(curl -s https://codecov.io/bash) + + # 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: lib - needs: compile + LIB_DIR: dist + needs: [setup, dist] - react-16-es: - name: react@16.x / es + ########################### Compile & Test ########################### + compile: runs-on: ubuntu-latest - env: - REACT: 16 steps: - name: checkout uses: actions/checkout@v3 @@ -402,26 +316,34 @@ jobs: path: node_modules key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} - - name: restore cache from es + - name: cache lib + uses: actions/cache@v3 + with: + path: lib + key: lib-${{ github.sha }} + + - name: cache es uses: actions/cache@v3 with: path: es key: es-${{ github.sha }} - - name: install react 16 - run: npm run install-react-16 + - name: compile + run: npm run compile - - name: test - run: npm test - env: - LIB_DIR: es - needs: compile + - name: check + run: node ./tests/dekko/lib.test.js + needs: setup - react-16-dist: - name: react@16.x / dist + compiled-module-test: + name: module test runs-on: ubuntu-latest + strategy: + matrix: + react: ['16', '17'] + module: [lib, es] env: - REACT: 16 + REACT: ${{ matrix.react }} steps: - name: checkout uses: actions/checkout@v3 @@ -438,62 +360,18 @@ jobs: path: node_modules key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} + - name: restore cache from ${{ matrix.module }} + uses: actions/cache@v3 + with: + path: ${{ matrix.module }} + key: ${{ matrix.module }}-${{ github.sha }} + - name: install react 16 + if: ${{ matrix.react == '16' }} run: npm run install-react-16 - - name: dist - run: npm run dist - env: - NODE_OPTIONS: --max_old_space_size=4096 - - - name: check - run: node ./tests/dekko/dist.test.js - - name: test run: npm test env: - LIB_DIR: dist - needs: setup - - style: - name: style compile - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v3 - - - 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: compile - run: npm run compile - - - name: dist - run: npm run dist - env: - NODE_OPTIONS: --max_old_space_size=4096 - - - name: lessc default - run: npx lessc --js ./dist/antd.less - - - name: lessc dark - run: npx lessc --js ./dist/antd.dark.less - - - name: lessc variable - run: npx lessc --js ./dist/antd.variable.less - - - name: lessc component - run: npx lessc --js ./es/button/style/index.less - - - name: lessc mixins - run: npx lessc --js ./es/style/mixins/index.less - needs: setup + LIB_DIR: ${{ matrix.module }} + needs: compile \ No newline at end of file diff --git a/.github/workflows/ui.yml b/.github/workflows/ui.yml index be150568ec..5484c116a0 100644 --- a/.github/workflows/ui.yml +++ b/.github/workflows/ui.yml @@ -7,6 +7,11 @@ on: branches: - master +# Cancel prev CI if new commit come +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: test: runs-on: ubuntu-latest