Skip to content

Commit 2e6950d

Browse files
feat: node:test (#2413)
* code * code * ran generate script * lint * fix ci * fix sharding * fix broken tests * test with 3 shards * test with 4 shards * no sharding run * fix no sharding ci * try again with 100% * fix * enable shards back * test complete * c8
1 parent fd45da2 commit 2e6950d

File tree

270 files changed

+4377
-6168
lines changed

Some content is hidden

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

270 files changed

+4377
-6168
lines changed

.github/workflows/publish-auto.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
publish:
1111
runs-on: ubuntu-latest
12-
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
12+
if: ${{ !contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci') }}
1313

1414
name: Make a release and publish to NPM
1515
steps:

.github/workflows/test.yml

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test
1+
name: CI
22

33
on:
44
push:
@@ -8,14 +8,41 @@ on:
88
branches:
99
- next
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
1115
jobs:
16+
build:
17+
name: Build
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v6
22+
23+
- uses: actions/setup-node@v6
24+
with:
25+
node-version: 22
26+
cache: "npm"
27+
28+
- name: Install Node dependencies
29+
run: npm ci
30+
31+
- name: Lint
32+
run: npm run lint
33+
34+
- name: Build
35+
run: npm run build
36+
1237
test:
13-
name: Test
38+
name: Test ${{ matrix.shard }}/4 (${{ matrix.os }})
39+
needs: build
1440

1541
strategy:
1642
fail-fast: false
1743
matrix:
1844
os: [ubuntu-latest, windows-latest]
45+
shard: [1, 2, 3, 4]
1946

2047
runs-on: ${{ matrix.os }}
2148

@@ -30,14 +57,29 @@ jobs:
3057
- name: Install Node dependencies
3158
run: npm ci
3259

33-
- name: Lint
34-
run: npm run lint
35-
3660
- name: Build
3761
run: npm run build
3862

39-
- name: Test coverage
40-
run: npx jest test/ --collectCoverage=true
63+
- name: Test coverage # node uses os.availableParallelism()-1 by default
64+
run: npm run test:coverage -- --test-concurrency=$(node -e 'console.log(os.availableParallelism())')
65+
env: # somehow using test shard as params didn't work
66+
NODE_OPTIONS: "--test-shard=${{ matrix.shard }}/4"
4167

4268
- name: Upload coverage to Codecov
4369
uses: codecov/codecov-action@v5
70+
71+
# This job aggregates all test results to have a simpler branch protection check
72+
test-complete:
73+
name: Tests Complete
74+
needs: test
75+
runs-on: ubuntu-latest
76+
if: always()
77+
78+
steps:
79+
- name: Check test matrix status
80+
run: |
81+
if [ "${{ needs.test.result }}" != "success" ]; then
82+
echo "Tests failed or were cancelled"
83+
exit 1
84+
fi
85+
echo "All tests passed successfully"

factory/program.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { globSync } from "glob";
12
import * as path from "node:path";
23
import normalize from "normalize-path";
4+
import type { CompilerOptions } from "typescript";
35
import ts from "typescript";
46
import type { CompletedConfig, Config } from "../src/Config.js";
57
import { BuildError } from "../src/Error/Errors.js";
6-
import { globSync } from "glob";
78

89
function loadTsConfigFile(configFile: string) {
910
const raw = ts.sys.readFile(configFile);
@@ -55,10 +56,13 @@ function getTsConfig(config: Config) {
5556
noEmit: true,
5657
emitDecoratorMetadata: true,
5758
experimentalDecorators: true,
58-
target: ts.ScriptTarget.ES5,
59+
target: ts.ScriptTarget.ES2022,
5960
module: ts.ModuleKind.CommonJS,
6061
strictNullChecks: false,
61-
},
62+
skipLibCheck: true,
63+
skipDefaultLibCheck: true,
64+
esModuleInterop: true,
65+
} satisfies CompilerOptions,
6266
};
6367
}
6468

0 commit comments

Comments
 (0)