Skip to content

Commit ca64f80

Browse files
cubapCopilotthehabes
authored
Migrate tests to node:test and update CI (#273)
* Migrate tests to node:test and update CI Replace Jest-based test setup with native node:test/assert and update CI. Tests were refactored to use node:test and node:assert (many __tests__ updated), new auth token unit tests added, and routes_mounted.test.js reworked to a data-driven style. The database mock was rewritten to remove Jest-specific APIs and provide a lightweight mock/registry with resetMocks; jest.config.js was removed. GitHub Actions workflows now separate install, test (npm run test:ci) and coverage (npm run coverage:ci) steps. package.json dev tooling and test scripts were adjusted accordingly, and test bootstrap/loader/coverage artifacts were added while placeholder .txt test files were removed. * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Delete coverage-inventory.json * rebranch * Update cd_dev.yaml * Update cd_prod.yaml * hotfix the search test * Update structural validation + sync strategy in __tests__/openapi_sync_artifacts.test.js * dedup test runs on prod * Bug fixes and tests for critical functionality * critical functionality tests * These no longer need the create step for testing * These no longer need the create step for testing * Fix exclusion flag * cleanup * update start script to avoid dotenv dependency * Line up contract. Add HEAD tests because contract requires them. * load env * last bit of cleanup and bolstering * Coverage (#274) * Add middleware for PATCH override support Introduce createPatchOverrideMiddleware in rest.js to centralize validation of X-HTTP-Method-Override for POST-to-PATCH requests. Replace duplicated inline checks in routes/patchSet.js, routes/patchUnset.js, and routes/patchUpdate.js with the new middleware (each using a route-specific statusMessage). Also standardize error handling by ending 405 responses with res.status(405).end() and export the new middleware from rest.js. * End 405 responses and add route wrapper tests Replace patterns that set status and call next(res) with res.status(405).end() in route fallbacks (routes/query.js, routes/release.js, routes/search.js) to ensure the response is terminated immediately. Add route wrapper tests (routes/__tests__/route_wrappers.test.js) to validate method-override handling, unsupported-method fallbacks, client verify behavior, and API discovery. Include a test coverage inventory (test/coverage-inventory.json) to record current test/coverage state. * End responses for unsupported-method handlers Replace next(res) with res.status(405).end() in multiple route fallbacks to ensure responses are terminated immediately (bulkCreate, bulkUpdate, create, delete, history, id, overwrite, putUpdate, since). Update route wrapper tests to import additional routers, add helper asserting fallback behavior on specific paths, and add tests for static/index handlers. Update test coverage inventory to reflect the new/updated tests. * Guard for bot checks. Stop releases from hanging on a tree error. * Changes from review. Reduce wording locks in tests. * last bit of cleanup from review * Introduce ecosystem file and env-loader for RHEL (#276) * Introduce ecosystem file and env-loader for RHEL * Introduce ecosystem file and env-loader for RHEL * changes from testing * cmon RHEL * back to 500M * 100% coverage * Changes during review * test: lock down secret name and cp target in sync workflow tests Adds two regex assertions to each sync-artifact test: - secrets.OPENAPI must appear verbatim (catches a rename that would silently break the receiver checkout step at runtime) - the literal 'cp source target' line must point at the expected paths (already covered for provider sync; now mirrored on shared sync) Backports improvements developed during TinyNode's parallel sync test where the same regression class actually bit us this week. * chore: align RERUM sync workflows with TinyNode/TinyPen pattern - bump peter-evans/create-pull-request v7 -> v8 - rename receiver checkout path rerum_openapi -> receiver - add `add-paths`, explicit `base: main`, `ref: main` on receiver checkout - add `test -f` verify-stub guard on both workflows (receiver stubs exist) - branch naming automation/sync-rerum-* -> sync/rerum-* - commit-message/title gain `chore:` prefix - PR body now matches the bullet-list format used by TinyNode and TinyPen - update tests to use `path:\s*receiver`, `@v\d+`, and new cp target regex * Remove claude from authorship lines. Move contracts/ under openapi/contracts like other repos for consistency --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Bryan Haberberger <bryan.j.haberberger@slu.edu>
1 parent b4e7efd commit ca64f80

81 files changed

Lines changed: 3476 additions & 6225 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cd_dev.yaml

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,18 @@ on:
33
pull_request:
44
branches: main
55
jobs:
6-
merge-branch:
7-
runs-on: ubuntu-latest
8-
steps:
9-
- uses: actions/checkout@master
10-
- name: Merge with main
11-
uses: devmasx/merge-branch@master
12-
with:
13-
type: now
14-
from_branch: main
15-
target_branch: ${{ github.head_ref }}
16-
github_token: ${{ secrets.OPENAPI }}
17-
message: Merge main into this branch to deploy to dev for testing.
186
test:
19-
needs: merge-branch
207
runs-on: ubuntu-latest
218
steps:
22-
- uses: actions/checkout@master
9+
- uses: actions/checkout@v4
2310
- name: Create .env from secrets
2411
run: echo "${{ secrets.DEV_FULL_ENV }}" > .env
2512
- name: Setup Node.js
26-
uses: actions/setup-node@master
13+
uses: actions/setup-node@v4
2714
with:
2815
node-version: "24"
2916
- name: Cache node modules
30-
uses: actions/cache@master
17+
uses: actions/cache@v4
3118
env:
3219
cache-name: cache-node-modules
3320
with:
@@ -38,14 +25,13 @@ jobs:
3825
${{ runner.os }}-build-${{ env.cache-name }}-
3926
${{ runner.os }}-build-
4027
${{ runner.os }}-
41-
- name: Install dependencies and run the test
42-
run: |
43-
npm install
44-
npm run runtest
28+
- name: Install dependencies
29+
run: npm install
30+
- name: Generate coverage report
31+
run: npm run coverage:ci
4532
deploy:
4633
if: github.event.pull_request.draft == false
4734
needs:
48-
- merge-branch
4935
- test
5036
strategy:
5137
matrix:
@@ -55,7 +41,7 @@ jobs:
5541
- vlcdhp02
5642
runs-on: ${{ matrix.machines }}
5743
steps:
58-
- uses: actions/checkout@master
44+
- uses: actions/checkout@v4
5945
- name: Deploy the app on the server
6046
run: |
6147
if [[ ! -e /srv/node/logs/rerumv1.txt ]]; then
@@ -70,4 +56,4 @@ jobs:
7056
git stash
7157
git pull
7258
npm install
73-
pm2 start -i max bin/rerum_v1.js
59+
pm2 startOrReload ecosystem.config.json --env development

.github/workflows/cd_prod.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@master
9+
- uses: actions/checkout@v4
1010
- name: Create .env from secrets
1111
run: echo "${{ secrets.PROD_FULL_ENV }}" > .env
1212
- name: Setup Node.js
13-
uses: actions/setup-node@master
13+
uses: actions/setup-node@v4
1414
with:
1515
node-version: "24"
1616

1717
# Speed up subsequent runs with caching
1818
- name: Cache node modules
19-
uses: actions/cache@master
19+
uses: actions/cache@v4
2020
env:
2121
cache-name: cache-node-modules
2222
with:
@@ -27,10 +27,10 @@ jobs:
2727
${{ runner.os }}-build-${{ env.cache-name }}-
2828
${{ runner.os }}-build-
2929
${{ runner.os }}-
30-
- name: Install dependencies and run the test
31-
run: |
32-
npm install
33-
npm run runtest
30+
- name: Install dependencies
31+
run: npm install
32+
- name: Generate coverage report
33+
run: npm run coverage:ci
3434
deploy:
3535
needs: test
3636
strategy:
@@ -41,7 +41,7 @@ jobs:
4141
- vlcdhprdp02
4242
runs-on: ${{ matrix.machines }}
4343
steps:
44-
- uses: actions/checkout@master
44+
- uses: actions/checkout@v4
4545
- name: Deploy the app on the server
4646
run: |
4747
if [[ ! -e /srv/node/logs/rerumv1.txt ]]; then
@@ -55,4 +55,4 @@ jobs:
5555
git stash
5656
git pull
5757
npm install
58-
pm2 start -i max bin/rerum_v1.js
58+
pm2 startOrReload ecosystem.config.json --env production
Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,53 @@
1-
name: Sync Core Provider Contract
1+
name: Sync RERUM core provider contract
22

33
on:
4-
workflow_dispatch:
54
push:
65
branches:
76
- main
87
paths:
9-
- contracts/core-provider.openapi.yaml
8+
- openapi/contracts/core-provider.openapi.yaml
109
- routes/**
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
1114

1215
jobs:
13-
sync-core-provider-contract:
16+
sync:
17+
name: Sync RERUM core provider contract
1418
runs-on: ubuntu-latest
15-
permissions:
16-
contents: read
1719
steps:
18-
- name: Checkout source repository
20+
- name: Checkout rerum_server_nodejs
1921
uses: actions/checkout@v4
2022

21-
- name: Checkout rerum_openapi
23+
- name: Checkout receiver repository
2224
uses: actions/checkout@v4
2325
with:
2426
repository: cubap/rerum_openapi
27+
ref: main
2528
token: ${{ secrets.OPENAPI }}
26-
path: rerum_openapi
29+
path: receiver
2730

28-
- name: Copy provider contract baseline
29-
run: |
30-
cp contracts/core-provider.openapi.yaml rerum_openapi/seams/tinynode-to-rerum/openapi/baseline.openapi.yaml
31+
- name: Verify receiver stub exists
32+
run: test -f receiver/seams/tinynode-to-rerum/openapi/baseline.openapi.yaml
3133

32-
- name: Create sync pull request
33-
uses: peter-evans/create-pull-request@v7
34+
- name: Copy canonical provider contract
35+
run: cp openapi/contracts/core-provider.openapi.yaml receiver/seams/tinynode-to-rerum/openapi/baseline.openapi.yaml
36+
37+
- name: Create or update sync pull request
38+
uses: peter-evans/create-pull-request@v8
3439
with:
3540
token: ${{ secrets.OPENAPI }}
36-
path: rerum_openapi
37-
branch: automation/sync-rerum-core-provider-contract
41+
path: receiver
42+
add-paths: seams/tinynode-to-rerum/openapi/baseline.openapi.yaml
43+
commit-message: "chore: sync RERUM core provider contract"
44+
branch: sync/rerum-core-provider-contract
45+
base: main
3846
delete-branch: true
39-
commit-message: Sync RERUM core provider contract from rerum_server_nodejs
40-
title: Sync RERUM core provider contract from rerum_server_nodejs
47+
title: "chore: sync RERUM core provider contract"
4148
body: |
42-
Automated sync from `${{ github.repository }}` at `${{ github.sha }}`.
43-
44-
Source:
45-
- `contracts/core-provider.openapi.yaml`
49+
Syncs the canonical RERUM core provider contract from CenterForDigitalHumanities/rerum_server_nodejs.
4650
47-
Target:
48-
- `seams/tinynode-to-rerum/openapi/baseline.openapi.yaml`
51+
- Source commit: ${{ github.sha }}
52+
- Source artifact: `openapi/contracts/core-provider.openapi.yaml`
53+
- Target artifact: `seams/tinynode-to-rerum/openapi/baseline.openapi.yaml`
Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Sync shared RERUM OpenAPI artifact
1+
name: Sync RERUM shared OpenAPI artifact
22

33
on:
44
push:
@@ -12,37 +12,41 @@ permissions:
1212
contents: read
1313

1414
jobs:
15-
sync-shared-openapi-artifact:
15+
sync:
16+
name: Sync RERUM shared OpenAPI artifact
1617
runs-on: ubuntu-latest
1718
steps:
18-
- name: Checkout source repository
19+
- name: Checkout rerum_server_nodejs
1920
uses: actions/checkout@v4
2021

21-
- name: Checkout rerum_openapi
22+
- name: Checkout receiver repository
2223
uses: actions/checkout@v4
2324
with:
2425
repository: cubap/rerum_openapi
26+
ref: main
2527
token: ${{ secrets.OPENAPI }}
26-
path: rerum_openapi
28+
path: receiver
2729

28-
- name: Copy shared artifact
29-
run: |
30-
cp openapi/components/rerum-shared-components.openapi.yaml rerum_openapi/schemas/openapi/rerum-shared-components.openapi.yaml
30+
- name: Verify receiver stub exists
31+
run: test -f receiver/schemas/openapi/rerum-shared-components.openapi.yaml
3132

32-
- name: Create sync pull request
33-
uses: peter-evans/create-pull-request@v7
33+
- name: Copy canonical shared artifact
34+
run: cp openapi/components/rerum-shared-components.openapi.yaml receiver/schemas/openapi/rerum-shared-components.openapi.yaml
35+
36+
- name: Create or update sync pull request
37+
uses: peter-evans/create-pull-request@v8
3438
with:
3539
token: ${{ secrets.OPENAPI }}
36-
path: rerum_openapi
37-
branch: automation/sync-rerum-shared-openapi-artifact
40+
path: receiver
41+
add-paths: schemas/openapi/rerum-shared-components.openapi.yaml
42+
commit-message: "chore: sync RERUM shared OpenAPI artifact"
43+
branch: sync/rerum-shared-openapi
44+
base: main
3845
delete-branch: true
39-
commit-message: Sync shared RERUM OpenAPI artifact from rerum_server_nodejs
40-
title: Sync shared RERUM OpenAPI artifact from rerum_server_nodejs
46+
title: "chore: sync RERUM shared OpenAPI artifact"
4147
body: |
42-
Automated sync from `${{ github.repository }}` at `${{ github.sha }}`.
43-
44-
Source:
45-
- `openapi/components/rerum-shared-components.openapi.yaml`
48+
Syncs the canonical RERUM shared OpenAPI artifact from CenterForDigitalHumanities/rerum_server_nodejs.
4649
47-
Target:
48-
- `schemas/openapi/rerum-shared-components.openapi.yaml`
50+
- Source commit: ${{ github.sha }}
51+
- Source artifact: `openapi/components/rerum-shared-components.openapi.yaml`
52+
- Target artifact: `schemas/openapi/rerum-shared-components.openapi.yaml`

0 commit comments

Comments
 (0)