Skip to content

Commit

Permalink
update node version (v18, v20, v22) (#833)
Browse files Browse the repository at this point in the history
* chore: move from ts-node to swc-loader

fix: integration tests

fix: use swc for both v18 & v20

refactor: remove ts-node

* ci: update CI to run tests for v18,v20,v22

fix: matrix on tests only

chore: no parallelism

ci: add node version 22

* fix: several tests & mocks

test: fix mocked socket

test: update thrown error message

fix: update mocks

fix: flaky test

tests: load package.json via fs

* fix: resolve mock-fs

fix: update mock-fs

tests: update override adaptor tests to use tmp-dir

test: fix collections test

* test: collection tests & flaky test

* tests: fix date output in integration test

* set node 22 and setup corepack on pnpm8

* update integration test matrix and use corepack

* fix yaml

* fix ndoe versions

* worker: bump image to node 22

* cli: type fix

* compiler: update test fixture with trivial diff

* tests: tweak test matrix

* runtime: await module import properly

* cli: fix failing unit test

* cli: skipped tests that are broken by mock fs

* cli: try to make docgen test a bit more stable in CI

Or at least fail better

* cli: another attempt to stabilze docgen

* cli: give up and skip the flaky test

* cli: skip another flaky test

* tests: remove logging

* compiler: remove .only

* versions: [email protected] [email protected]

* worker: fix version number output

* version: @openfn/[email protected]

* worker: typing

* worker: fix package.json resolution

* worker: typings

* engine: update package json importer

* version: [email protected]

---------

Co-authored-by: Joe Clark <[email protected]>
  • Loading branch information
doc-han and josephjclark authored Dec 20, 2024
1 parent 5b3e3e9 commit 93cdaaa
Show file tree
Hide file tree
Showing 73 changed files with 2,554 additions and 2,696 deletions.
32 changes: 21 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ 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:22.12
resource_class: medium
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- run:
name: Install pnpm
command: sudo corepack enable && corepack prepare [email protected] --activate
command: sudo corepack enable
- checkout
- restore_cache:
# See the configuration reference documentation for more details on using restore_cache and save_cache steps
Expand All @@ -35,7 +35,7 @@ jobs:

build:
docker:
- image: cimg/node:18.18
- image: cimg/node:22.12
resource_class: medium
steps:
- attach_workspace:
Expand All @@ -50,8 +50,9 @@ jobs:

unit_test:
docker:
- image: cimg/node:18.18
- image: cimg/node:22.12
resource_class: medium
parallelism: 1
steps:
- attach_workspace:
at: ~/project
Expand All @@ -61,7 +62,7 @@ jobs:

format:
docker:
- image: cimg/node:18.18
- image: cimg/node:22.12
resource_class: medium
steps:
- attach_workspace:
Expand All @@ -72,7 +73,7 @@ jobs:

type_check:
docker:
- image: cimg/node:18.18
- image: cimg/node:22.12
resource_class: medium
steps:
- attach_workspace:
Expand All @@ -83,8 +84,12 @@ jobs:

integration_test:
docker:
- image: cimg/node:18.18
- image: cimg/node:<< parameters.node_version >>
resource_class: medium
parallelism: 1
parameters:
node_version:
type: string
steps:
- attach_workspace:
at: ~/project
Expand All @@ -107,10 +112,10 @@ workflows:
build_and_test:
jobs:
- install:
filters:
branches:
ignore:
- main
filters:
branches:
ignore:
- main
- build:
requires:
- install
Expand All @@ -124,5 +129,10 @@ workflows:
requires:
- build
- integration_test:
matrix:
parameters:
# temporarily test against a range of versions while we get over teh 18x hump
# We can reduce this later
node_version: ['18.12.1', '18.18', '20.18.1', '22.12']
requires:
- build
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fetch-depth: 1
- uses: actions/setup-node@v3
with:
node-version: '18.18'
node-version: '22.12'
- uses: pnpm/action-setup@v4
with:
version: 8
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 18.12.1
nodejs 22.12.0
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine AS base
FROM node:22-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ We use [`pnpm`](https://pnpm.io/installation), a fast, disk space efficient pack

## Installing

- `$ pnpm run setup`
This repo uses node corepack to ensure pnpm v8 is used.

- `$ corepack enable`
- `$ pnpm install`
- `$ pnpm build`

## Running Tests
Expand Down
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=@swc-node/register/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
7 changes: 7 additions & 0 deletions examples/dts-inspector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# dts-inspector

## 1.0.22

### Patch Changes

- Updated dependencies
- @openfn/describe-package@0.1.4

## 1.0.21

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/dts-inspector/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dts-inspector",
"version": "1.0.21",
"version": "1.0.22",
"description": "",
"main": "index.js",
"type": "module",
Expand Down
6 changes: 5 additions & 1 deletion integration-tests/cli/ava.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import semver from "semver"

const loader_arg = semver.lte(process.version, 'v20.5.0') ? '--loader=@swc-node/register/esm' : '--import=@swc-node/register/esm-register'

export default {
extensions: {
ts: 'module',
Expand All @@ -7,7 +11,7 @@ export default {
TS_NODE_TRANSPILE_ONLY: 'true',
},

nodeArguments: ['--loader=ts-node/esm', '--no-warnings'],
nodeArguments: [loader_arg, '--no-warnings'],

files: ['test/**/*test.ts'],
};
1 change: 0 additions & 1 deletion integration-tests/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"ava": "5.3.1",
"date-fns": "^2.30.0",
"rimraf": "^3.0.2",
"ts-node": "10.8.1",
"tslib": "^2.4.0",
"typescript": "^5.1.6"
},
Expand Down
5 changes: 4 additions & 1 deletion integration-tests/cli/test/execute-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ test.serial(
t.falsy(err);

const out = getJSON();
t.deepEqual(out, { data: '01/01/2024', result: '1/1/2024, 12:00:00 AM' });
t.deepEqual(out, {
data: '01/01/2024',
result: '2024-01-01T00:00:00.000Z',
});
}
);
2 changes: 1 addition & 1 deletion integration-tests/cli/test/fixtures/common-date.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"steps": [
{
"adaptor": "common",
"expression": "fn((state) => { state.result = dateFns.parse(state.data, 'MM/dd/yyyy', new Date()).toLocaleString(); return state; })"
"expression": "fn((state) => { state.result = dateFns.parse(state.data, 'MM/dd/yyyy', new Date()).toISOString(); return state; })"
}
]
}
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"ts-node": {
"experimentalSpecifierResolution": "node"
},
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "es2020",
Expand Down
9 changes: 9 additions & 0 deletions integration-tests/execute/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @openfn/integration-tests-execute

