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 <sidachen2003@gmail.com>
This commit is contained in:
Oscar Dominguez 2021-10-30 09:27:06 +02:00 committed by GitHub
parent 9247332334
commit 41346e0abf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 50 deletions

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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: |

View file

@ -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

View file

@ -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