Skip to content

Commit af063ce

Browse files
author
Thomas Aribart
committed
test PRs on several node and ts versions
1 parent d604f0a commit af063ce

File tree

4 files changed

+76
-8
lines changed

4 files changed

+76
-8
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Install Node Dependencies
2+
description: Install dependencies using yarn
3+
inputs:
4+
node-version:
5+
description: Node version to use
6+
required: true
7+
typescript-version:
8+
description: TS version to use
9+
default: 'default'
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Use Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: ${{ inputs.node-version }}
18+
19+
- name: Get yarn cache directory path
20+
id: yarn-cache-dir-path
21+
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
22+
shell: bash
23+
24+
- name: Sync yarn cache
25+
uses: actions/cache@v3
26+
with:
27+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
28+
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-yarn-
31+
32+
- name: Sync node_modules cache
33+
id: sync-node-modules-cache
34+
uses: actions/cache@v3
35+
with:
36+
path: '**/node_modules'
37+
key: ${{ runner.os }}-modules-${{ inputs.node-version }}-${{ inputs.typescript-version }}-${{ hashFiles('./yarn.lock') }}
38+
39+
- name: Install node_modules
40+
run: if [ '${{ steps.sync-node-modules-cache.outputs.cache-hit }}' != 'true' ]; then yarn install --immutable; fi
41+
shell: bash
42+
43+
- name: Override TS with specified version
44+
run: if [ '${{ inputs.typescript-version }}' != 'default' ] && [ '${{ steps.sync-node-modules-cache.outputs.cache-hit }}' != 'true' ]; then yarn add --dev typescript@${{ inputs.typescript-version }}; fi
45+
shell: bash
46+
47+
- name: Sync packages cache
48+
id: sync-packages-cache
49+
uses: actions/cache@v3
50+
with:
51+
path: |
52+
node_modules/@castore/**/dist
53+
key: ${{ inputs.node-version }}-${{ inputs.typescript-version }}-${{ hashFiles('./packages/**') }}-${{ hashFiles('./demo/**') }}
54+
55+
- name: Package
56+
run: if [ '${{ steps.sync-packages-cache.outputs.cache-hit }}' != 'true' ]; then yarn package; fi
57+
shell: bash

.github/workflows/draft-or-update-next-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
env:
1010
CI: true
11-
NODE_VERSION: 16
11+
NODE_VERSION: 18
1212

1313
jobs:
1414
prepare-deployment:

.github/workflows/label-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
env:
1212
CI: true
13-
NODE_VERSION: 16
13+
NODE_VERSION: 18
1414

1515
defaults:
1616
run:

.github/workflows/test-pr.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
env:
1212
CI: true
13-
NODE_VERSION: 16
13+
NODE_VERSION: 18
1414

1515
defaults:
1616
run:
@@ -23,18 +23,24 @@ jobs:
2323
timeout-minutes: 30
2424
outputs:
2525
affected-packages: ${{ steps.get-affected-packages-paths.outputs.affected-packages }}
26+
strategy:
27+
matrix:
28+
node-version: [16, 18]
29+
typescript-version:
30+
['default', '~4.6.4', '~4.7.4', '~4.8.3', '~4.9.5', '~5.0.4']
2631
steps:
2732
- uses: actions/checkout@v3
2833
with:
2934
ref: ${{ github.event.pull_request.head.sha }}
3035
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
3136
fetch-depth: 0
3237

33-
- name: Install node_modules
38+
- name: Install node_modules & package
3439
uses: ./.github/actions/install-node-modules
35-
36-
- name: Package
37-
uses: ./.github/actions/package
40+
with:
41+
path: ${{ matrix.AFFECTED_LIB }}
42+
node-version: ${{ matrix.node-version }}
43+
typescript-version: ${{ matrix.typescript-version }}
3844

3945
- name: Get affected packages paths
4046
id: get-affected-packages-paths
@@ -43,7 +49,7 @@ jobs:
4349
base-branch: ${{ github.base_ref }}
4450

4551
library-lint-and-tests:
46-
name: 🎯 Run Tests
52+
name: '🎯 Run ${{ matrix.AFFECTED_LIB }} tests (Node${{ matrix.node-version }}, TS${{ matrix.typescript-version }})'
4753
needs: build
4854
runs-on: ubuntu-latest
4955
if: join(fromJson(needs.build.outputs.affected-packages)) != ''
@@ -52,6 +58,9 @@ jobs:
5258
fail-fast: false
5359
matrix:
5460
AFFECTED_LIB: ${{ fromJson(needs.build.outputs.affected-packages) }}
61+
node-version: [16, 18]
62+
typescript-version:
63+
['default', '~4.6.4', '~4.7.4', '~4.8.3', '~4.9.5', '~5.0.4']
5564
steps:
5665
- uses: actions/checkout@v3
5766
with:
@@ -60,6 +69,8 @@ jobs:
6069
uses: ./.github/actions/lint-and-tests
6170
with:
6271
path: ${{ matrix.AFFECTED_LIB }}
72+
node-version: ${{ matrix.node-version }}
73+
typescript-version: ${{ matrix.typescript-version }}
6374

6475
validate-pr:
6576
name: ✅ Validate the PR

0 commit comments

Comments
 (0)