|
1 | 1 | name: CI
|
2 |
| -on: [push] |
3 |
| -jobs: |
4 |
| - build: |
5 |
| - name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }} |
6 | 2 |
|
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | + # Allows to run this workflow manually from the Actions tab |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + ci: |
| 14 | + name: CI on Node ${{ matrix.node }} and ${{ matrix.os }} |
7 | 15 | runs-on: ${{ matrix.os }}
|
8 | 16 | strategy:
|
9 | 17 | matrix:
|
10 |
| - node: ['12.x', '14.x'] |
11 |
| - os: [ubuntu-latest, windows-latest, macOS-latest] |
| 18 | + node-version: ['12.x', '14.x', '16.x'] |
| 19 | + os: [ubuntu-latest] |
12 | 20 |
|
13 | 21 | steps:
|
14 | 22 | - name: Checkout repo
|
15 | 23 | uses: actions/checkout@v2
|
16 | 24 |
|
17 |
| - - name: Use Node ${{ matrix.node }} |
18 |
| - uses: actions/setup-node@v1 |
| 25 | + - name: Install Node ${{ matrix.node-version }} |
| 26 | + uses: actions/setup-node@v2 |
| 27 | + with: |
| 28 | + node-version: ${{ matrix.node-version }} |
| 29 | + |
| 30 | + # See: https://github.com/actions/cache/blob/main/examples.md#node---yarn |
| 31 | + - name: Get Yarn cache directory |
| 32 | + id: yarn-cache-dir-path |
| 33 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 34 | + |
| 35 | + - name: Use Yarn cache |
| 36 | + uses: actions/cache@v2 |
| 37 | + id: yarn-cache |
19 | 38 | with:
|
20 |
| - node-version: ${{ matrix.node }} |
| 39 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 40 | + key: ${{ matrix.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} |
21 | 41 |
|
22 |
| - - name: Install deps and build (with cache) |
23 |
| - uses: bahmutov/npm-install@v1 |
| 42 | + - name: Install dependencies |
| 43 | + # `--prefer-offline` gives local cache the priority to restore |
| 44 | + run: yarn install --prefer-offline --frozen-lockfile |
24 | 45 |
|
25 | 46 | - name: Lint
|
26 | 47 | run: yarn lint
|
|
0 commit comments