Skip to content

Commit 53893c6

Browse files
committed
chore: modernize CI workflow and migrate to Nx release system
1 parent d649ec2 commit 53893c6

File tree

9 files changed

+6949
-14841
lines changed

9 files changed

+6949
-14841
lines changed

.github/actions/cache/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ runs:
99
with:
1010
path: |
1111
**/node_modules
12-
key: install-cache-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
12+
key: install-cache-${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }}

.github/actions/release/action.yml

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,10 @@ inputs:
1313
gh_email:
1414
description: 'Github email'
1515
required: true
16-
gh_repository:
17-
description: 'Github repository'
18-
required: true
1916
runs:
2017
using: "composite"
2118
steps:
22-
- name: Use Node.js 22.x
23-
uses: actions/setup-node@v4
24-
with:
25-
node-version: '22'
26-
- uses: nrwl/nx-set-shas@v4
27-
- uses: './.github/actions/cache'
19+
- uses: './.github/actions/setup-environment'
2820
- name: Install deps
2921
shell: bash
3022
run: npm i
@@ -33,26 +25,24 @@ runs:
3325
run: |
3426
git config user.name "${{ inputs.gh_name }}"
3527
git config user.email "${{ inputs.gh_email }}"
36-
git remote set-url origin https://${{ inputs.gh_token }}@github.com/${{ inputs.gh_repository }}
37-
- name: Build
38-
shell: bash
39-
run: npx nx run-many -t build --exclude=demo,
4028
- name: Set publish config
4129
env:
4230
NPM_TOKEN: ${{ inputs.npm_token }}
4331
shell: bash
4432
run: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
45-
- name: Version
33+
- name: Release version
4634
shell: bash
4735
env:
48-
# skip the git hooks
49-
HUSKY: 0
5036
GH_TOKEN: ${{ inputs.gh_token }}
5137
GITHUB_TOKEN: ${{ inputs.gh_token }}
52-
run: npx nx affected --base=last-release --parallel=1 --baseBranch=master --target=version --trackDeps --postTargets=build,deploy,github --exclude=@redhat-cloud-services/executors,demo
53-
- name: Tag last-release
38+
# Disable legacy peer deps to ensure proper dependency resolution
39+
# See: https://github.com/nrwl/nx/issues/22066#issuecomment-2576366862
40+
# See: https://github.com/nrwl/nx/blob/5ea2e47acfa9d175546daa922ce40905533f1074/packages/nx/src/utils/package-manager.ts#L207-L213
41+
npm_config_legacy_peer_deps: false
42+
run: npx nx release version
43+
- name: Release publish
5444
shell: bash
55-
run: |
56-
git tag -f last-release
57-
git push origin last-release --force --no-verify
45+
env:
46+
NPM_TOKEN: ${{ inputs.npm_token }}
47+
run: npx nx release publish
5848

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Setup Environment
2+
description: Setup Node.js and cache dependencies consistently
3+
# Note: All workflows using this action should use runs-on: ubuntu-24.04
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Show Node.js environment info
8+
shell: bash
9+
run: |
10+
echo "=== Pre-installed Node.js versions ==="
11+
ls -la /opt/hostedtoolcache/node/ 2>/dev/null || ls -la /opt/acttoolcache/node/ 2>/dev/null || echo "No pre-installed Node versions found"
12+
echo "=== Current default Node.js ==="
13+
which node && node --version || echo "No default Node.js found"
14+
echo "=== .nvmrc content ==="
15+
cat .nvmrc 2>/dev/null || echo "No .nvmrc file found"
16+
- uses: actions/setup-node@v5
17+
with:
18+
node-version-file: '.nvmrc'
19+
- name: Show final Node.js version
20+
shell: bash
21+
run: |
22+
echo "=== Final Node.js version after setup ==="
23+
which node && node --version
24+
npm --version
25+
- uses: './.github/actions/cache'

.github/workflows/ci.yaml

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,50 @@ on:
99

