Skip to content

chore: build library #74

chore: build library

chore: build library #74

Workflow file for this run

name: Backend
permissions:
contents: read
packages: write
on:
push:
paths:
- .github/workflows/backend.yaml
- backend/**
branches:
- '**'
tags-ignore:
- "**"
workflow_call:
defaults:
run:
working-directory: backend
jobs:
build-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
registry-url: 'https://npm.pkg.github.com'
scope: '@codecentric'
cache-dependency-path: backend/package-lock.json
- run: npm ci
- run: npm run build:lib
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- run: npm install
- run: npm run build
check-generated-files:
runs-on: ubuntu-latest
strategy:
matrix:
service: [reis, tools, executor]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- run: npm install
- run: npm run generate-${{ matrix.service }}
- run: git diff --quiet # exits with exitcode != 0 if changes are detected
check-generated-specs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- run: npm install
- run: npm run generate-openapi-dev
- run: git add -N .
- run: git diff .
- run: git diff --quiet .
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- run: npm install
- run: npm run lint
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17.5
env:
POSTGRES_USER: admin
POSTGRES_PASSWORD: secret
POSTGRES_DB: cccc
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
BASE_URL: 'https://example.com'
DB_URL: postgres://admin:secret@localhost:5432/cccc
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- run: npm install
- run: npm run test:cov
- uses: irongut/[email protected]
with:
badge: true
filename: backend/coverage/cobertura-coverage.xml
format: markdown
output: both
- run: cp code-coverage-results.md $GITHUB_STEP_SUMMARY
working-directory: .
test-migration:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17.5
env:
POSTGRES_USER: admin
POSTGRES_PASSWORD: secret
POSTGRES_DB: cccc
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
BASE_URL: 'https://example.com'
DB_URL: postgres://admin:secret@localhost:5432/cccc
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- run: npm install
- run: npm run migration:run
# changes the return code from 1 to 0 in case no schema was changed and vice versa
- run: sh -c "! npm run migration:generate --name=test"