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
15 changes: 15 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Setup Node.js with cached dependencies'
description: 'Sets up Node.js and restores node_modules from the artifact uploaded by the setup job.'

runs:
using: composite
steps:
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/download-artifact@v4
with:
name: node-modules
path: .
- run: tar -xzf node-modules.tar.gz && rm node-modules.tar.gz
shell: bash
78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CI

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
setup:
name: Install Dependencies
runs-on: ubuntu-latest
permissions:
contents: read
actions: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: tar -czf node-modules.tar.gz node_modules
- uses: actions/upload-artifact@v4
with:
name: node-modules
path: node-modules.tar.gz
retention-days: 1

lint:
name: Lint
needs: setup
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: npm run lint

format-check:
name: Format Check
needs: setup
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: npm run format:check

build:
name: Build
needs: setup
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: npm run build

test:
name: Test & Coverage
needs: setup
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Enforce 80% coverage
run: npm run test:coverage
3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = tseslint.config(
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
projectService: true,
project: ['packages/backend/tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
},
globals: {
Expand Down Expand Up @@ -54,6 +54,7 @@ module.exports = tseslint.config(
'@typescript-eslint/unbound-method': 'warn',
},
},

{
files: ['**/*.spec.ts'],
rules: {
Expand Down
5 changes: 0 additions & 5 deletions packages/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ COPY packages/backend/tsconfig.json packages/backend/
COPY packages/backend/tsconfig.prod.json packages/backend/
COPY packages/backend/src packages/backend/src

# Copy config files for linting
COPY eslint.config.js .prettierrc.js ./

# Install dependencies and build
RUN npm ci
RUN npm run lint -w @mocker/backend
RUN npm run test -w @mocker/backend
RUN npm run build:prod -w @mocker/backend

FROM node:20-alpine AS release
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "dist"]
}
Loading