From 41346e0abf21b3dc29cb46bc29779ae68d055fab Mon Sep 17 00:00:00 2001 From: Oscar Dominguez Date: Sat, 30 Oct 2021 09:27:06 +0200 Subject: [PATCH] chore(workflow): add cache to workflows using actions/setup-node (#5697) * ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows * Use cache: yarn * Reformat Co-authored-by: Joshua Chen --- .github/workflows/canary-release.yml | 3 +- .github/workflows/codeql-analysis.yml | 38 +++++++++------------- .github/workflows/lint.yml | 8 ++--- .github/workflows/v2-build-blog-only.yml | 9 +++-- .github/workflows/v2-build-size-report.yml | 8 +++-- .github/workflows/v2-build-time-perf.yml | 8 ++--- .github/workflows/v2-lighthouse-report.yml | 2 +- .github/workflows/v2-tests-e2e.yml | 12 +++---- .github/workflows/v2-tests-windows.yml | 1 + .github/workflows/v2-tests.yml | 5 ++- 10 files changed, 44 insertions(+), 50 deletions(-) diff --git a/.github/workflows/canary-release.yml b/.github/workflows/canary-release.yml index af4effae3cb5..6572faadb85f 100644 --- a/.github/workflows/canary-release.yml +++ b/.github/workflows/canary-release.yml @@ -5,7 +5,7 @@ on: branches: - main paths: - - 'packages/**' + - packages/** jobs: publish-canary: @@ -21,6 +21,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} + cache: yarn - name: Prepare git run: | git config --global user.name "Docusaurus Canary" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e358e6d894a5..bcaf22bfb38b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,13 +1,14 @@ -name: "CodeQL" +name: CodeQL on: push: - branches: [ main ] + branches: + - main pull_request: - # The branches below must be a subset of the branches above - branches: [ main ] + branches: + - main schedule: - - cron: '25 22 * * 3' + - cron: 25 22 * * 3 jobs: analyze: @@ -21,24 +22,17 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more: - # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + language: + - javascript steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v2 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d5acf35b3e4a..8da4c7ebd436 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,11 +12,11 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 - - name: Installation - uses: bahmutov/npm-install@v1 with: - install-command: yarn install - # install-command: yarn install --immutable # Fails if yarn.lock is modified (unfortunately only works for Yarn 2, and --frozen-lockfile is not the same!) + cache: yarn + - name: Installation + run: yarn + # run: yarn install --immutable # Fails if yarn.lock is modified (unfortunately only works for Yarn 2, and --frozen-lockfile is not the same!) - name: Check immutable yarn.lock run: git diff --exit-code - name: Lint diff --git a/.github/workflows/v2-build-blog-only.yml b/.github/workflows/v2-build-blog-only.yml index 0ef3569e27c7..88edfdc3b19d 100644 --- a/.github/workflows/v2-build-blog-only.yml +++ b/.github/workflows/v2-build-blog-only.yml @@ -5,8 +5,7 @@ on: branches: - main paths: - - 'website-1.x/blog/**' - - 'packages/docusaurus/**' + - packages/docusaurus/** jobs: build: @@ -15,9 +14,9 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 - - name: Installation - uses: bahmutov/npm-install@v1 with: - install-command: yarn + cache: yarn + - name: Installation + run: yarn - name: Build blog-only run: yarn workspace website build:blogOnly diff --git a/.github/workflows/v2-build-size-report.yml b/.github/workflows/v2-build-size-report.yml index db30f8d925b9..5f89eb6ce999 100644 --- a/.github/workflows/v2-build-size-report.yml +++ b/.github/workflows/v2-build-size-report.yml @@ -17,11 +17,13 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 + with: + cache: yarn - uses: preactjs/compressed-size-action@v2 with: - repo-token: '${{ secrets.GITHUB_TOKEN }}' - build-script: 'build:website:en' + repo-token: ${{ secrets.GITHUB_TOKEN }} + build-script: build:website:en pattern: '{website/build/assets/js/main*js,website/build/assets/css/styles*css,website/.docusaurus/globalData.json,website/build/index.html,website/build/blog/index.html,website/build/blog/**/introducing-docusaurus/*,website/build/docs/index.html,website/build/docs/installation/index.html,website/build/tests/docs/index.html,website/build/tests/docs/standalone/index.html}' strip-hash: '\.([^;]\w{7})\.' minimum-change-threshold: 30 - compression: 'none' + compression: none diff --git a/.github/workflows/v2-build-time-perf.yml b/.github/workflows/v2-build-time-perf.yml index 227c3b7232a5..924c3bfef174 100644 --- a/.github/workflows/v2-build-time-perf.yml +++ b/.github/workflows/v2-build-time-perf.yml @@ -5,7 +5,7 @@ on: branches: - main paths-ignore: - - 'website/docs/**' + - website/docs/** jobs: build: @@ -14,10 +14,10 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 - - name: Installation - uses: bahmutov/npm-install@v1 with: - install-command: yarn + cache: yarn + - name: Installation + run: yarn # Ensure build with a cold cache does not increase too much - name: Build (cold cache) diff --git a/.github/workflows/v2-lighthouse-report.yml b/.github/workflows/v2-lighthouse-report.yml index 6714047231f9..f2d2cac98409 100644 --- a/.github/workflows/v2-lighthouse-report.yml +++ b/.github/workflows/v2-lighthouse-report.yml @@ -14,7 +14,7 @@ jobs: uses: jakepartusch/wait-for-netlify-action@v1 id: netlify with: - site_name: 'docusaurus-2' + site_name: docusaurus-2 max_timeout: 600 - name: Audit URLs using Lighthouse id: lighthouse_audit diff --git a/.github/workflows/v2-tests-e2e.yml b/.github/workflows/v2-tests-e2e.yml index 0db28c4c7b12..20b549085915 100644 --- a/.github/workflows/v2-tests-e2e.yml +++ b/.github/workflows/v2-tests-e2e.yml @@ -21,10 +21,9 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} + cache: yarn - name: Installation - uses: bahmutov/npm-install@v1 - with: - install-command: yarn + run: yarn - name: Generate test-website project against main branch run: | KEEP_CONTAINER=true yarn test:build:website -s @@ -50,17 +49,16 @@ jobs: strategy: matrix: node: ['14'] - nodeLinker: ['pnp', 'node-modules'] + nodeLinker: [pnp, node-modules] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} + cache: yarn - name: Installation - uses: bahmutov/npm-install@v1 - with: - install-command: yarn + run: yarn - name: Generate test-website project against main branch run: | diff --git a/.github/workflows/v2-tests-windows.yml b/.github/workflows/v2-tests-windows.yml index d9c046914012..52fce19e924b 100644 --- a/.github/workflows/v2-tests-windows.yml +++ b/.github/workflows/v2-tests-windows.yml @@ -20,6 +20,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} + cache: yarn - name: Installation run: yarn || yarn || yarn # 3 attempts to avoid timeout errors... - name: Docusaurus Jest Tests diff --git a/.github/workflows/v2-tests.yml b/.github/workflows/v2-tests.yml index b31a93451465..70eb1317d1b1 100644 --- a/.github/workflows/v2-tests.yml +++ b/.github/workflows/v2-tests.yml @@ -18,10 +18,9 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} + cache: yarn - name: Installation - uses: bahmutov/npm-install@v1 - with: - install-command: yarn + run: yarn - name: Test run: yarn test - name: TypeCheck website