From 8bf628e5bd3674ac5e5f6cd581b5214de7979604 Mon Sep 17 00:00:00 2001 From: Shay Date: Tue, 14 Nov 2023 12:52:53 -0800 Subject: [PATCH] Bump node version to 18 (#496) * try win dns res * add dns hack to application service tests * fix unused import * update types * add note about why dns resolution order is necessary --- .github/workflows/mjolnir.yml | 12 ++++++------ Dockerfile | 2 +- docs/setup_selfbuild.md | 2 +- package.json | 4 ++-- test/appservice/integration/provisionTest.ts | 4 ++++ test/appservice/integration/webAPITest.ts | 3 +++ test/integration/fixtures.ts | 4 ++++ yarn.lock | 14 +++++++++++++- 8 files changed, 34 insertions(+), 11 deletions(-) diff --git a/.github/workflows/mjolnir.yml b/.github/workflows/mjolnir.yml index bb57961..85a2313 100644 --- a/.github/workflows/mjolnir.yml +++ b/.github/workflows/mjolnir.yml @@ -17,10 +17,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Specifically use node 16 like in the readme. + - name: Specifically use node 18 like in the readme. uses: actions/setup-node@v3 with: - node-version: '16' + node-version: '18' - run: yarn install - run: yarn build - run: yarn lint @@ -29,10 +29,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Specifically use node 16 like in the readme. + - name: Specifically use node 18 like in the readme. uses: actions/setup-node@v3 with: - node-version: '16' + node-version: '18' - run: yarn install - run: yarn test integration: @@ -43,7 +43,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: '16' + node-version: '18' - name: Fetch and build mx-tester (cached across runs) uses: baptiste0928/cargo-install@v1 with: @@ -65,7 +65,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: '16' + node-version: '18' - name: Fetch and build mx-tester (cached across runs) uses: baptiste0928/cargo-install@v1 with: diff --git a/Dockerfile b/Dockerfile index d0891b0..9cf5859 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # We can't use alpine anymore because crypto has rust deps. -FROM node:16-slim +FROM node:18-slim COPY . /tmp/src RUN cd /tmp/src \ && yarn install \ diff --git a/docs/setup_selfbuild.md b/docs/setup_selfbuild.md index 9e42fdb..5c87540 100644 --- a/docs/setup_selfbuild.md +++ b/docs/setup_selfbuild.md @@ -1,5 +1,5 @@ These instructions are to build and run mjolnir without using [Docker](./setup_docker.md). -To build mjolnir, you have to have installed [Node >=16](https://nodejs.org/en/download/), [npm](https://docs.npmjs.com/cli/v7/configuring-npm/install) and [yarn >1.x](https://classic.yarnpkg.com/en/docs/install). +To build mjolnir, you have to have installed [Node >=18](https://nodejs.org/en/download/), [npm](https://docs.npmjs.com/cli/v7/configuring-npm/install) and [yarn >1.x](https://classic.yarnpkg.com/en/docs/install). Copy the latest release tag from https://github.com/matrix-org/mjolnir/releases/latest/ to use when cloning. For example `v1.6.1` - please check the link for the current version as this mentioned example might be outdated. diff --git a/package.json b/package.json index 1917ffa..f63aa6f 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@types/jsdom": "^16.2.11", "@types/mocha": "^9.0.0", "@types/nedb": "^1.8.12", - "@types/node": "^16.7.10", + "@types/node": "^18.0.0", "@types/pg": "^8.6.5", "@types/request": "^2.48.8", "@types/shell-quote": "1.7.1", @@ -64,6 +64,6 @@ "yaml": "^2.2.2" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" } } diff --git a/test/appservice/integration/provisionTest.ts b/test/appservice/integration/provisionTest.ts index 8e2765a..106654a 100644 --- a/test/appservice/integration/provisionTest.ts +++ b/test/appservice/integration/provisionTest.ts @@ -3,12 +3,16 @@ import { newTestUser } from "../../integration/clientHelper"; import { getFirstReply } from "../../integration/commands/commandUtils"; import { MatrixClient } from "matrix-bot-sdk"; import { MjolnirAppService } from "../../../src/appservice/AppService"; +import dns from 'node:dns'; interface Context extends Mocha.Context { moderator?: MatrixClient, appservice?: MjolnirAppService } +// Necessary for CI: Node 17+ defaults to using ipv6 first, but Github Actions does not support ipv6 +dns.setDefaultResultOrder('ipv4first'); + describe("Test that the app service can provision a mjolnir on invite of the appservice bot", function () { afterEach(function(this: Context) { this.moderator?.stop(); diff --git a/test/appservice/integration/webAPITest.ts b/test/appservice/integration/webAPITest.ts index 2875e69..1b5165e 100644 --- a/test/appservice/integration/webAPITest.ts +++ b/test/appservice/integration/webAPITest.ts @@ -5,6 +5,7 @@ import { CreateMjolnirResponse, MjolnirWebAPIClient } from "../utils/webAPIClien import { MatrixClient } from "matrix-bot-sdk"; import { getFirstReply } from "../../integration/commands/commandUtils"; import expect from "expect"; +import dns from 'node:dns'; interface Context extends Mocha.Context { @@ -12,6 +13,8 @@ interface Context extends Mocha.Context { moderator?: MatrixClient } +// Necessary for CI: Node 17+ defaults to using ipv6 first, but Github Actions does not support ipv6 +dns.setDefaultResultOrder('ipv4first'); describe("Test that the app service can provision a mjolnir when requested from the web API", function () { afterEach(function(this: Context) { diff --git a/test/integration/fixtures.ts b/test/integration/fixtures.ts index 921bd3b..b91cfc8 100644 --- a/test/integration/fixtures.ts +++ b/test/integration/fixtures.ts @@ -1,6 +1,10 @@ import { read as configRead } from "../../src/config"; import { makeMjolnir, teardownManagementRoom } from "./mjolnirSetupUtils"; import { register } from "prom-client"; +import dns from 'node:dns'; + +// Necessary for CI: Node 17+ defaults to using ipv6 first, but Github Actions does not support ipv6 +dns.setDefaultResultOrder('ipv4first'); // When Mjolnir starts (src/index.ts) it clobbers the config by resolving the management room // alias specified in the config (config.managementRoom) and overwriting that with the room ID. diff --git a/yarn.lock b/yarn.lock index fed2092..0748148 100644 --- a/yarn.lock +++ b/yarn.lock @@ -268,11 +268,18 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@^16.7.10": +"@types/node@*": version "16.10.2" resolved "https://registry.npmjs.org/@types/node/-/node-16.10.2.tgz" integrity sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ== +"@types/node@^18.0.0": + version "18.18.9" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.18.9.tgz#5527ea1832db3bba8eb8023ce8497b7d3f299592" + integrity sha512-0f5klcuImLnG4Qreu9hPj/rEfFq6YRc5n2mAjSsH+ec/mJL+3voBH0+8T7o8RpFjH7ovc+TRsL/c7OYIQsPTfQ== + dependencies: + undici-types "~5.26.4" + "@types/parse5@*": version "6.0.1" resolved "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.1.tgz" @@ -3364,6 +3371,11 @@ underscore@~1.4.4: resolved "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz" integrity sha512-ZqGrAgaqqZM7LGRzNjLnw5elevWb5M8LEoDMadxIW3OWbcv72wMMgKdwOKpd5Fqxe8choLD8HN3iSj3TUh/giQ== +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + universalify@^0.1.2: version "0.1.2" resolved "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz"