Skip to content

Commit 7a76c51

Browse files
authored
Node 22 native (#409) & Dependency update (#425) (#426)
* Node 22 native (#409) & Dependency update (#425) * Node 22 native features * Update webhook body * Dependency update (#425) * Bump esbuild from 0.27.0 to 0.27.1 in the development-dependencies group (#424) * Bump the production-dependencies group with 5 updates (#423) | Package | From | To | | --- | --- | --- | | [@natlibfi/marc-record-serializers](https://github.com/NatLibFi/marc-record-serializers) | `11.0.0` | `11.0.1` | | [@natlibfi/melinda-backend-commons](https://github.com/NatLibFi/melinda-backend-commons-js) | `3.0.0` | `3.0.1` | | [@natlibfi/melinda-rest-api-commons](https://github.com/NatLibFi/melinda-rest-api-commons) | `5.0.0` | `5.0.1` | | [body-parser](https://github.com/expressjs/body-parser) | `2.2.0` | `2.2.1` | | [express](https://github.com/expressjs/express) | `4.21.2` | `4.22.1` | * Bump js-yaml from 4.1.0 to 4.1.1 (#417) * Update deps * 4.0.0-alpha.6 * Update Dockerfile * Move esbuild to prod for docker * Fix import * 4.0.0-alpha.7 * Try to fix dockerfile * fix build script * 4.0.0-alpha.8
1 parent baee61a commit 7a76c51

24 files changed

+2137
-6660
lines changed
Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Melinda node tests
1+
# Melinda node tests and webhook
22

3-
name: Melinda node tests
3+
name: Melinda node tests and webhook
44

55
on: push
66

@@ -11,14 +11,14 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
node-version: [18.x, 20.x, 22.x, 23.x]
14+
node-version: [22.x, 24.x]
1515
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
1616

1717
steps:
1818
- name: Checkout the code
19-
uses: actions/checkout@v5
19+
uses: actions/checkout@v6
2020
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v4
21+
uses: actions/setup-node@v6
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424
cache: 'npm'
@@ -32,122 +32,126 @@ jobs:
3232
license-scan:
3333
name: License compliance check
3434
runs-on: ubuntu-latest
35+
container: node:22
3536

3637
steps:
37-
- uses: actions/checkout@v5
38+
- uses: actions/checkout@v6
3839
- uses: mikaelvesavuori/license-compliance-action@main
3940
with:
4041
exclude_pattern: /^@natlibfi/
4142

4243
njsscan:
4344
name: Njsscan check
4445
runs-on: ubuntu-latest
46+
container: node:22
4547

4648
steps:
4749
- name: Checkout the code
48-
uses: actions/checkout@v5
50+
uses: actions/checkout@v6
4951
- name: nodejsscan scan
5052
id: njsscan
5153
uses: ajinabraham/njsscan-action@master
5254
with:
5355
args: '.'
5456

55-
quayio:
56-
name: Quay.io image builder & publisher
57-
needs: [build-node-versions, njsscan]
58-
runs-on: ubuntu-latest
59-
if: github.actor!= 'dependabot[bot]' # ignore the pull request which comes from user dependabot, because it does not access to secrets
57+
# quayio:
58+
# name: Quay.io image builder & publisher
59+
# needs: [build-node-versions, njsscan]
60+
# runs-on: ubuntu-latest
61+
# container: node:22
62+
# if: github.actor!= 'dependabot[bot]' # ignore the pull request which comes from user dependabot, because it does not access to secrets
6063

61-
steps:
62-
- uses: actions/checkout@v5
63-
- name: Docker meta
64-
id: meta
65-
uses: docker/metadata-action@v5
66-
with:
67-
images: quay.io/${{ github.repository }}
68-
tags: |
69-
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
70-
type=ref,event=branch
71-
type=ref,event=pr
72-
type=semver,pattern={{version}}
73-
type=semver,pattern={{major}}.{{minor}}
74-
type=semver,pattern={{major}}
75-
- name: Login to Quay.io
76-
uses: docker/login-action@v3
77-
with:
78-
registry: quay.io
79-
username: ${{ secrets.MELINDA_QUAY_IO_USERNAME }}
80-
password: ${{ secrets.MELINDA_QUAY_IO_PASSWORD }}
81-
- name: Build and publish image to Quay.io
82-
uses: docker/build-push-action@v6
83-
with:
84-
context: .
85-
push: true
86-
tags: ${{ steps.meta.outputs.tags }}
64+
# steps:
65+
# - uses: actions/checkout@v6
66+
# - name: Docker meta
67+
# id: meta
68+
# uses: docker/metadata-action@v5
69+
# with:
70+
# images: quay.io/${{ github.repository }}
71+
# tags: |
72+
# type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
73+
# type=ref,event=branch
74+
# type=ref,event=pr
75+
# type=semver,pattern={{version}}
76+
# type=semver,pattern={{major}}.{{minor}}
77+
# type=semver,pattern={{major}}
78+
# - name: Login to Quay.io
79+
# uses: docker/login-action@v3
80+
# with:
81+
# registry: quay.io
82+
# username: ${{ secrets.MELINDA_QUAY_IO_USERNAME }}
83+
# password: ${{ secrets.MELINDA_QUAY_IO_PASSWORD }}
84+
# - name: Build and publish image to Quay.io
85+
# uses: docker/build-push-action@v6
86+
# with:
87+
# context: .
88+
# push: true
89+
# tags: ${{ steps.meta.outputs.tags }}
8790

8891
openshift-webhook:
8992
name: OpenShift webhook for image builder
9093
needs: [build-node-versions, njsscan]
9194
runs-on: ubuntu-latest
95+
container: node:22
9296

9397
steps:
9498
- name: Production bib webhook
9599
uses: joelwmale/webhook-action@master
96100
if: github.ref == 'refs/heads/main'
97101
with:
98102
url: ${{ secrets.WEBHOOK_URL_BIB_PROD_FROM_MAIN }}
99-
body: '{}'
103+
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
100104
- name: Production aut-aux webhook
101105
uses: joelwmale/webhook-action@master
102106
if: github.ref == 'refs/heads/main'
103107
with:
104108
url: ${{ secrets.WEBHOOK_URL_AUT_AUX_PROD_FROM_MAIN }}
105-
body: '{}'
109+
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
106110
- name: Production aut-names webhook
107111
uses: joelwmale/webhook-action@master
108112
if: github.ref == 'refs/heads/main'
109113
with:
110114
url: ${{ secrets.WEBHOOK_URL_AUT_NAMES_PROD_FROM_MAIN }}
111-
body: '{}'
115+
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
112116
- name: Production aut-subjects webhook
113117
uses: joelwmale/webhook-action@master
114118
if: github.ref == 'refs/heads/main'
115119
with:
116120
url: ${{ secrets.WEBHOOK_URL_AUT_SUBJECTS_PROD_FROM_MAIN }}
117-
body: '{}'
121+
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
118122
- name: Production aut-works webhook
119123
uses: joelwmale/webhook-action@master
120124
if: github.ref == 'refs/heads/main'
121125
with:
122126
url: ${{ secrets.WEBHOOK_URL_AUT_WORKS_PROD_FROM_MAIN }}
123-
body: '{}'
127+
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
124128
- name: Test aut aux webhook
125129
uses: joelwmale/webhook-action@master
126130
if: github.ref == 'refs/heads/test'
127131
with:
128132
url: ${{ secrets.WEBHOOK_URL_AUT_AUX_TEST_FROM_TEST }}
129-
body: '{}'
133+
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
130134
- name: Test aut names webhook
131135
uses: joelwmale/webhook-action@master
132136
if: github.ref == 'refs/heads/test'
133137
with:
134138
url: ${{ secrets.WEBHOOK_URL_AUT_NAMES_TEST_FROM_TEST }}
135-
body: '{}'
139+
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
136140
- name: Test aut subjects webhook
137141
uses: joelwmale/webhook-action@master
138142
if: github.ref == 'refs/heads/test'
139143
with:
140144
url: ${{ secrets.WEBHOOK_URL_AUT_SUBJECTS_TEST_FROM_TEST }}
141-
body: '{}'
145+
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
142146
- name: Test aut works webhook
143147
uses: joelwmale/webhook-action@master
144148
if: github.ref == 'refs/heads/test'
145149
with:
146150
url: ${{ secrets.WEBHOOK_URL_AUT_WORKS_TEST_FROM_TEST }}
147-
body: '{}'
151+
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
148152
- name: Test bib webhook
149153
uses: joelwmale/webhook-action@master
150154
if: github.ref == 'refs/heads/test'
151155
with:
152156
url: ${{ secrets.WEBHOOK_URL_BIB_TEST_FROM_TEST }}
153-
body: '{}'
157+
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18-alpine as builder
1+
FROM node:22-alpine as builder
22
WORKDIR /home/node
33

44
COPY --chown=node:node . build
@@ -8,12 +8,13 @@ RUN apk add -U --no-cache --virtual .build-deps git sudo \
88
&& sudo -u node sh -c 'cp -r build/dist/* build/package.json build/package-lock.json .' \
99
&& sudo -u node sh -c 'npm i --ignore-scripts --production'
1010

11-
FROM node:18-alpine
11+
FROM node:22-alpine
1212
CMD ["/usr/local/bin/node", "index.js"]
1313
WORKDIR /home/node
1414
USER node
1515

1616
COPY --from=builder /home/node/build/dist/ .
1717
COPY --from=builder /home/node/node_modules node_modules
1818
COPY --from=builder /home/node/package.json .
19-
COPY --from=builder /home/node/package-lock.json .
19+
COPY --from=builder /home/node/package-lock.json .
20+

eslint.config.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Eslint configuration object for src
2+
const configSrc = {
3+
files: [
4+
"src/*"
5+
],
6+
linterOptions: {
7+
reportUnusedDisableDirectives: true,
8+
},
9+
rules: {
10+
"no-console": "warn",
11+
"eqeqeq": ["error", "always"],
12+
"no-const-assign": "error",
13+
"max-depth": ["warn", 4],
14+
"max-lines": ["warn", 500],
15+
"max-lines-per-function": ["warn", {"max": 100}],
16+
"no-else-return": ["error", {allowElseIf: false}],
17+
"no-plusplus": [
18+
"error",
19+
{
20+
"allowForLoopAfterthoughts": true
21+
}
22+
],
23+
"array-callback-return": [
24+
"error",
25+
{
26+
"checkForEach": false
27+
}
28+
],
29+
"no-unused-vars": [
30+
"error",
31+
{
32+
"argsIgnorePattern": "next"
33+
}
34+
],
35+
"no-warning-comments": "off"
36+
}
37+
};
38+
39+
// Eslint configuration object for globally ignoring .js files
40+
// - ignore all files that start with a dot
41+
// - ignore all files inside directories named 'dist'
42+
const configIgnores = {
43+
ignores: [
44+
"**/.*",
45+
"**/dist/"
46+
]
47+
};
48+
49+
export default [
50+
configSrc,
51+
configIgnores
52+
];

example.env

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
TZ=Europe/Helsinki
2+
HTTP_PORT=8081
3+
ENABLE_PROXY=1
4+
ALEPH_X_SVC_URL=https://example.com/X?
5+
ALEPH_USER_LIBRARY=usr00
6+
OWN_AUTHZ_URL=https://example.com/aleph-own-auth-api/
7+
OWN_AUTHZ_API_KEY=API_KEY
8+
SRU_URL=https://sru.example.com/bib/prv
9+
LOG_LEVEL=debug
10+
DEBUG="@natlibfi/*,-*amqp*"
11+
ALLOWED_LIBS="EXP11"

0 commit comments

Comments
 (0)