Skip to content

Commit 6a2abf2

Browse files
ci: add integration tests
Integration tests run in the CI and check if the demo application builds with the versions of @ngrx/signals as defined in the package.json.
1 parent 80ccc52 commit 6a2abf2

File tree

6 files changed

+70
-3
lines changed

6 files changed

+70
-3
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ jobs:
1717
cache: 'npm'
1818
- run: npm i
1919
- run: npm run build:all
20+
- run: ./integration-tests.sh
2021

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ Thumbs.db
4040

4141
.nx/cache
4242
.angular
43+
/versions.txt

integration-tests.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# This uses different NgRx versions and verifies that the demo app builds.
4+
5+
set -e
6+
7+
echo 'checking against different @ngrx/signals versions'
8+
9+
./read-supported-versions.js
10+
11+
i=0
12+
while read line
13+
do
14+
versions[$i]="$line"
15+
i=$((i+1))
16+
done < versions.txt
17+
18+
for version in ${versions[*]}; do
19+
npm i @ngrx/signals@$version
20+
echo "Building with version $version"
21+
npx nx build --project demo
22+
done

libs/ngrx-toolkit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/angular-architects/ngrx-toolkit"
88
},
99
"peerDependencies": {
10-
"@ngrx/signals": "18.0.0-rc.1 || 18.0.0-rc.2"
10+
"@ngrx/signals": "18.0.0-rc.2"
1111
},
1212
"dependencies": {
1313
"tslib": "^2.3.0"

nx.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,5 @@
7979
"@nx/angular:component": {
8080
"style": "css"
8181
}
82-
},
83-
"nxCloudAccessToken": "MDc5ZjM0OWMtZGJkZC00YWRjLWFjOTctYzYzMDc4MDUyMjkwfHJlYWQtd3JpdGU="
82+
}
8483
}

read-supported-versions.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Reads the supported versions of @ngrx/signals from the package.json and saves
5+
* them into a file, which is then consumed by the integrations tests.
6+
*/
7+
8+
const fs = require('fs');
9+
const path = require('path');
10+
const os = require('os');
11+
12+
// Define the path to the package.json file
13+
const packageJsonPath = path.join(
14+
__dirname,
15+
'libs/ngrx-toolkit',
16+
'package.json'
17+
);
18+
// Define the path for the output file
19+
const outputPath = path.join(__dirname, 'versions.txt');
20+
21+
// Read the package.json file
22+
fs.readFile(packageJsonPath, 'utf8', (err, data) => {
23+
if (err) {
24+
console.error('Error reading package.json:', err);
25+
return;
26+
}
27+
28+
// Parse the JSON content
29+
const packageJson = JSON.parse(data);
30+
31+
// Extract dependencies
32+
const peerDependencies = packageJson.peerDependencies;
33+
if (!peerDependencies?.['@ngrx/signals']) {
34+
throw new Error('Could not find @ngrx/signals in peerDependencies');
35+
}
36+
37+
const versions =
38+
peerDependencies['@ngrx/signals']
39+
.split('||')
40+
.map((version) => version.trim())
41+
.join(os.EOL) + os.EOL;
42+
43+
fs.writeFileSync(outputPath, versions);
44+
});

0 commit comments

Comments
 (0)