Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump to node 20 #706

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ concurrency:
jobs:
test:
name: Test
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "18"
node-version-file: '.nvmrc'


- run: |
npm clean-install
Expand All @@ -30,19 +31,30 @@ jobs:

prettier-check:
name: Prettier check
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actionsx/prettier@v3
- name: Setup node
uses: actions/setup-node@v4
with:
args: --check "{src,test}/**/*.ts"

node-version-file: '.nvmrc'

# Installing all dependencies takes up to three minutes, hacking around to only installing prettier+deps
- name: Download dependencies
run: |
rm package.json
rm package-lock.json
npm i prettier@3 prettier-plugin-sql@0.17.0
- name: Run prettier
run: |-
npx prettier -c '{src,test}/**/*.ts'

docker:
name: Build with docker
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: Checkout Repo

- uses: docker/setup-buildx-action@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ concurrency:
jobs:
docs:
name: Publish docs
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "18"
node-version-file: '.nvmrc'

- run: |
npm clean-install
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ on:

jobs:
publish:
# Must match glibc verison in node:18
# Must match glibc verison in node:20
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'pyramation/libpg-query-node'
ref: 'v13'
ref: 'v15'

- uses: actions/setup-node@v4
with:
node-version: '18'
node-version-file: '.nvmrc'

- run: npm i
- run: npm run binary:build
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ on:
jobs:
semantic-release:
name: Release
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
outputs:
new-release-published: ${{ steps.semantic-release.outputs.new_release_published }}
new-release-version: ${{ steps.semantic-release.outputs.new_release_version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '18'
node-version-file: '.nvmrc'

- run: |
npm clean-install
Expand All @@ -37,13 +37,13 @@ jobs:
needs:
- semantic-release
if: needs.semantic-release.outputs.new-release-published == 'true'
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '18'
node-version-file: '.nvmrc'

- name: Prepare release
run: |
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18 as build
FROM node:20 as build
WORKDIR /usr/src/app
# Do `npm ci` separately so we can cache `node_modules`
# https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
Expand All @@ -7,7 +7,7 @@ RUN npm clean-install
COPY . .
RUN npm run build && npm prune --omit=dev

FROM node:18-slim
FROM node:20-slim
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/node_modules node_modules
COPY --from=build /usr/src/app/dist dist
Expand All @@ -16,4 +16,4 @@ ENV PG_META_PORT=8080
CMD ["npm", "run", "start"]
EXPOSE 8080
# --start-period defaults to 0s, but can't be set to 0s (to be explicit) by now
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD node -e "require('http').get('http://localhost:8080/health', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD node -e "fetch('http://localhost:8080/health').then((r) => {if (r.status !== 200) throw new Error(r.status)})"
40 changes: 29 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"test:update": "run-s db:clean db:run && vitest run && run-s db:clean"
},
"engines": {
"node": ">=18",
"npm": ">=8"
"node": ">=20",
"npm": ">=9"
},
"dependencies": {
"@fastify/cors": "^9.0.1",
Expand All @@ -56,7 +56,7 @@
},
"devDependencies": {
"@types/crypto-js": "^4.1.1",
"@types/node": "^18.17.17",
"@types/node": "^20.11.14",
"@types/pg": "^8.6.5",
"@types/pg-format": "^1.0.1",
"cpy-cli": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/secrets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Use dynamic import to support module mock
const fs = await import('fs/promises')
const fs = await import('node:fs/promises')

export const getSecret = async (key: string) => {
if (!key) {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/sql/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFile } from 'fs/promises'
import { dirname, join } from 'path'
import { fileURLToPath } from 'url'
import { readFile } from 'node:fs/promises'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'

const __dirname = dirname(fileURLToPath(import.meta.url))
export const columnPrivilegesSql = await readFile(join(__dirname, 'column_privileges.sql'), 'utf-8')
Expand Down
7 changes: 4 additions & 3 deletions test/lib/secrets.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { readFile } from 'fs/promises'
import { readFile } from 'node:fs/promises'
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
import { getSecret } from '../../src/lib/secrets'

vi.mock('fs/promises', async (): Promise<typeof import('fs/promises')> => {
const originalModule = await vi.importActual<typeof import('fs/promises')>('fs/promises')
vi.mock('node:fs/promises', async (): Promise<typeof import('node:fs/promises')> => {
const originalModule =
await vi.importActual<typeof import('node:fs/promises')>('node:fs/promises')
const readFile = vi.fn()
return {
...originalModule,
Expand Down
6 changes: 3 additions & 3 deletions test/server/ssl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CryptoJS from 'crypto-js'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { expect, test } from 'vitest'
import { app } from './utils'
import { CRYPTO_KEY, DEFAULT_POOL_CONFIG } from '../../src/server/constants'
Expand Down