From b270dc1296b5fda61b4d179a78f60c7ffd8d7b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Thu, 22 Sep 2022 09:04:40 +0800 Subject: [PATCH] ci: improve cache (#9860) --- .../workflows/lint-commit-message-post.yml | 3 ++ .github/workflows/lint-commit-message.yml | 19 +++++----- .github/workflows/pr-docs-build.yml | 24 ++++++++++-- .github/workflows/publish-build-product.yml | 20 +++++++--- .../workflows/publish-docs-deploy-manual.yml | 22 +++++++---- .github/workflows/publish-docs-deploy.yml | 20 +++++++--- .github/workflows/publish-npm-nightly.yml | 24 +++++++++--- .github/workflows/publish-npm.yml | 29 +++++++++++---- .github/workflows/publish-size-report.yml | 20 +++++++--- .github/workflows/staging-docs.yml | 20 +++++++--- .github/workflows/test-coverage.yml | 28 +++++++++----- .github/workflows/test-ssr.yml | 14 ++++++- .github/workflows/test-unit.yml | 37 ++++++++++++++++--- 13 files changed, 209 insertions(+), 71 deletions(-) diff --git a/.github/workflows/lint-commit-message-post.yml b/.github/workflows/lint-commit-message-post.yml index 3050abd6fb..940010816f 100644 --- a/.github/workflows/lint-commit-message-post.yml +++ b/.github/workflows/lint-commit-message-post.yml @@ -8,9 +8,11 @@ on: jobs: result: runs-on: ubuntu-latest + outputs: succeeded: ${{ steps.assert.outputs.succeeded }} pr: ${{ steps.pr.outputs.pr }} + steps: - name: Download result uses: dawidd6/action-download-artifact@v2 @@ -18,6 +20,7 @@ jobs: workflow: ${{ github.event.workflow.id }} run_id: ${{ github.event.workflow_run.id }} name: commit-lint-result + - name: Derive PR number uses: dawidd6/action-download-artifact@v2 with: diff --git a/.github/workflows/lint-commit-message.yml b/.github/workflows/lint-commit-message.yml index 138b0a2f5b..f110c7f359 100644 --- a/.github/workflows/lint-commit-message.yml +++ b/.github/workflows/lint-commit-message.yml @@ -24,17 +24,18 @@ jobs: with: node-version: 16 - - name: Cache ~/.pnpm-store - uses: actions/cache@v3 - env: - cache-name: cache-pnpm-store + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache with: - path: ~/.pnpm-store - key: ${{ runner.os }}-${{ matrix.node-version }}-test-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-${{ matrix.node-version }}-test-${{ env.cache-name }}- - ${{ runner.os }}-${{ matrix.node-version }}-test- - ${{ runner.os }}- + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile diff --git a/.github/workflows/pr-docs-build.yml b/.github/workflows/pr-docs-build.yml index 91f8c2e55e..cbe97ee31b 100644 --- a/.github/workflows/pr-docs-build.yml +++ b/.github/workflows/pr-docs-build.yml @@ -8,13 +8,19 @@ concurrency: jobs: build: - name: Build + name: Build ${{ matrix.os }} ${{ matrix.node-name }} runs-on: ${{ matrix.os }} strategy: matrix: - node-version: [16.x] + node-version: [16, 18] os: [ubuntu-latest, windows-latest] + include: + - node-version: 16 + node-name: LTS + - node-version: 18 + node-name: Current + fail-fast: false env: @@ -31,7 +37,19 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - cache: 'pnpm' + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile diff --git a/.github/workflows/publish-build-product.yml b/.github/workflows/publish-build-product.yml index 0194c84af0..cb2b85e25b 100644 --- a/.github/workflows/publish-build-product.yml +++ b/.github/workflows/publish-build-product.yml @@ -10,10 +10,6 @@ jobs: name: Build Product Check runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16.x] - steps: - uses: actions/checkout@v3 with: @@ -29,8 +25,20 @@ jobs: - name: Setup node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' + node-version: 16 + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile diff --git a/.github/workflows/publish-docs-deploy-manual.yml b/.github/workflows/publish-docs-deploy-manual.yml index 5d1c22a6f6..adb86beb88 100644 --- a/.github/workflows/publish-docs-deploy-manual.yml +++ b/.github/workflows/publish-docs-deploy-manual.yml @@ -6,10 +6,6 @@ jobs: deploy-docs: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16.x] - steps: - name: Checkout uses: actions/checkout@v3 @@ -20,8 +16,20 @@ jobs: - name: Setup node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' + node-version: 16 + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile @@ -32,7 +40,7 @@ jobs: CROWDIN_TOKEN: ${{secrets.CROWDIN_TOKEN}} - name: Pull Crowdin translations - run: cd docs && pnpm exec crowdin download -l es-ES && pnpm exec crowdin download -l zh-CN + run: cd docs && pnpm exec crowdin download -l zh-CN && pnpm exec crowdin download -l es-ES - name: Generate common locale run: pnpm docs:gen-locale diff --git a/.github/workflows/publish-docs-deploy.yml b/.github/workflows/publish-docs-deploy.yml index 3a7e8614a5..bd5ff32478 100644 --- a/.github/workflows/publish-docs-deploy.yml +++ b/.github/workflows/publish-docs-deploy.yml @@ -10,10 +10,6 @@ jobs: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} - strategy: - matrix: - node-version: [16.x] - steps: - name: Checkout uses: actions/checkout@v3 @@ -27,8 +23,20 @@ jobs: - name: Setup node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' + node-version: 16 + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile diff --git a/.github/workflows/publish-npm-nightly.yml b/.github/workflows/publish-npm-nightly.yml index 00680cf04e..ceb7335815 100644 --- a/.github/workflows/publish-npm-nightly.yml +++ b/.github/workflows/publish-npm-nightly.yml @@ -11,10 +11,6 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'element-plus' }} - strategy: - matrix: - node-version: [16.x] - steps: - uses: actions/checkout@v3 with: @@ -26,13 +22,27 @@ jobs: - name: Setup node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' + node-version: 16 + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile + - name: Lint run: pnpm lint + - name: Test run: pnpm test @@ -42,10 +52,12 @@ jobs: if: ${{ github.repository_owner == 'element-plus' }} steps: - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: '16' registry-url: https://registry.npmjs.com/ + - name: Setup pnpm uses: pnpm/action-setup@v2 diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 4bc320f3ec..4d2200904f 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -8,10 +8,6 @@ jobs: test: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16.x] - steps: - uses: actions/checkout@v3 with: @@ -25,14 +21,28 @@ jobs: - name: Setup node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} + node-version: 16 registry-url: https://registry.npmjs.com/ - cache: 'pnpm' + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile + - name: Lint run: pnpm lint + - name: Test run: pnpm test @@ -41,19 +51,24 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: - node-version: '16' + node-version: 16 registry-url: https://registry.npmjs.com/ + - name: Setup pnpm uses: pnpm/action-setup@v2 - name: Get version run: echo "TAG_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Get git head run: echo "GIT_HEAD=${GITHUB_SHA}" >> $GITHUB_ENV + - name: Gen npmrc run: echo "//registry.npmjs.com/:_authToken=${{ secrets.NPM_PUBLISH_TOKEN }}" >> ./.npmrc + - name: Build&publish run: sh ./scripts/publish.sh env: diff --git a/.github/workflows/publish-size-report.yml b/.github/workflows/publish-size-report.yml index 86ef49767f..31c1658606 100644 --- a/.github/workflows/publish-size-report.yml +++ b/.github/workflows/publish-size-report.yml @@ -10,10 +10,6 @@ jobs: size-report: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16.x] - env: CI_JOB_NUMBER: 1 @@ -26,8 +22,20 @@ jobs: - name: Setup node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' + node-version: 16 + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - uses: preactjs/compressed-size-action@v2 with: diff --git a/.github/workflows/staging-docs.yml b/.github/workflows/staging-docs.yml index 5f050a6965..89d803c298 100644 --- a/.github/workflows/staging-docs.yml +++ b/.github/workflows/staging-docs.yml @@ -15,10 +15,6 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'element-plus' }} - strategy: - matrix: - node-version: [16.x] - steps: - name: Checkout uses: actions/checkout@v3 @@ -29,8 +25,20 @@ jobs: - name: Setup node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' + node-version: 16 + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index 0b58cf847e..9b9fd7aa44 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -9,31 +9,41 @@ on: jobs: build: - name: Coverage (${{ matrix.node-name }}) + name: Coverage runs-on: ubuntu-latest - strategy: - matrix: - node-version: ['16'] - include: - - node-version: '16' - node-name: 'Latest' + steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Add dev branch run: git branch dev origin/dev + - name: Setup pnpm uses: pnpm/action-setup@v2 - name: Setup node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' + node-version: 16 + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile + - uses: ArtiomTr/jest-coverage-report-action@v2.0-rc.6 with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-ssr.yml b/.github/workflows/test-ssr.yml index c0b61dc150..c56e9b8ec1 100644 --- a/.github/workflows/test-ssr.yml +++ b/.github/workflows/test-ssr.yml @@ -24,7 +24,19 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 - cache: 'pnpm' + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index a75363efa2..10a25af13b 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -26,7 +26,19 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 - cache: 'pnpm' + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile @@ -40,12 +52,15 @@ jobs: build: name: Unit Test (${{ matrix.node-name }}) runs-on: ubuntu-latest + strategy: matrix: - node-version: ['16'] + node-version: [16] include: - - node-version: '16' - node-name: 'Latest' + - node-version: 16 + node-name: LTS + # - node-version: 18 + # node-name: Current steps: - uses: actions/checkout@v3 @@ -57,7 +72,19 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - cache: 'pnpm' + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm i --frozen-lockfile