Skip to content

Commit 71bea0e

Browse files
Integration test overhaul
- New integration test guidelines and framework - Updated GitHub Actions workflow - Continue to support existing integration tests - Copious documentation and utility scripts refactor loopback address pool un-skip apiTests Update actions/checkout to v6 Co-authored-by: Chris Barber <[email protected]> revert threadServer.js debug code improve docs remove ignore existing changes - all seems to work fine now rename the files format
1 parent 067e550 commit 71bea0e

22 files changed

+1751
-81
lines changed

.github/workflows/integration-test.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Integration Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
inputs:
9+
node-version:
10+
description: 'Node.js version'
11+
required: true
12+
type: choice
13+
default: 'all'
14+
options:
15+
- 'all'
16+
- '20'
17+
- '22'
18+
- '24'
19+
20+
jobs:
21+
generate-node-version-matrix:
22+
name: Generate Node Version Matrix
23+
runs-on: ubuntu-latest
24+
outputs:
25+
node-versions: ${{ steps.set-node-versions.outputs.node-versions }}
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v6
30+
31+
- name: Set Node versions
32+
id: set-node-versions
33+
run: |
34+
if [ "${{ github.event.inputs.node-version }}" == "all" ] || [ -z "${{ github.event.inputs.node-version }}" ]; then
35+
echo "node-versions=[20, 22, 24]" >> $GITHUB_OUTPUT
36+
else
37+
echo "node-versions=[${{ github.event.inputs.node-version }}]" >> $GITHUB_OUTPUT
38+
fi
39+
40+
build:
41+
name: Build Harper (Node.js v${{ matrix.node-version }})
42+
needs: generate-node-version-matrix
43+
runs-on: ubuntu-latest
44+
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
node-version: ${{ fromJSON(needs.generate-node-version-matrix.outputs.node-versions) }}
49+
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v6
53+
54+
- name: Setup Node.js ${{ matrix.node-version }}
55+
uses: actions/setup-node@v6
56+
with:
57+
node-version: ${{ matrix.node-version }}
58+
package-manager-cache: false
59+
60+
- name: Install dependencies
61+
run: npm install
62+
63+
- name: Build
64+
run: npm run build || true # we currently have type errors so just ignore that
65+
66+
- name: Upload build artifacts
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: harper-build-artifacts-node-${{ matrix.node-version }}
70+
path: |
71+
dist/
72+
static/
73+
node_modules/
74+
package.json
75+
retention-days: 1
76+
77+
run-integration-apiTests:
78+
name: Integration API Tests (Node.js v${{ matrix.node-version }})
79+
needs: [generate-node-version-matrix, build]
80+
runs-on: ubuntu-latest
81+
82+
strategy:
83+
fail-fast: false
84+
matrix:
85+
node-version: ${{ fromJSON(needs.generate-node-version-matrix.outputs.node-versions) }}
86+
87+
steps:
88+
- name: Checkout code
89+
uses: actions/checkout@v6
90+
91+
- name: Setup Node.js ${{ matrix.node-version }}
92+
uses: actions/setup-node@v6
93+
with:
94+
node-version: ${{ matrix.node-version }}
95+
package-manager-cache: false
96+
97+
- name: Download build artifacts
98+
uses: actions/download-artifact@v4
99+
with:
100+
name: harper-build-artifacts-node-${{ matrix.node-version }}
101+
102+
- name: Setup Harper
103+
env:
104+
DEFAULTS_MODE: 'dev'
105+
HDB_ADMIN_USERNAME: 'admin'
106+
HDB_ADMIN_PASSWORD: 'password'
107+
ROOTPATH: '/tmp/hdb'
108+
OPERATIONSAPI_NETWORK_PORT: 9925
109+
LOGGING_LEVEL: 'debug'
110+
LOGGING_STDSTREAMS: true
111+
THREADS_COUNT: 1
112+
THREADS_DEBUG: false
113+
NODE_HOSTNAME: 'localhost'
114+
run: |
115+
node ./dist/bin/harper.js install
116+
sleep 10
117+
node ./dist/bin/harper.js start
118+
sleep 10
119+
120+
- name: Run API Tests
121+
id: run-api-tests
122+
env:
123+
HDB_ADMIN_USERNAME: 'admin'
124+
HDB_ADMIN_PASSWORD: 'password'
125+
run: npm run test:integration:api-tests
126+
127+
- name: Upload Harper logs
128+
if: steps.run-api-tests.outcome == 'failure'
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: harper-integration-api-test-logs-node-${{ matrix.node-version }}
132+
path: /tmp/hdb/log/hdb.log
133+
retention-days: 2
134+
135+
run-integration-tests:
136+
name: Integration Tests ${{matrix.shard}}/4 (Node.js v${{ matrix.node-version }})
137+
runs-on: ubuntu-latest
138+
needs: [generate-node-version-matrix, build]
139+
strategy:
140+
fail-fast: false
141+
matrix:
142+
node-version: ${{ fromJSON(needs.generate-node-version-matrix.outputs.node-versions) }}
143+
shard: [1, 2, 3, 4]
144+
exclude:
145+
- node-version: 20
146+
147+
steps:
148+
- name: Checkout code
149+
uses: actions/checkout@v6
150+
151+
- name: Setup Node.js ${{ matrix.node-version }}
152+
uses: actions/setup-node@v6
153+
with:
154+
node-version: ${{ matrix.node-version }}
155+
package-manager-cache: false
156+
157+
- name: Download build artifacts
158+
uses: actions/download-artifact@v4
159+
with:
160+
name: harper-build-artifacts-node-${{ matrix.node-version }}
161+
162+
- name: Run Integration Test Shard ${{ matrix.shard }}
163+
run: |
164+
npm run test:integration -- --shard=${{ matrix.shard }}/4

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Install dependencies using `npm install`
1515

1616
Build the project using `npm run build` or `npm run build:watch` to automatically rebuild on file changes.
1717

18-
Run integration tests using `npm run test:integration`. Make sure to read the [integration test instructions](./integrationTests/apiTests/README.md) for setup.
18+
Run integration tests using `npm run test:integration`. Make sure to read the [integration test instructions](./integrationTests/README.md) for setup requirements (particularly the loopback address configuration).
1919

2020
Run unit tests using `npm run test:unit <unit-test-file>` or `npm run test:unit:all`, but make sure to build the project first since unit tests depend on the built source files.
2121

eslint.config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ export default defineConfig([
4545
rules: {},
4646
},
4747

48+
{
49+
files: ['**/*.test.{ts,mts}'],
50+
rules: {
51+
// Allow floating promises in test files for async test functions
52+
'@typescript-eslint/no-floating-promises': {
53+
allowForKnownSafePromises: [{ from: 'node:test', names: ['describe', 'it', 'suite', 'test'] }],
54+
},
55+
},
56+
},
57+
4858
// Disable conflicting ESLint formatting rules
4959
// Prettier formatting is only enforced via `npm run format:check` and editor integrations
5060
// More information here: https://prettier.io/docs/integrating-with-linters.html

0 commit comments

Comments
 (0)