Skip to content

Commit 9e86379

Browse files
sfreeman422CopilotCopilot
authored
Added github actions flow for CI concerns (#181)
* Added github actions flow for CI concerns * Update .github/workflows/ci.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Added support for linting spec files * Updated to use an ESLint specific tsconfig * Updated eslint config to properly leverage the right tsconfig * CI: run npm ci once via composite action + artifact sharing (#182) * Initial plan * Refactor CI to use composite action + artifacts to avoid repeated npm ci Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com> Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/4c494880-0851-4259-9bf2-0172fcf671c4 * Fix actions permissions for artifact upload/download in CI workflow Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com> Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/9c6de18d-4d6d-4a01-a0c4-6091c6499711 * Fix: restore execute permissions on node_modules/.bin after artifact download Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com> Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/c08c9005-bef2-4528-b4ab-b197997e8da9 * Fix: tar node_modules to preserve symlinks and permissions across artifact upload/download Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com> Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/95656348-9a9c-4213-a56b-4604864084e8 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>
1 parent c5f9a0a commit 9e86379

5 files changed

Lines changed: 99 additions & 6 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: 'Setup Node.js with cached dependencies'
2+
description: 'Sets up Node.js and restores node_modules from the artifact uploaded by the setup job.'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- uses: actions/setup-node@v4
8+
with:
9+
node-version: '20'
10+
- uses: actions/download-artifact@v4
11+
with:
12+
name: node-modules
13+
path: .
14+
- run: tar -xzf node-modules.tar.gz && rm node-modules.tar.gz
15+
shell: bash

.github/workflows/ci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
setup:
12+
name: Install Dependencies
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
actions: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
- run: npm ci
24+
- run: tar -czf node-modules.tar.gz node_modules
25+
- uses: actions/upload-artifact@v4
26+
with:
27+
name: node-modules
28+
path: node-modules.tar.gz
29+
retention-days: 1
30+
31+
lint:
32+
name: Lint
33+
needs: setup
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: read
37+
actions: read
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: ./.github/actions/setup
41+
- run: npm run lint
42+
43+
format-check:
44+
name: Format Check
45+
needs: setup
46+
runs-on: ubuntu-latest
47+
permissions:
48+
contents: read
49+
actions: read
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: ./.github/actions/setup
53+
- run: npm run format:check
54+
55+
build:
56+
name: Build
57+
needs: setup
58+
runs-on: ubuntu-latest
59+
permissions:
60+
contents: read
61+
actions: read
62+
steps:
63+
- uses: actions/checkout@v4
64+
- uses: ./.github/actions/setup
65+
- run: npm run build
66+
67+
test:
68+
name: Test & Coverage
69+
needs: setup
70+
runs-on: ubuntu-latest
71+
permissions:
72+
contents: read
73+
actions: read
74+
steps:
75+
- uses: actions/checkout@v4
76+
- uses: ./.github/actions/setup
77+
- name: Enforce 80% coverage
78+
run: npm run test:coverage

eslint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = tseslint.config(
1515
ecmaVersion: 'latest',
1616
sourceType: 'module',
1717
parserOptions: {
18-
projectService: true,
18+
project: ['packages/backend/tsconfig.eslint.json'],
1919
tsconfigRootDir: __dirname,
2020
},
2121
globals: {
@@ -54,6 +54,7 @@ module.exports = tseslint.config(
5454
'@typescript-eslint/unbound-method': 'warn',
5555
},
5656
},
57+
5758
{
5859
files: ['**/*.spec.ts'],
5960
rules: {

packages/backend/Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,8 @@ COPY packages/backend/tsconfig.json packages/backend/
1212
COPY packages/backend/tsconfig.prod.json packages/backend/
1313
COPY packages/backend/src packages/backend/src
1414

15-
# Copy config files for linting
16-
COPY eslint.config.js .prettierrc.js ./
17-
1815
# Install dependencies and build
1916
RUN npm ci
20-
RUN npm run lint -w @mocker/backend
21-
RUN npm run test -w @mocker/backend
2217
RUN npm run build:prod -w @mocker/backend
2318

2419
FROM node:20-alpine AS release
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": ["node_modules", "dist"]
4+
}

0 commit comments

Comments
 (0)