Skip to content

Commit

Permalink
Node20 (#7095)
Browse files Browse the repository at this point in the history
Upgrades workflows, nvmrc and package.json to use Node 20.
  • Loading branch information
chriswk authored May 23, 2024
1 parent b783e89 commit 7e38d6b
Show file tree
Hide file tree
Showing 21 changed files with 105 additions and 74 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
runs-on: ubuntu-latest
name: build

strategy:
matrix:
node-version: [18.x]
services:
# Label used to access the service container
postgres:
Expand All @@ -38,10 +35,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 20.x
cache: 'yarn'
- run: yarn install --frozen-lockfile --ignore-scripts
- run: yarn lint
Expand All @@ -56,4 +53,4 @@ jobs:
if: (success() || failure()) && github.ref == 'refs/heads/main'
with:
name: test-results
path: ./reports/jest-junit.xml
path: ./reports/jest-junit.xml
4 changes: 2 additions & 2 deletions .github/workflows/build_coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
services:
# Label used to access the service container
postgres:
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
cache: 'yarn'
- run: yarn
- run: yarn build:frontend:if-needed
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_doc_prs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
validate:
name: build (18.x) # temporary solution to trick branch protection rules
name: build # temporary solution to trick branch protection rules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_frontend_prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
working-directory: frontend
strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build_prs_jest_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
name: build (18.x) # temporary solution to trick branch protection rules
name: build # temporary solution to trick branch protection rules

services:
# Label used to access the service container
Expand All @@ -32,12 +32,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
cache: 'yarn'
- name: Tests on 18.x
- name: Tests on 20.x
id: coverage
uses: ArtiomTr/jest-coverage-report-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [18.18.2-alpine]
version: [20.13.1-alpine]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gradual-strict-null-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]

steps:
- name: Checkout current branch
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
cache: 'yarn'
cache-dependency-path: |
current/yarn.lock
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/notify_enterprise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-new-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v4
- name: Setup to npm
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update_contributors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
- uses: actions/checkout@master
with:
repository: sighphyre/svg-contributors
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate-migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
cache: 'yarn'
- name: Start database
working-directory: test-migrations
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG NODE_VERSION=18.20.2-alpine
ARG NODE_VERSION=20.13.1-alpine

FROM node:$NODE_VERSION as builder

Expand Down
2 changes: 1 addition & 1 deletion docker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test:ci": "echo 'no tests for unleash-docker'"
},
"engines": {
"node": ">=18"
"node": ">=20"
},
"author": "",
"license": "ISC",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
"proxyquire": "2.1.3",
"source-map-support": "0.5.21",
"superagent": "9.0.2",
"supertest": "6.3.4",
"supertest": "7.0.0",
"ts-node": "10.9.2",
"tsc-watch": "6.2.0",
"typescript": "5.4.2",
Expand Down
1 change: 1 addition & 0 deletions src/lib/__snapshots__/create-config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ exports[`should create default config 1`] = `
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(shapeMode): false,
Symbol(kCapture): false,
},
"feedbackUriPath": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ test('should return lifecycle stages', async () => {
bucket: {
toggles: {
my_feature_a: 'irrelevant',
non_existent_feature: 'irrelevent',
non_existent_feature: 'irrelevant',
},
},
environment: 'default',
Expand Down
25 changes: 15 additions & 10 deletions src/lib/features/frontend-api/frontend-api.concurrency.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
type IUnleashTest,
setupAppWithAuth,
type IUnleashNoSupertest,
setupAppWithoutSupertest,
} from '../../../test/e2e/helpers/test-helper';
import dbInit, { type ITestDb } from '../../../test/e2e/helpers/database-init';
import getLogger from '../../../test/fixtures/no-logger';
import { randomId } from '../../util';
import { ApiTokenType } from '../../types/models/api-token';

let app: IUnleashTest;
let app: IUnleashNoSupertest;
let db: ITestDb;
let appErrorLogs: string[] = [];

Expand All @@ -21,7 +21,7 @@ beforeAll(async () => {
baseLogger.error(msg, ...args);
},
};
app = await setupAppWithAuth(db.stores, {
app = await setupAppWithoutSupertest(db.stores, {
frontendApiOrigins: ['https://example.com'],
getLogger: () => appLogger,
});
Expand Down Expand Up @@ -53,14 +53,19 @@ test('multiple parallel calls to api/frontend should not create multiple instanc
environment: 'default',
tokenName: `test-token-${randomId()}`,
});

const address = app.server.address();
expect(address).not.toBeNull();
expect(address).toHaveProperty('port');
// @ts-ignore - We've just checked that we have this property
const serverUrl = `http://localhost:${address.port}/api/frontend`;
await Promise.all(
Array.from(Array(10).keys()).map(() =>
app.request
.get('/api/frontend')
.set('Authorization', frontendTokenDefault.secret)
.expect('Content-Type', /json/)
.expect(200),
fetch(serverUrl, {
method: 'GET',
headers: {
Authorization: frontendTokenDefault.secret,
},
}).then((res) => expect(res.status).toBe(200)),
),
);
expect(appErrorLogs).toHaveLength(0);
Expand Down
56 changes: 55 additions & 1 deletion src/test/e2e/helpers/test-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
import type { Knex } from 'knex';
import type TestAgent from 'supertest/lib/agent';
import type Test from 'supertest/lib/test';

import type { Server } from 'node:http';
process.env.NODE_ENV = 'test';

export interface IUnleashTest extends IUnleashHttpAPI {
Expand All @@ -32,6 +32,13 @@ export interface IUnleashTest extends IUnleashHttpAPI {
config: IUnleashConfig;
}

export interface IUnleashNoSupertest {
server: Server;
services: IUnleashServices;
config: IUnleashConfig;
destroy: () => Promise<void>;
}

/**
* This is a collection of API helpers. The response code is optional, and should default to the success code for the request.
*
Expand Down Expand Up @@ -348,6 +355,53 @@ export async function setupApp(stores: IUnleashStores): Promise<IUnleashTest> {
return createApp(stores);
}

export async function setupAppWithoutSupertest(
stores,
customOptions?: any,
db?: Db,
): Promise<IUnleashNoSupertest> {
const config = createTestConfig({
authentication: {
type: IAuthType.DEMO,
},
server: {
unleashUrl: 'http://localhost:4242',
},
disableScheduler: true,
...{
...customOptions,
experimental: {
...(customOptions?.experimental ?? {}),
flags: {
strictSchemaValidation: true,
...(customOptions?.experimental?.flags ?? {}),
},
},
},
});
const services = createServices(stores, config, db);
const unleashSession = sessionDb(config, undefined);
const app = await getApp(config, stores, services, unleashSession, db);
const server = app.listen(0);
const destroy = async () => {
// iterate on the keys of services and if the services at that key has a function called destroy then call it
await Promise.all(
Object.keys(services).map(async (key) => {
if (services[key].destroy) {
await services[key].destroy();
}
}),
);
await server.close();
};
return {
server,
destroy,
services,
config,
};
}

export async function setupAppWithCustomConfig(
stores: IUnleashStores,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
Expand Down
Loading

0 comments on commit 7e38d6b

Please sign in to comment.