1010
jobs:
1111
install:
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-24.04
1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
18-
- uses: nrwl/nx-set-shas@v4
19-
- uses: './.github/actions/cache'
18+
- uses: './.github/actions/setup-environment'
2019
- uses: './.github/actions/cypress-cache'
2120
- name: Install dependencies
2221
run: npm i
2322
build:
24-
runs-on: ubuntu-latest
23+
runs-on: ubuntu-24.04
2524
needs: install
2625
steps:
2726
- name: Checkout
2827
uses: actions/checkout@v4
2928
with:
3029
fetch-depth: 0
31-
- name: Use Node.js 22.x
32-
uses: actions/setup-node@v3
33-
with:
34-
node-version: 22.x
30+
- uses: './.github/actions/setup-environment'
3531
- uses: nrwl/nx-set-shas@v4
36-
- uses: './.github/actions/cache'
3732
- name: Build
3833
run: npm run build
3934
unit-test:
40-
runs-on: ubuntu-latest
35+
runs-on: ubuntu-24.04
4136
needs: [install]
4237
steps:
4338
- name: Checkout
4439
uses: actions/checkout@v4
4540
with:
4641
fetch-depth: 0
47-
- name: Use Node.js 22.x
48-
uses: actions/setup-node@v3
49-
with:
50-
node-version: 22.x
42+
- uses: './.github/actions/setup-environment'
5143
- uses: nrwl/nx-set-shas@v4
52-
- uses: './.github/actions/cache'
5344
- name: Run unit tests
5445
run: npm run test:unit
5546
component-test:
56-
runs-on: ubuntu-latest
47+
runs-on: ubuntu-24.04
5748
needs: install
5849
steps:
5950
- name: Checkout
6051
uses: actions/checkout@v4
6152
with:
6253
fetch-depth: 0
54+
- uses: './.github/actions/setup-environment'
6355
- uses: nrwl/nx-set-shas@v4
64-
- uses: './.github/actions/cache'
6556
- uses: './.github/actions/cypress-cache'
6657
- name: Install deps
6758
shell: bash
@@ -70,27 +61,27 @@ jobs:
7061
uses: cypress-io/github-action@v6
7162
with:
7263
command: npx nx affected -t test:component --exclude=demo --configuration=ci --parallel=1
73-
lint:
74-
runs-on: ubuntu-latest
64+
lint:
65+
runs-on: ubuntu-24.04
7566
needs: install
7667
steps:
7768
- name: Checkout
7869
uses: actions/checkout@v4
7970
with:
8071
fetch-depth: 0
72+
- uses: './.github/actions/setup-environment'
8173
- uses: nrwl/nx-set-shas@v4
82-
- uses: './.github/actions/cache'
8374
- name: Lint
8475
run: npx nx affected -t test:lint --exclude=demo
8576
commitlint:
8677
needs: [install]
87-
runs-on: ubuntu-latest
78+
runs-on: ubuntu-24.04
8879
steps:
8980
- name: Checkout
9081
uses: actions/checkout@v4
9182
with:
9283
fetch-depth: 0
93-
- uses: './.github/actions/cache'
84+
- uses: './.github/actions/setup-environment'
9485
- name: install
9586
shell: bash
9687
run: npm i
@@ -103,23 +94,22 @@ jobs:
10394
if: github.event_name == 'pull_request'
10495
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
10596
check-circular-imports:
106-
runs-on: ubuntu-latest
97+
runs-on: ubuntu-24.04
10798
needs: install
108-
steps:
99+
steps:
109100
- name: Checkout
110101
uses: actions/checkout@v4
111102
with:
112103
fetch-depth: 0
113-
- uses: './.github/actions/cache'
104+
- uses: './.github/actions/setup-environment'
105+
- uses: nrwl/nx-set-shas@v4
114106
- name: install
115107
shell: bash
116108
run: npm i
117-
- uses: nrwl/nx-set-shas@v4
118-
- uses: './.github/actions/cache'
119109
- name: Check circular imports
120110
run: npx nx affected -t test:circular-dependencies --exclude=demo
121111
release:
122-
runs-on: ubuntu-latest
112+
runs-on: ubuntu-24.04
123113
needs: [install, build, unit-test, component-test, lint, commitlint, check-circular-imports]
124114
if: github.event_name != 'pull_request'
125115
steps:

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

nx.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@
3232
}
3333
},
3434
"defaultBase": "origin/master",
35+
"namedInputs": {
36+
"default": ["{projectRoot}/**/*", "sharedGlobals"],
37+
"production": [
38+
"default",
39+
"!{projectRoot}/.eslintrc.json",
40+
"!{projectRoot}/eslint.config.js",
41+
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
42+
"!{projectRoot}/tsconfig.spec.json",
43+
"!{projectRoot}/jest.config.[jt]s",
44+
"!{projectRoot}/src/test-setup.[jt]s",
45+
"!{projectRoot}/test-setup.[jt]s"
46+
],
47+
"sharedGlobals": []
48+
},
3549
"plugins": [
3650
{
3751
"plugin": "@nx/eslint/plugin",
@@ -80,6 +94,33 @@
8094
}
8195
}
8296
],
97+
"release": {
98+
"projects": ["packages/*"],
99+
"projectsRelationship": "independent",
100+
"version": {
101+
"git": {
102+
"commit": true,
103+
"tag": true,
104+
"push": true,
105+
"commitMessage": "chore(release): publish\n\n{releaseNotes}"
106+
},
107+
"preVersionCommand": "npx nx run-many -t build --exclude=demo,",
108+
"conventionalCommits": true,
109+
"preserveLocalDependencyProtocols": false,
110+
"versionActionsOptions": {
111+
"skipLockFileUpdate": false
112+
},
113+
"manifestRootsToUpdate": [
114+
"{projectRoot}",
115+
"{projectRoot}/dist"
116+
]
117+
},
118+
"changelog": {
119+
"workspaceChangelog": false,
120+
"projectChangelogs": false
121+
},
122+
"releaseTagPattern": "{projectName}-{version}"
123+
},
83124
"generators": {
84125
"@nx/react": {
85126
"application": {

0 commit comments

Comments
 (0)