|
1 | | -# build and test on linux, windows, mac with node 12, 14, 16 |
| 1 | +# build and test |
2 | 2 | name: CI |
3 | 3 |
|
4 | | -env: |
5 | | - pnpm_store_path: ${{github.workspace}}/.pnpm-store |
6 | | - CI: true |
7 | | - |
8 | 4 | on: |
9 | 5 | push: |
10 | 6 | branches: |
|
14 | 10 | - master |
15 | 11 |
|
16 | 12 | jobs: |
17 | | - pnpmstore: |
| 13 | + # "checks" job runs on linux + 16 only and checks that install, build, lint and audit work |
| 14 | + # it also primes the pnpm store cache for linux, important for downstream tests |
| 15 | + checks: |
| 16 | + timeout-minutes: 5 |
18 | 17 | runs-on: ${{ matrix.os }} |
19 | | - |
20 | 18 | strategy: |
21 | | - fail-fast: false |
22 | 19 | matrix: |
23 | | - # os: [ ubuntu-latest, windows-latest, macos-latest ] |
24 | | - os: [ ubuntu-latest, macos-latest ] |
25 | | - node: [ 12, 14, 16 ] |
26 | | - |
| 20 | + # pseudo-matrix for convenience, NEVER use more than a single combination |
| 21 | + node: [16] |
| 22 | + os: [ubuntu-latest] |
| 23 | + outputs: |
| 24 | + build_successful: ${{ steps.build.outcome == 'success' }} |
27 | 25 | steps: |
28 | | - - uses: actions/setup-node@v2 |
| 26 | + - uses: actions/checkout@v3 |
| 27 | + - uses: actions/setup-node@v3 |
29 | 28 | with: |
30 | 29 | node-version: ${{ matrix.node }} |
31 | | - |
32 | | - - name: checkout |
33 | | - uses: actions/checkout@v2 |
34 | | - |
35 | | - - name: install pnpm |
36 | | - run: npm i -g pnpm@6 |
37 | | - - name: set pnpm store-dir |
38 | | - run: pnpm config set store-dir ${{ env.pnpm_store_path }} |
39 | | - - name: pnpm-store |
40 | | - uses: actions/cache@v2 |
41 | | - id: pnpm-store |
42 | | - with: |
43 | | - path: ${{ env.pnpm_store_path }} |
44 | | - key: ${{ matrix.os }}-node-v${{ matrix.node }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
45 | | - |
46 | | - - name: pnpm-store-fallback |
47 | | - if: steps.pnpm-store.outputs.cache-hit != 'true' |
48 | | - uses: actions/cache@v2 |
49 | | - id: pnpm-store-fallback |
50 | | - with: |
51 | | - path: ${{ env.pnpm_store_path }} |
52 | | - key: ${{ matrix.os }}-node-v${{ matrix.node }}-pnpm-store-fallback-${{ hashFiles('**/pnpm-lock.yaml') }} |
53 | | - restore-keys: | |
54 | | - ${{ matrix.os }}-node-v${{ matrix.node }}-pnpm-store-fallback- |
55 | | - ${{ matrix.os }}-node-v${{ matrix.node }}-pnpm-store- |
56 | | -
|
57 | | - - name: install |
58 | | - if: steps.pnpm-store.outputs.cache-hit != 'true' |
59 | | - run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts |
60 | | - - name: prune store |
61 | | - if: steps.pnpm-store.outputs.cache-hit != 'true' |
62 | | - run: pnpm store prune |
63 | | - - name: check store |
64 | | - if: steps.pnpm-store.outputs.cache-hit != 'true' |
65 | | - run: pnpm store status |
66 | | - |
67 | | - lint: |
68 | | - needs: pnpmstore |
69 | | - |
70 | | - runs-on: ${{ matrix.os }} |
71 | | - strategy: |
72 | | - matrix: |
73 | | - os: [ ubuntu-latest ] |
74 | | - node: [ 14 ] |
75 | | - steps: |
76 | | - - uses: actions/setup-node@v2 |
| 30 | + - run: npm i -g pnpm@6 |
| 31 | + - uses: actions/setup-node@v3 |
77 | 32 | with: |
78 | 33 | node-version: ${{ matrix.node }} |
79 | | - |
80 | | - - name: checkout |
81 | | - uses: actions/checkout@v2 |
82 | | - |
83 | | - - name: pnpm-store |
84 | | - uses: actions/cache@v2 |
85 | | - id: pnpm-store |
86 | | - with: |
87 | | - path: ${{ env.pnpm_store_path }} |
88 | | - key: ${{ matrix.os }}-node-v${{ matrix.node }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
89 | | - - name: install pnpm |
90 | | - run: npm i -g pnpm@6 |
91 | | - - name: set pnpm store-dir |
92 | | - run: pnpm config set store-dir ${{ env.pnpm_store_path }} |
| 34 | + cache: 'pnpm' |
| 35 | + cache-dependency-path: '**/pnpm-lock.yaml' |
93 | 36 | - name: install |
94 | | - run: pnpm install --frozen-lockfile --offline --ignore-scripts |
| 37 | + run: pnpm install --frozen-lockfile --prefer-offline |
| 38 | + - name: build |
| 39 | + id: build |
| 40 | + run: pnpm run build |
95 | 41 | - name: lint |
96 | | - run: pnpm lint |
97 | | - |
98 | | - audit: |
99 | | - needs: pnpmstore |
100 | | - |
101 | | - runs-on: ${{ matrix.os }} |
102 | | - strategy: |
103 | | - matrix: |
104 | | - os: [ ubuntu-latest ] |
105 | | - node: [ 14 ] |
106 | | - steps: |
107 | | - - uses: actions/setup-node@v2 |
108 | | - with: |
109 | | - node-version: ${{ matrix.node }} |
110 | | - |
111 | | - - name: checkout |
112 | | - uses: actions/checkout@v2 |
113 | | - |
114 | | - - name: pnpm-store |
115 | | - uses: actions/cache@v2 |
116 | | - id: pnpm-store |
117 | | - with: |
118 | | - path: ${{ env.pnpm_store_path }} |
119 | | - key: ${{ matrix.os }}-node-v${{ matrix.node }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
120 | | - - name: install pnpm |
121 | | - run: npm i -g pnpm@6 |
122 | | - - name: set pnpm store-dir |
123 | | - run: pnpm config set store-dir ${{ env.pnpm_store_path }} |
124 | | - - name: install |
125 | | - run: pnpm install --frozen-lockfile --offline --ignore-scripts |
| 42 | + if: (${{ success() }} || ${{ failure() }}) |
| 43 | + run: pnpm run lint |
126 | 44 | - name: audit |
| 45 | + if: (${{ success() }} || ${{ failure() }}) |
127 | 46 | run: pnpm audit |
128 | 47 |
|
| 48 | + # this is the test matrix |
| 49 | + # it is skipped if the build step of the checks job wasn't successful (still runs if lint or audit fail) |
129 | 50 | test: |
130 | | - needs: pnpmstore |
131 | | - |
| 51 | + needs: checks |
| 52 | + if: (${{ success() }} || ${{ failure() }}) && (${{ needs.checks.output.build_successful }}) |
| 53 | + timeout-minutes: 10 |
132 | 54 | runs-on: ${{ matrix.os }} |
133 | | - timeout-minutes: 5 |
134 | 55 | strategy: |
135 | 56 | fail-fast: false |
136 | 57 | matrix: |
137 | 58 | os: [ ubuntu-latest, macos-latest ] |
138 | | - node: [ 12, 14, 16 ] |
| 59 | + node: [ 14, 16 ] |
139 | 60 | steps: |
140 | | - - uses: actions/setup-node@v2 |
| 61 | + - uses: actions/checkout@v2 |
| 62 | + - uses: actions/setup-node@v3 |
141 | 63 | with: |
142 | 64 | node-version: ${{ matrix.node }} |
143 | | - |
144 | | - - name: checkout |
145 | | - uses: actions/checkout@v2 |
146 | | - |
147 | | - - name: pnpm-store |
148 | | - uses: actions/cache@v2 |
149 | | - id: pnpm-store |
| 65 | + - run: npm i -g pnpm@6 |
| 66 | + - uses: actions/setup-node@v3 |
150 | 67 | with: |
151 | | - path: ${{ env.pnpm_store_path }} |
152 | | - key: ${{ matrix.os }}-node-v${{ matrix.node }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
153 | | - |
154 | | - - name: install pnpm |
155 | | - run: npm i -g pnpm@6 |
156 | | - - name: set pnpm store-dir |
157 | | - run: pnpm config set store-dir ${{ env.pnpm_store_path }} |
| 68 | + node-version: ${{ matrix.node }} |
| 69 | + cache: 'pnpm' |
| 70 | + cache-dependency-path: '**/pnpm-lock.yaml' |
158 | 71 | - name: install |
159 | | - run: pnpm install --frozen-lockfile --offline |
| 72 | + run: pnpm install --frozen-lockfile --prefer-offline |
160 | 73 | - name: run tests |
161 | 74 | run: pnpm test |
0 commit comments