From 8f3cb770ebfeb812352839b4856f41d962e0fd86 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 27 Oct 2025 23:58:27 +0800 Subject: [PATCH] [Docker] Bump to Node.js 22 (#6222) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/auto-test.yml | 12 ++++++------ .github/workflows/close-incorrect-issue.yml | 4 ++-- .github/workflows/validate.yml | 2 +- docker/debian-base.dockerfile | 4 ++-- package.json | 6 ++++-- test/test-backend.mjs | 12 ++++++++++++ 6 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 test/test-backend.mjs diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index f59035442..14b80f234 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: os: [macos-latest, ubuntu-22.04, windows-latest, ARM64] - node: [ 18, 20 ] + node: [ 20, 24 ] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -30,7 +30,7 @@ jobs: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node }} - run: npm install @@ -49,7 +49,7 @@ jobs: strategy: matrix: os: [ ARMv7 ] - node: [ 18, 20 ] + node: [ 20, 22 ] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -57,7 +57,7 @@ jobs: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node }} - run: npm ci --production @@ -70,7 +70,7 @@ jobs: - uses: actions/checkout@v4 - name: Use Node.js 20 - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: 20 - run: npm install @@ -84,7 +84,7 @@ jobs: - uses: actions/checkout@v4 - name: Use Node.js 20 - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: 20 - run: npm install diff --git a/.github/workflows/close-incorrect-issue.yml b/.github/workflows/close-incorrect-issue.yml index 3ef5ba378..9d4616931 100644 --- a/.github/workflows/close-incorrect-issue.yml +++ b/.github/workflows/close-incorrect-issue.yml @@ -11,13 +11,13 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node-version: [18] + node-version: [20] steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: 'npm' diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 7e631ccd4..4dff3689d 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -32,7 +32,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use Node.js 20 - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: 20 diff --git a/docker/debian-base.dockerfile b/docker/debian-base.dockerfile index ca5fc43ec..10471af2a 100644 --- a/docker/debian-base.dockerfile +++ b/docker/debian-base.dockerfile @@ -1,5 +1,5 @@ # Download Apprise deb package -FROM node:20-bookworm-slim AS download-apprise +FROM node:22-bookworm-slim AS download-apprise WORKDIR /app COPY ./extra/download-apprise.mjs ./download-apprise.mjs RUN apt update && \ @@ -9,7 +9,7 @@ RUN apt update && \ # Base Image (Slim) # If the image changed, the second stage image should be changed too -FROM node:20-bookworm-slim AS base2-slim +FROM node:22-bookworm-slim AS base2-slim ARG TARGETPLATFORM # Specify --no-install-recommends to skip unused dependencies, make the base much smaller! diff --git a/package.json b/package.json index 576068492..7f09ef86f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "url": "https://github.com/louislam/uptime-kuma.git" }, "engines": { - "node": "18 || >= 20.4.0" + "node": ">= 20.4.0" }, "scripts": { "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .", @@ -27,7 +27,9 @@ "build": "vite build --config ./config/vite.config.js", "test": "npm run test-backend && npm run test-e2e", "test-with-build": "npm run build && npm test", - "test-backend": "cross-env TEST_BACKEND=1 node --test test/backend-test", + "test-backend": "node test/test-backend.mjs", + "test-backend-22": "cross-env TEST_BACKEND=1 node --test \"test/backend-test/**/*.js\"", + "test-backend-20": "cross-env TEST_BACKEND=1 node --test test/backend-test", "test-e2e": "playwright test --config ./config/playwright.config.js", "test-e2e-ui": "playwright test --config ./config/playwright.config.js --ui --ui-port=51063", "playwright-codegen": "playwright codegen localhost:3000 --save-storage=./private/e2e-auth.json", diff --git a/test/test-backend.mjs b/test/test-backend.mjs new file mode 100644 index 000000000..e285f7804 --- /dev/null +++ b/test/test-backend.mjs @@ -0,0 +1,12 @@ +import * as childProcess from "child_process"; + +const version = parseInt(process.version.slice(1).split(".")[0]); + +/** + * Since Node.js 22 introduced a different "node --test" command with glob, we need to run different test commands based on the Node.js version. + */ +if (version < 22) { + childProcess.execSync("npm run test-backend-20", { stdio: "inherit" }); +} else { + childProcess.execSync("npm run test-backend-22", { stdio: "inherit" }); +}