Skip to content

Commit

Permalink
chore: use different loader for node20
Browse files Browse the repository at this point in the history
  • Loading branch information
doc-han committed Nov 29, 2024
1 parent 4376f7b commit 95f4ebc
Show file tree
Hide file tree
Showing 6 changed files with 5,094 additions and 3,676 deletions.
56 changes: 46 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ jobs:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
- image: cimg/node:18.18
- image: cimg/node:<< parameters.node_version >>
resource_class: medium
parameters:
node_version:
type: string
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
Expand All @@ -35,8 +38,11 @@ jobs:

build:
docker:
- image: cimg/node:18.18
- image: cimg/node:<< parameters.node_version >>
resource_class: medium
parameters:
node_version:
type: string
steps:
- attach_workspace:
at: ~/project
Expand All @@ -50,8 +56,11 @@ jobs:

unit_test:
docker:
- image: cimg/node:18.18
- image: cimg/node:<< parameters.node_version >>
resource_class: medium
parameters:
node_version:
type: string
steps:
- attach_workspace:
at: ~/project
Expand All @@ -61,8 +70,11 @@ jobs:

format:
docker:
- image: cimg/node:18.18
- image: cimg/node:<< parameters.node_version >>
resource_class: medium
parameters:
node_version:
type: string
steps:
- attach_workspace:
at: ~/project
Expand All @@ -72,8 +84,11 @@ jobs:

type_check:
docker:
- image: cimg/node:18.18
- image: cimg/node:<< parameters.node_version >>
resource_class: medium
parameters:
node_version:
type: string
steps:
- attach_workspace:
at: ~/project
Expand All @@ -83,8 +98,11 @@ jobs:

integration_test:
docker:
- image: cimg/node:18.18
- image: cimg/node:<< parameters.node_version >>
resource_class: medium
parameters:
node_version:
type: string
steps:
- attach_workspace:
at: ~/project
Expand All @@ -107,22 +125,40 @@ workflows:
build_and_test:
jobs:
- install:
filters:
branches:
ignore:
- main
matrix:
parameters:
node_version: ["18.18", "20.12"]
filters:
branches:
ignore:
- main
- build:
matrix:
parameters:
node_version: ["18.18", "20.12"]
requires:
- install
- unit_test:
matrix:
parameters:
node_version: ["18.18", "20.12"]
requires:
- build
- type_check:
matrix:
parameters:
node_version: ["18.18", "20.12"]
requires:
- build
- format:
matrix:
parameters:
node_version: ["18.18", "20.12"]
requires:
- build
- integration_test:
matrix:
parameters:
node_version: ["18.18", "20.12"]
requires:
- build
5 changes: 4 additions & 1 deletion ava.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const semver = require("semver")

const loader_arg = semver.lte(process.version, 'v20.5.0') ? '--loader=ts-node/esm' : '--import=@swc-node/register/esm-register'
module.exports = {
extensions: {
ts: 'module',
Expand All @@ -8,7 +11,7 @@ module.exports = {
},

nodeArguments: [
'--loader=ts-node/esm',
loader_arg,
'--no-warnings', // Disable experimental module warnings
'--experimental-vm-modules',
],
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@slack/web-api": "^6.12.1",
"@swc-node/register": "^1.10.9",
"@types/gunzip-maybe": "^1.4.0",
"@types/rimraf": "^3.0.2",
"@types/tar-stream": "^2.2.2",
"gunzip-maybe": "^1.4.2",
"prettier": "^2.8.8",
"rimraf": "^3.0.2",
"semver": "^7.5.4",
"tar-stream": "^3.0.0",
"typesync": "^0.13.0"
}
Expand Down
3 changes: 2 additions & 1 deletion packages/deploy/src/stateTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ function idKeyPairs<P extends { id: string }, S extends { id: string }>(
stateItems: Record<keyof S, S>
): [key: string, projectItem: P, stateItem: S][] {
let pairs: [string, P, S][] = [];
for (const projectItem of projectItems) {
for (let i = 0; i < projectItems.length; i++) {
const projectItem = projectItems[i];
for (const [key, stateItem] of Object.entries(stateItems)) {
if (projectItem.id === stateItem.id) {
pairs.push([key, projectItem, stateItem]);
Expand Down
24 changes: 12 additions & 12 deletions packages/ws-worker/test/api/destroy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ test.serial('destroy a worker while one run is active', async (t) => {
done();
};

lightning.once('claim', () => {
// The run should be active immediately after it's claimed
// BUT in these tests we do need a moment's grace - this event occurs
// at the lightning end and the handler in the worker may not have executed yet
setTimeout(() => {
doDestroy();
}, 2);
});

lightning.once('run:complete', () => {
didFinish = true;
});
lightning
.once('run:complete', () => {
didFinish = true;
})
.once('claim', () => {
// The run should be active immediately after it's claimed
// BUT in these tests we do need a moment's grace - this event occurs
// at the lightning end and the handler in the worker may not have executed yet
setTimeout(() => {
doDestroy();
}, 2);
});
lightning.enqueueRun(createRun());
});
});
Expand Down
Loading

0 comments on commit 95f4ebc

Please sign in to comment.