## 1.0.12

### Patch Changes

- Updated dependencies
- Updated dependencies [8904af2]
- @openfn/compiler@0.4.3
- @openfn/runtime@1.5.4

## 1.0.11

### Patch Changes
Expand Down
6 changes: 5 additions & 1 deletion integration-tests/execute/ava.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import semver from "semver"

const loader_arg = semver.lte(process.version, 'v20.5.0') ? '--loader=@swc-node/register/esm' : '--import=@swc-node/register/esm-register'

export default {
extensions: {
ts: 'module',
Expand All @@ -7,7 +11,7 @@ export default {
TS_NODE_TRANSPILE_ONLY: 'true',
},

nodeArguments: ['--loader=ts-node/esm', '--no-warnings', '--experimental-vm-modules'],
nodeArguments: [loader_arg, '--no-warnings', '--experimental-vm-modules'],

files: ['test/**/*test.ts'],
};
3 changes: 1 addition & 2 deletions integration-tests/execute/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openfn/integration-tests-execute",
"private": true,
"version": "1.0.11",
"version": "1.0.12",
"description": "Job execution tests",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand All @@ -18,7 +18,6 @@
"ava": "5.3.1",
"date-fns": "^2.30.0",
"rimraf": "^3.0.2",
"ts-node": "10.8.1",
"tslib": "^2.4.0",
"typescript": "^5.1.6"
},
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/execute/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"ts-node": {
"experimentalSpecifierResolution": "node"
},
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "es2020",
Expand Down
24 changes: 24 additions & 0 deletions integration-tests/worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# @openfn/integration-tests-worker

## 1.0.72

### Patch Changes

- Updated dependencies
- @openfn/ws-worker@1.8.9

## 1.0.71

### Patch Changes

- Updated dependencies
- @openfn/ws-worker@1.8.8

## 1.0.70

### Patch Changes

- Updated dependencies
- @openfn/lightning-mock@2.0.27
- @openfn/engine-multi@1.4.6
- @openfn/ws-worker@1.8.7
- @openfn/logger@1.0.3

## 1.0.69

### Patch Changes
Expand Down
6 changes: 5 additions & 1 deletion integration-tests/worker/ava.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import semver from "semver"

const loader_arg = semver.lte(process.version, 'v20.5.0') ? '--loader=@swc-node/register/esm' : '--import=@swc-node/register/esm-register'

export default {
extensions: {
ts: 'module',
Expand All @@ -7,7 +11,7 @@ export default {
TS_NODE_TRANSPILE_ONLY: 'true',
},

nodeArguments: ['--loader=ts-node/esm', '--no-warnings'],
nodeArguments: [loader_arg, '--no-warnings'],

files: ['test/**/*test.ts'],
};
3 changes: 1 addition & 2 deletions integration-tests/worker/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openfn/integration-tests-worker",
"private": true,
"version": "1.0.69",
"version": "1.0.72",
"description": "Lightning WOrker integration tests",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand All @@ -25,7 +25,6 @@
"date-fns": "^2.30.0",
"koa": "^2.13.4",
"rimraf": "^3.0.2",
"ts-node": "10.8.1",
"tslib": "^2.4.0",
"typescript": "^5.1.6"
},
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/worker/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import createLightningServer, { toBase64 } from '@openfn/lightning-mock';
import createEngine from '@openfn/engine-multi';
import createWorkerServer from '@openfn/ws-worker';
import { createMockLogger } from '@openfn/logger';
// import createLogger from '@openfn/logger';
import createLogger from '@openfn/logger';

export const randomPort = () => Math.round(2000 + Math.random() * 1000);

Expand Down Expand Up @@ -39,8 +39,8 @@ export const initWorker = async (
});

const worker = createWorkerServer(engine, {
logger: createMockLogger(),
// logger: createLogger('worker', { level: 'debug' }),
// logger: createMockLogger(),
logger: createLogger('worker', { level: 'debug' }),
port: workerPort,
lightning: `ws://localhost:${lightningPort}/worker`,
secret: crypto.randomUUID(),
Expand Down
1 change: 0 additions & 1 deletion integration-tests/worker/test/runs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const humanMb = (sizeInBytes: number) => Math.round(sizeInBytes / 1024 / 1024);
const run = async (t, attempt) => {
return new Promise<any>(async (done, reject) => {
lightning.on('step:complete', ({ payload }) => {
console.log(payload);
t.is(payload.reason, 'success');

// TODO friendlier job names for this would be nice (rather than run ids)
Expand Down
Loading

0 comments on commit 93cdaaa

Please sign in to comment.