Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Melinda node tests
# Melinda node tests and webhook

name: Melinda node tests
name: Melinda node tests and webhook

on: push

Expand All @@ -11,14 +11,14 @@ jobs:

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

steps:
- name: Checkout the code
uses: actions/checkout@v5
uses: actions/checkout@v6
- 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'
Expand All @@ -32,122 +32,126 @@ jobs:
license-scan:
name: License compliance check
runs-on: ubuntu-latest
container: node:22

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: mikaelvesavuori/license-compliance-action@main
with:
exclude_pattern: /^@natlibfi/

njsscan:
name: Njsscan check
runs-on: ubuntu-latest
container: node:22

steps:
- name: Checkout the code
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: nodejsscan scan
id: njsscan
uses: ajinabraham/njsscan-action@master
with:
args: '.'

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

steps:
- uses: actions/checkout@v5
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: quay.io/${{ github.repository }}
tags: |
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.MELINDA_QUAY_IO_USERNAME }}
password: ${{ secrets.MELINDA_QUAY_IO_PASSWORD }}
- name: Build and publish image to Quay.io
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
# steps:
# - uses: actions/checkout@v6
# - name: Docker meta
# id: meta
# uses: docker/metadata-action@v5
# with:
# images: quay.io/${{ github.repository }}
# tags: |
# type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
# type=ref,event=branch
# type=ref,event=pr
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}
# type=semver,pattern={{major}}
# - name: Login to Quay.io
# uses: docker/login-action@v3
# with:
# registry: quay.io
# username: ${{ secrets.MELINDA_QUAY_IO_USERNAME }}
# password: ${{ secrets.MELINDA_QUAY_IO_PASSWORD }}
# - name: Build and publish image to Quay.io
# uses: docker/build-push-action@v6
# with:
# context: .
# push: true
# tags: ${{ steps.meta.outputs.tags }}

openshift-webhook:
name: OpenShift webhook for image builder
needs: [build-node-versions, njsscan]
runs-on: ubuntu-latest
container: node:22

steps:
- name: Production bib webhook
uses: joelwmale/webhook-action@master
if: github.ref == 'refs/heads/main'
with:
url: ${{ secrets.WEBHOOK_URL_BIB_PROD_FROM_MAIN }}
body: '{}'
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
- name: Production aut-aux webhook
uses: joelwmale/webhook-action@master
if: github.ref == 'refs/heads/main'
with:
url: ${{ secrets.WEBHOOK_URL_AUT_AUX_PROD_FROM_MAIN }}
body: '{}'
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
- name: Production aut-names webhook
uses: joelwmale/webhook-action@master
if: github.ref == 'refs/heads/main'
with:
url: ${{ secrets.WEBHOOK_URL_AUT_NAMES_PROD_FROM_MAIN }}
body: '{}'
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
- name: Production aut-subjects webhook
uses: joelwmale/webhook-action@master
if: github.ref == 'refs/heads/main'
with:
url: ${{ secrets.WEBHOOK_URL_AUT_SUBJECTS_PROD_FROM_MAIN }}
body: '{}'
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
- name: Production aut-works webhook
uses: joelwmale/webhook-action@master
if: github.ref == 'refs/heads/main'
with:
url: ${{ secrets.WEBHOOK_URL_AUT_WORKS_PROD_FROM_MAIN }}
body: '{}'
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
- name: Test aut aux webhook
uses: joelwmale/webhook-action@master
if: github.ref == 'refs/heads/test'
with:
url: ${{ secrets.WEBHOOK_URL_AUT_AUX_TEST_FROM_TEST }}
body: '{}'
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
- name: Test aut names webhook
uses: joelwmale/webhook-action@master
if: github.ref == 'refs/heads/test'
with:
url: ${{ secrets.WEBHOOK_URL_AUT_NAMES_TEST_FROM_TEST }}
body: '{}'
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
- name: Test aut subjects webhook
uses: joelwmale/webhook-action@master
if: github.ref == 'refs/heads/test'
with:
url: ${{ secrets.WEBHOOK_URL_AUT_SUBJECTS_TEST_FROM_TEST }}
body: '{}'
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
- name: Test aut works webhook
uses: joelwmale/webhook-action@master
if: github.ref == 'refs/heads/test'
with:
url: ${{ secrets.WEBHOOK_URL_AUT_WORKS_TEST_FROM_TEST }}
body: '{}'
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
- name: Test bib webhook
uses: joelwmale/webhook-action@master
if: github.ref == 'refs/heads/test'
with:
url: ${{ secrets.WEBHOOK_URL_BIB_TEST_FROM_TEST }}
body: '{}'
body: '{"event": "${{ github.event_name }}","uri": "${{ github.repository }}","ref": "${{ github.ref }}","commit": "${{ github.sha }}"}'
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine as builder
FROM node:22-alpine as builder
WORKDIR /home/node

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

FROM node:18-alpine
FROM node:22-alpine
CMD ["/usr/local/bin/node", "index.js"]
WORKDIR /home/node
USER node

COPY --from=builder /home/node/build/dist/ .
COPY --from=builder /home/node/node_modules node_modules
COPY --from=builder /home/node/package.json .
COPY --from=builder /home/node/package-lock.json .
COPY --from=builder /home/node/package-lock.json .

52 changes: 52 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Eslint configuration object for src
const configSrc = {
files: [
"src/*"
],
linterOptions: {
reportUnusedDisableDirectives: true,
},
rules: {
"no-console": "warn",
"eqeqeq": ["error", "always"],
"no-const-assign": "error",
"max-depth": ["warn", 4],
"max-lines": ["warn", 500],
"max-lines-per-function": ["warn", {"max": 100}],
"no-else-return": ["error", {allowElseIf: false}],
"no-plusplus": [
"error",
{
"allowForLoopAfterthoughts": true
}
],
"array-callback-return": [
"error",
{
"checkForEach": false
}
],
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "next"
}
],
"no-warning-comments": "off"
}
};

// Eslint configuration object for globally ignoring .js files
// - ignore all files that start with a dot
// - ignore all files inside directories named 'dist'
const configIgnores = {
ignores: [
"**/.*",
"**/dist/"
]
};

export default [
configSrc,
configIgnores
];
11 changes: 11 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TZ=Europe/Helsinki
HTTP_PORT=8081
ENABLE_PROXY=1
ALEPH_X_SVC_URL=https://example.com/X?
ALEPH_USER_LIBRARY=usr00
OWN_AUTHZ_URL=https://example.com/aleph-own-auth-api/
OWN_AUTHZ_API_KEY=API_KEY
SRU_URL=https://sru.example.com/bib/prv
LOG_LEVEL=debug
DEBUG="@natlibfi/*,-*amqp*"
ALLOWED_LIBS="EXP11"
Loading