Skip to content

Commit 12d5e4c

Browse files
authored
ci(workflow): add cache to workflows using actions/setup-node (#9757)
* ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows * style(workflows): restore single quotes and remove unnecessary 'null'
1 parent 6a250de commit 12d5e4c

File tree

3 files changed

+97
-95
lines changed

3 files changed

+97
-95
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
- master
1111
- "2.9"
1212
workflow_dispatch:
13-
1413
jobs:
1514
build:
1615
runs-on: ${{ matrix.os }}
@@ -24,80 +23,80 @@ jobs:
2423
fail-fast: false
2524

2625
steps:
27-
- uses: actions/checkout@v2
28-
- name: Use Node.js
29-
uses: actions/setup-node@v1
30-
with:
31-
node-version: '14'
32-
- uses: dorny/paths-filter@v2
33-
id: changes
34-
with:
35-
filters: |
36-
docs:
37-
- 'docs/**'
38-
- 'package.json'
39-
- 'tsconfig.json'
40-
src:
41-
- 'src/**'
42-
- 'package.json'
43-
test:
44-
- 'test/**'
45-
- 'karma.conf.js'
46-
- 'package.json'
47-
types:
48-
- 'types/**'
49-
- 'package.json'
50-
- 'tsconfig.json'
51-
- name: Install
52-
run: npm ci
53-
- name: Build
54-
run: npm run build
55-
- name: Test
56-
if: |
57-
steps.changes.outputs.src == 'true' ||
58-
steps.changes.outputs.test == 'true'
59-
run: |
60-
npm run build
61-
if [ "${{ runner.os }}" == "Windows" ]; then
62-
npm test
63-
elif [ "${{ runner.os }}" == "macOS" ]; then
64-
npm test --browsers chrome,safari
65-
else
66-
xvfb-run --auto-servernum npm test
67-
fi
68-
shell: bash
69-
- name: Lint
70-
run: npm run lint
71-
- name: Package
72-
if: steps.changes.outputs.docs == 'true'
73-
run: |
74-
npm run docs
75-
npm pack
76-
- name: Coveralls Parallel - Chrome
77-
if: steps.changes.outputs.src == 'true'
78-
uses: coverallsapp/github-action@master
79-
with:
80-
github-token: ${{ secrets.github_token }}
81-
path-to-lcov: './coverage/chrome/lcov.info'
82-
flag-name: ${{ matrix.os }}-chrome
83-
parallel: true
84-
- name: Coveralls Parallel - Firefox
85-
if: steps.changes.outputs.src == 'true'
86-
uses: coverallsapp/github-action@master
87-
with:
88-
github-token: ${{ secrets.github_token }}
89-
path-to-lcov: './coverage/firefox/lcov.info'
90-
flag-name: ${{ matrix.os }}-firefox
91-
parallel: true
92-
26+
- uses: actions/checkout@v2
27+
- name: Use Node.js
28+
uses: actions/setup-node@v2
29+
with:
30+
node-version: '14'
31+
cache: npm
32+
- uses: dorny/paths-filter@v2
33+
id: changes
34+
with:
35+
filters: |
36+
docs:
37+
- 'docs/**'
38+
- 'package.json'
39+
- 'tsconfig.json'
40+
src:
41+
- 'src/**'
42+
- 'package.json'
43+
test:
44+
- 'test/**'
45+
- 'karma.conf.js'
46+
- 'package.json'
47+
types:
48+
- 'types/**'
49+
- 'package.json'
50+
- 'tsconfig.json'
51+
- name: Install
52+
run: npm ci
53+
- name: Build
54+
run: npm run build
55+
- name: Test
56+
if: |
57+
steps.changes.outputs.src == 'true' ||
58+
steps.changes.outputs.test == 'true'
59+
run: |
60+
npm run build
61+
if [ "${{ runner.os }}" == "Windows" ]; then
62+
npm test
63+
elif [ "${{ runner.os }}" == "macOS" ]; then
64+
npm test --browsers chrome,safari
65+
else
66+
xvfb-run --auto-servernum npm test
67+
fi
68+
shell: bash
69+
- name: Lint
70+
run: npm run lint
71+
- name: Package
72+
if: steps.changes.outputs.docs == 'true'
73+
run: |
74+
npm run docs
75+
npm pack
76+
- name: Coveralls Parallel - Chrome
77+
if: steps.changes.outputs.src == 'true'
78+
uses: coverallsapp/github-action@master
79+
with:
80+
github-token: ${{ secrets.github_token }}
81+
path-to-lcov: './coverage/chrome/lcov.info'
82+
flag-name: ${{ matrix.os }}-chrome
83+
parallel: true
84+
- name: Coveralls Parallel - Firefox
85+
if: steps.changes.outputs.src == 'true'
86+
uses: coverallsapp/github-action@master
87+
with:
88+
github-token: ${{ secrets.github_token }}
89+
path-to-lcov: './coverage/firefox/lcov.info'
90+
flag-name: ${{ matrix.os }}-firefox
91+
parallel: true
9392

9493
finish:
9594
needs: build
9695
runs-on: ubuntu-latest
9796
steps:
98-
- name: Coveralls Finished
99-
if: needs.build.outputs.coveralls == 'true'
100-
uses: coverallsapp/github-action@master
101-
with:
102-
github-token: ${{ secrets.github_token }}
103-
parallel-finished: true
97+
- name: Coveralls Finished
98+
if: needs.build.outputs.coveralls == 'true'
99+
uses: coverallsapp/github-action@master
100+
with:
101+
github-token: ${{ secrets.github_token }}
102+
parallel-finished: true

.github/workflows/deploy-docs.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,28 @@ jobs:
1010
correct_repository:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: fail on fork
14-
if: github.repository_owner != 'chartjs'
15-
run: exit 1
13+
- name: fail on fork
14+
if: github.repository_owner != 'chartjs'
15+
run: exit 1
1616

1717
build:
1818
needs: correct_repository
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@v2
22-
- name: Use Node.js
23-
uses: actions/setup-node@v1
24-
with:
25-
node-version: '14.x'
26-
- name: Package & Deploy Docs
27-
run: |
28-
npm ci
29-
npm run build
30-
./scripts/docs-config.sh "master"
31-
npm run docs
32-
npm pack
33-
./scripts/deploy-docs.sh "master"
34-
env:
35-
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
36-
GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js
23+
uses: actions/setup-node@v2
24+
with:
25+
node-version: '14.x'
26+
cache: npm
27+
- name: Package & Deploy Docs
28+
run: |
29+
npm ci
30+
npm run build
31+
./scripts/docs-config.sh "master"
32+
npm run docs
33+
npm pack
34+
./scripts/deploy-docs.sh "master"
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
37+
GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v2
23-
- uses: actions/setup-node@v1
23+
- uses: actions/setup-node@v2
2424
with:
2525
node-version: '14.x'
2626
registry-url: https://registry.npmjs.org/
27+
cache: npm
2728
- name: Setup and build
2829
run: |
2930
npm ci
@@ -59,15 +60,16 @@ jobs:
5960
asset_name: ${{ format('chart.js-{0}.tgz', needs.setup.outputs.version) }}
6061
asset_content_type: application/gzip
6162
release-tag:
62-
needs: [setup,release]
63+
needs: [setup, release]
6364
runs-on: ubuntu-latest
6465
if: "!github.event.release.prerelease"
6566
steps:
6667
- uses: actions/checkout@v2
67-
- uses: actions/setup-node@v1
68+
- uses: actions/setup-node@v2
6869
with:
6970
node-version: '14.x'
7071
registry-url: https://registry.npmjs.org/
72+
cache: npm
7173
- name: Setup and build
7274
run: |
7375
npm ci

0 commit comments

Comments
 (0)