Skip to content

Commit 02aee9c

Browse files
authored
Maintenance tasks (#1950)
* tweak test concurrency options * update CI config and test matrix * Further optimization * name all steps in CI; fix node version check for new nightly format * More CI maint * upgrade yarn, fix cache issue when installing from tarball into ./tests/node_modules * Fix swc bug, since swc supports `target: esnext` now * Fix test failure due to new TS's `allowImportingTsExtensions` diagnostic * update yarn lockfile * bump another gh action version * Fix allImportingTsExtensions test * Fix another test failure due to allImportingTsExtensions * remove duplicated tests * Fix failing @tsconfig/bases test * fmt * cleanup previous fix, and fix diagnostic test failing on 4.2 * make it less flaky? * improve some tests to be faster, rely less on long pauses which fail on CI * fix failing repl tests * oops
1 parent 8b09d49 commit 02aee9c

26 files changed

+1222
-1201
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 44 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,31 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
# checkout code
21-
- uses: actions/checkout@v2
21+
- name: Checkout
22+
uses: actions/checkout@v3
2223
# install node
2324
- name: Use Node.js 18
24-
uses: actions/setup-node@v1
25+
uses: actions/setup-node@v3
2526
with:
2627
node-version: 18
2728
- name: Get cache directory
2829
id: get-cache-directory
2930
run: |
3031
yarn config get cacheFolder
31-
echo "::set-output name=path::$( yarn config get cacheFolder )"
32+
echo "path=$( yarn config get cacheFolder )" >> $GITHUB_OUTPUT
3233
- name: Cache dependencies
33-
uses: actions/cache@v2
34+
uses: actions/cache@v3
3435
with:
3536
path: ${{ steps.get-cache-directory.outputs.path }}
3637
key: yarn-cache-packaging-${{ hashFiles('yarn.lock') }}
3738
restore-keys: yarn-cache-packaging-
3839
# lint, build, test
39-
- run: yarn install --immutable
40-
- run: yarn lint
41-
- run: yarn build
40+
- name: Install dependencies
41+
run: yarn install --immutable
42+
- name: Lint
43+
run: yarn lint
44+
- name: Build
45+
run: yarn build
4246
- name: Upload package artifact
4347
uses: actions/upload-artifact@v1
4448
with:
@@ -57,145 +61,88 @@ jobs:
5761
matrix:
5862
os: [ubuntu, windows]
5963
# Don't forget to add all new flavors to this list!
60-
flavor: [2, 3, 4, 6, 8, 9, 10, 11]
64+
flavor: [1, 2, 3, 4, 5]
6165
include:
62-
# Node 14.13.0
63-
# To test ESM builtin module resolution immediately before a node behavioral change: https://github.com/TypeStrong/ts-node/issues/1130
64-
# - flavor: 1
65-
# node: 14.13.0
66-
# nodeFlag: 14_13_0
67-
# typescript: latest
68-
# typescriptFlag: latest
69-
# Node 14
70-
- flavor: 2
71-
node: 14
72-
nodeFlag: 14
73-
typescript: latest
74-
typescriptFlag: latest
75-
- flavor: 3
76-
node: 14
77-
nodeFlag: 14
78-
typescript: 4.0
79-
typescriptFlag: 4_0
80-
- flavor: 4
81-
node: 14
82-
nodeFlag: 14
83-
typescript: next
84-
typescriptFlag: next
8566
# Node 16
86-
# Node 16.11.1
87-
# Earliest version that supports old ESM Loader Hooks API: https://github.com/TypeStrong/ts-node/pull/1522
88-
# - flavor: 5
89-
# node: 16.11.1
90-
# nodeFlag: 16_11_1
91-
# typescript: latest
92-
# typescriptFlag: latest
93-
- flavor: 6
67+
- flavor: 1
9468
node: 16
9569
nodeFlag: 16
9670
typescript: latest
9771
typescriptFlag: latest
98-
downgradeNpm: true
99-
# - flavor: 7
100-
# node: 16
101-
# nodeFlag: 16
102-
# typescript: 4.0
103-
# typescriptFlag: 4_0
104-
# downgradeNpm: true
105-
- flavor: 8
72+
- flavor: 2
10673
node: 16
10774
nodeFlag: 16
108-
typescript: next
109-
typescriptFlag: next
110-
downgradeNpm: true
75+
typescript: 4.2
76+
typescriptFlag: 4_2
11177
# Node 18
112-
- flavor: 9
78+
- flavor: 3
11379
node: 18
11480
nodeFlag: 18
11581
typescript: latest
11682
typescriptFlag: latest
117-
downgradeNpm: true
118-
- flavor: 10
83+
- flavor: 4
11984
node: 18
12085
nodeFlag: 18
12186
typescript: next
12287
typescriptFlag: next
123-
downgradeNpm: true
12488
# Node nightly
125-
- flavor: 11
126-
node: nightly
127-
nodeFlag: nightly
89+
- flavor: 5
90+
node: 19-nightly
91+
nodeFlag: 19_nightly
12892
typescript: latest
12993
typescriptFlag: latest
130-
downgradeNpm: true
13194
steps:
13295
# checkout code
133-
- uses: actions/checkout@v2
96+
- name: Checkout
97+
uses: actions/checkout@v3
13498
# install node
13599
- name: Use Node.js ${{ matrix.node }}
136-
if: matrix.node != 'nightly'
137-
uses: actions/setup-node@v1
100+
uses: actions/setup-node@v3
138101
with:
139102
node-version: ${{ matrix.node }}
140-
- name: Use Node.js 16, will be subsequently overridden by download of nightly
141-
if: matrix.node == 'nightly'
142-
uses: actions/setup-node@v1
143-
with:
144-
node-version: 16
145-
- name: Download Node.js nightly
146-
if: matrix.node == 'nightly' && matrix.os == 'ubuntu'
147-
run: |
148-
export N_PREFIX=$(pwd)/n
149-
npm install -g n
150-
n nightly
151-
sudo cp "${N_PREFIX}/bin/node" "$(which node)"
152-
node --version
153-
- name: Download Node.js nightly
154-
if: matrix.node == 'nightly' && matrix.os == 'windows'
155-
run: |
156-
$version = (Invoke-WebRequest https://nodejs.org/download/nightly/index.json | ConvertFrom-json)[0].version
157-
$url = "https://nodejs.org/download/nightly/$version/win-x64/node.exe"
158-
$targetPath = (Get-Command node.exe).Source
159-
Invoke-WebRequest -Uri $url -OutFile $targetPath -UserAgent ([Microsoft.PowerShell.Commands.PSUserAgent]::Chrome)
160-
node --version
161103
# lint, build, test
162104
- name: Get cache directory
163105
id: get-cache-directory
164106
run: |
165107
yarn config get cacheFolder
166-
echo "::set-output name=path::$( yarn config get cacheFolder )"
108+
echo "path=$( yarn config get cacheFolder )" >> $GITHUB_OUTPUT
167109
- name: Cache dependencies
168110
if: ${{ matrix.os != 'windows' }}
169-
uses: actions/cache@v2
111+
uses: actions/cache@v3
170112
with:
171113
path: ${{ steps.get-cache-directory.outputs.path }}
172114
key: yarn-cache-${{ matrix.os }}-${{ hashFiles('yarn.lock') }}
173115
restore-keys: yarn-cache-${{matrix.os }}-
174-
- run: yarn install --immutable --mode=skip-build
175-
- name: Upload yarn logs
176-
if: ${{ failure() }}
177-
uses: actions/upload-artifact@v1
178-
with:
179-
name: yarn-logs
180-
path: yarn-error.log
181-
- run: yarn build-tsc
116+
- name: Install dependencies
117+
run: yarn install --immutable --mode=skip-build
118+
- name: Build tests
119+
run: yarn build-tsc
182120
- name: Download package artifact
183121
uses: actions/download-artifact@v1
184122
with:
185123
name: ts-node-packed.tgz
186124
path: tests/
187-
- run: yarn add -D typescript@${{ matrix.typescript }}
188-
- run: yarn test-cov
189-
- name: Upload yarn logs
125+
- name: Install typescript version to test against
126+
run: yarn add -D typescript@${{ matrix.typescript }}
127+
- name: Test
128+
run: yarn test-cov
129+
- name: Check for yarn logs
130+
id: check-yarn-logs-exist
190131
if: ${{ failure() }}
132+
uses: andstor/file-existence-action@v2
133+
with:
134+
files: yarn-error.log
135+
- name: Upload yarn logs
136+
if: ${{ failure() && steps.check-yarn-logs-exist.outputs.files_exists == 'true' }}
191137
uses: actions/upload-artifact@v1
192138
with:
193139
name: yarn-logs-${{ matrix.os }}-node-${{ matrix.nodeFlag }}-typescript-${{ matrix.typescriptFlag }}
194140
path: yarn-error.log
195-
- run: yarn coverage-report
141+
- name: Coverage Report
142+
run: yarn coverage-report
196143
if: ${{ always() }}
197144
- name: Codecov
198145
if: ${{ always() }}
199-
uses: codecov/codecov-action@v1
146+
uses: codecov/codecov-action@v3
200147
with:
201148
flags: ${{ matrix.os }},node_${{ matrix.nodeFlag }},typescript_${{ matrix.typescriptFlag }}

.github/workflows/website.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
# checkout code
1313
- uses: actions/checkout@v2
1414
# install node
15-
- name: Use Node.js 14
16-
uses: actions/setup-node@v1
15+
- name: Use Node.js 18
16+
uses: actions/setup-node@v3
1717
with:
18-
node-version: 14
18+
node-version: 18
1919
# Render typedoc
2020
- run: npm install && npx typedoc
2121
# Render docusaurus and deploy website

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ npm-debug.log
1616
/yarn-error.log
1717
/.yarn/install-state.gz
1818
/tests/.yarn/install-state.gz
19+
/tests/.yarn/cache

.yarn/releases/yarn-3.2.2.cjs

Lines changed: 0 additions & 783 deletions
This file was deleted.

.yarn/releases/yarn-3.4.1.cjs

Lines changed: 873 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
enableGlobalCache: true
22

3+
nmHoistingLimits: workspaces
4+
35
nmMode: hardlinks-global
46

57
nodeLinker: node-modules
@@ -8,6 +10,4 @@ plugins:
810
- path: .yarn/plugins/@yarnpkg/plugin-compat.cjs
911
spec: .yarn/plugins/@yarnpkg/plugin-compat.cjs
1012

11-
yarnPath: .yarn/releases/yarn-3.2.2.cjs
12-
13-
nmHoistingLimits: workspaces
13+
yarnPath: .yarn/releases/yarn-3.4.1.cjs

ava.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
require: ['./src/test/remove-env-var-force-color.js'],
1818
nodeArguments: ['--loader', './src/test/test-loader.mjs', '--no-warnings'],
1919
timeout: '300s',
20-
concurrency: 1,
20+
concurrency: 4,
2121
};
2222

2323
{

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
"homepage": "https://typestrong.org/ts-node",
110110
"devDependencies": {
111111
"@microsoft/api-extractor": "^7.19.4",
112-
"@swc/core": ">=1.2.205",
113-
"@swc/wasm": ">=1.2.205",
112+
"@swc/core": ">=1.3.32",
113+
"@swc/wasm": ">=1.3.32",
114114
"@types/diff": "^4.0.2",
115115
"@types/lodash": "^4.14.151",
116116
"@types/node": "13.13.5",
@@ -175,5 +175,5 @@
175175
"node": "18.1.0",
176176
"npm": "6.14.15"
177177
},
178-
"packageManager": "yarn@3.2.2"
178+
"packageManager": "yarn@3.4.1"
179179
}

src/test/ci-node-and-ts-versions.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ test.suite('Confirm node and typescript versions on CI', (test) => {
1414
const actualVersion = process.versions.node;
1515
t.log({ expectedVersion, actualVersion });
1616
expect(expectedVersion).toBeDefined();
17-
if (expectedVersion === 'nightly') {
18-
expect(actualVersion).toMatch('nightly');
17+
const major = expectedVersion.match(/^(\d+)-nightly$/)?.[1];
18+
if (major != null) {
19+
expect(actualVersion).toMatch(new RegExp('^' + major));
20+
expect(actualVersion).toMatch('-nightly');
1921
} else {
2022
expect(semver.satisfies(actualVersion, expectedVersion)).toBe(true);
2123
}

src/test/diagnostics.spec.ts

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,44 @@ const test = context(ctxTsNode);
88
test.suite('TSError diagnostics', ({ context }) => {
99
const test = context(
1010
once(async (t) => {
11-
// Locking to es2021, because es2022 -- default in @tsconfig/bases for node18 --
12-
// changes this diagnostic to be a composite "No overload matches this call."
11+
// Locking to es2020, because:
12+
// 1) es2022 -- default in @tsconfig/bases for node18 -- changes this diagnostic
13+
// to be a composite "No overload matches this call."
14+
// 2) TS 4.2 doesn't support es2021 or higher
1315
const service = t.context.tsNodeUnderTest.create({
14-
compilerOptions: { target: 'es5', lib: ['es2021'] },
16+
compilerOptions: { target: 'es5', lib: ['es2020'] },
1517
skipProject: true,
1618
});
1719
try {
1820
service.compile('new Error(123)', 'test.ts');
1921
} catch (err) {
20-
return { service, err };
22+
return { err: err as TSError };
2123
}
22-
return { service, err: undefined };
24+
return { err: undefined };
2325
})
2426
);
2527

2628
const diagnosticCode = 2345;
2729
const diagnosticMessage =
28-
"Argument of type 'number' " +
29-
"is not assignable to parameter of type 'string'.";
30-
const diagnosticErrorMessage = `TS${diagnosticCode}: ${diagnosticMessage}`;
30+
/Argument of type '.*?' is not assignable to parameter of type 'string( \| undefined)?'./;
31+
const diagnosticErrorMessage =
32+
/TS2345: Argument of type '.*?' is not assignable to parameter of type 'string( \| undefined)?'./;
3133

32-
const cwdBefore = process.cwd();
33-
test('should throw errors', ({ log, context: { err, service } }) => {
34-
log({
35-
version: ts.version,
36-
serviceVersion: service.ts.version,
37-
cwdBefore,
38-
cwd: process.cwd(),
39-
configFilePath: service.configFilePath,
40-
config: service.config.options,
41-
});
34+
test('should throw errors', (t) => {
35+
const { err } = t.context;
4236
expect(err).toBeDefined();
43-
expect((err as Error).message).toMatch(diagnosticErrorMessage);
44-
});
45-
46-
test('should throw errors with diagnostic text', ({ context: { err } }) => {
47-
expect((err as TSError).diagnosticText).toMatch(diagnosticErrorMessage);
48-
});
49-
50-
test('should throw errors with diagnostic codes', ({ context: { err } }) => {
51-
expect((err as TSError).diagnosticCodes).toEqual([2345]);
52-
});
53-
54-
test('should throw errors with complete diagnostic information', ({
55-
context: { err },
56-
}) => {
57-
const diagnostics = (err as TSError).diagnostics;
58-
59-
expect(diagnostics).toHaveLength(1);
60-
expect(diagnostics[0]).toMatchObject({
61-
code: 2345,
62-
start: 10,
63-
length: 3,
64-
messageText: expect.stringMatching(diagnosticMessage),
37+
expect(err!).toMatchObject({
38+
message: expect.stringMatching(diagnosticErrorMessage),
39+
diagnosticText: expect.stringMatching(diagnosticErrorMessage),
40+
diagnosticCodes: [diagnosticCode],
41+
diagnostics: [
42+
{
43+
code: diagnosticCode,
44+
start: 10,
45+
length: 3,
46+
messageText: expect.stringMatching(diagnosticMessage),
47+
},
48+
],
6549
});
6650
});
6751
});

0 commit comments

Comments
 (0)