Skip to content

Commit 7ca56ff

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

4 files changed

Lines changed: 91 additions & 12 deletions

File tree

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: 32 additions & 10 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:
@@ -21,6 +21,27 @@ jobs:
2121
name: 🏗 Build Project
2222
runs-on: ubuntu-latest
2323
timeout-minutes: 30
24+
strategy:
25+
matrix:
26+
node-version: [16, 18]
27+
typescript-version:
28+
['default', '~4.6.4', '~4.7.4', '~4.8.3', '~4.9.5', '~5.0.4']
29+
steps:
30+
- uses: actions/checkout@v3
31+
with:
32+
ref: ${{ github.event.pull_request.head.sha }}
33+
34+
- name: Install node_modules & package
35+
uses: ./.github/actions/install-node-modules-and-package
36+
with:
37+
path: ${{ matrix.AFFECTED_LIB }}
38+
node-version: ${{ matrix.node-version }}
39+
typescript-version: ${{ matrix.typescript-version }}
40+
41+
get-affected-packages:
42+
name: 🔎 Get affected packages
43+
runs-on: ubuntu-latest
44+
timeout-minutes: 30
2445
outputs:
2546
affected-packages: ${{ steps.get-affected-packages-paths.outputs.affected-packages }}
2647
steps:
@@ -30,36 +51,36 @@ jobs:
3051
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
3152
fetch-depth: 0
3253

33-
- name: Install node_modules
34-
uses: ./.github/actions/install-node-modules
35-
36-
- name: Package
37-
uses: ./.github/actions/package
38-
3954
- name: Get affected packages paths
4055
id: get-affected-packages-paths
4156
uses: ./.github/actions/get-affected-packages-paths
4257
with:
4358
base-branch: ${{ github.base_ref }}
4459

4560
library-lint-and-tests:
46-
name: 🎯 Run Tests
47-
needs: build
61+
name: '🎯 Run ${{ matrix.AFFECTED_LIB }} tests (Node${{ matrix.node-version }}, TS${{ matrix.typescript-version }})'
62+
needs: [build, get-affected-packages]
4863
runs-on: ubuntu-latest
4964
if: join(fromJson(needs.build.outputs.affected-packages)) != ''
5065
timeout-minutes: 30
5166
strategy:
5267
fail-fast: false
5368
matrix:
54-
AFFECTED_LIB: ${{ fromJson(needs.build.outputs.affected-packages) }}
69+
AFFECTED_LIB: ${{ fromJson(needs.get-affected-packages.outputs.affected-packages) }}
70+
node-version: [16, 18]
71+
typescript-version:
72+
['default', '~4.6.4', '~4.7.4', '~4.8.3', '~4.9.5', '~5.0.4']
5573
steps:
5674
- uses: actions/checkout@v3
5775
with:
5876
ref: ${{ github.event.pull_request.head.sha }}
77+
5978
- name: Run tests
6079
uses: ./.github/actions/lint-and-tests
6180
with:
6281
path: ${{ matrix.AFFECTED_LIB }}
82+
node-version: ${{ matrix.node-version }}
83+
typescript-version: ${{ matrix.typescript-version }}
6384

6485
validate-pr:
6586
name: ✅ Validate the PR
@@ -73,6 +94,7 @@ jobs:
7394
echo "build failed"
7495
exit 1
7596
fi
97+
7698
- name: Validate tests
7799
run: |
78100
if [[ ${{ needs.library-lint-and-tests.result }} = "failure" ]]; then

0 commit comments

Comments
 (0)