Skip to content

Commit

Permalink
chore(workflow): add cache to workflows using actions/setup-node (#5697)
Browse files Browse the repository at this point in the history
* ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows

* Use cache: yarn

* Reformat

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
  • Loading branch information
oscard0m and Josh-Cena committed Oct 30, 2021
1 parent 9247332 commit 41346e0
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 50 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/canary-release.yml
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
paths:
- 'packages/**'
- packages/**

jobs:
publish-canary:
Expand All @@ -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"
Expand Down
38 changes: 16 additions & 22 deletions .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:
Expand All @@ -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
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/v2-build-blog-only.yml
Expand Up @@ -5,8 +5,7 @@ on:
branches:
- main
paths:
- 'website-1.x/blog/**'
- 'packages/docusaurus/**'
- packages/docusaurus/**

jobs:
build:
Expand All @@ -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
8 changes: 5 additions & 3 deletions .github/workflows/v2-build-size-report.yml
Expand Up @@ -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
8 changes: 4 additions & 4 deletions .github/workflows/v2-build-time-perf.yml
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
paths-ignore:
- 'website/docs/**'
- website/docs/**

jobs:
build:
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/v2-lighthouse-report.yml
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/v2-tests-e2e.yml
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/v2-tests-windows.yml
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/v2-tests.yml
Expand Up @@ -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
Expand Down

0 comments on commit 41346e0

Please sign in to comment.