Skip to content

Commit 1bbe5af

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

File tree

4 files changed

+92
-13
lines changed

4 files changed

+92
-13
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: 33 additions & 11 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,37 +21,51 @@ jobs:
2121
name: 🏗 Build Project
2222
runs-on: ubuntu-latest
2323
timeout-minutes: 30
24-
outputs:
25-
affected-packages: ${{ steps.get-affected-packages-paths.outputs.affected-packages }}
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']
2629
steps:
2730
- uses: actions/checkout@v3
2831
with:
2932
ref: ${{ github.event.pull_request.head.sha }}
3033
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
3134
fetch-depth: 0
3235

33-
- name: Install node_modules
36+
- name: Install node_modules & package
3437
uses: ./.github/actions/install-node-modules
38+
with:
39+
path: ${{ matrix.AFFECTED_LIB }}
40+
node-version: ${{ matrix.node-version }}
41+
typescript-version: ${{ matrix.typescript-version }}
3542

36-
- name: Package
37-
uses: ./.github/actions/package
38-
43+
get-affected-packages:
44+
name: 🔎 Get affected packages
45+
runs-on: ubuntu-latest
46+
timeout-minutes: 30
47+
outputs:
48+
affected-packages: ${{ steps.get-affected-packages-paths.outputs.affected-packages }}
49+
steps:
3950
- name: Get affected packages paths
4051
id: get-affected-packages-paths
4152
uses: ./.github/actions/get-affected-packages-paths
4253
with:
4354
base-branch: ${{ github.base_ref }}
4455

4556
library-lint-and-tests:
46-
name: 🎯 Run Tests
47-
needs: build
57+
name: '🎯 Run ${{ matrix.AFFECTED_LIB }} tests (Node${{ matrix.node-version }}, TS${{ matrix.typescript-version }})'
58+
needs: [build, get-affected-packages]
4859
runs-on: ubuntu-latest
4960
if: join(fromJson(needs.build.outputs.affected-packages)) != ''
5061
timeout-minutes: 30
5162
strategy:
5263
fail-fast: false
5364
matrix:
54-
AFFECTED_LIB: ${{ fromJson(needs.build.outputs.affected-packages) }}
65+
AFFECTED_LIB: ${{ fromJson(needs.get-affected-packages.outputs.affected-packages) }}
66+
node-version: [16, 18]
67+
typescript-version:
68+
['default', '~4.6.4', '~4.7.4', '~4.8.3', '~4.9.5', '~5.0.4']
5569
steps:
5670
- uses: actions/checkout@v3
5771
with:
@@ -60,19 +74,27 @@ jobs:
6074
uses: ./.github/actions/lint-and-tests
6175
with:
6276
path: ${{ matrix.AFFECTED_LIB }}
77+
node-version: ${{ matrix.node-version }}
78+
typescript-version: ${{ matrix.typescript-version }}
6379

6480
validate-pr:
6581
name: ✅ Validate the PR
6682
runs-on: ubuntu-latest
6783
if: ${{ always() }}
68-
needs: [build, library-lint-and-tests]
84+
needs: [build, get-affected-packages, library-lint-and-tests]
6985
steps:
7086
- name: Validate build
7187
run: |
7288
if [[ ${{ needs.build.result }} = "failure" ]]; then
7389
echo "build failed"
7490
exit 1
7591
fi
92+
- name: Validate get-affected-packages
93+
run: |
94+
if [[ ${{ needs.get-affected-packages.result }} = "failure" ]]; then
95+
echo "get-affected-packages failed"
96+
exit 1
97+
fi
7698
- name: Validate tests
7799
run: |
78100
if [[ ${{ needs.library-lint-and-tests.result }} = "failure" ]]; then

0 commit comments

Comments
 (0)