Repository navigation
127 lines (109 loc) · 5.05 KB
/
Copy pathci.yml
File metadata and controls
127 lines (109 loc) · 5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# StudyStack CI: on every push to any branch, check that the code builds and the
# server files are valid, before anything is deployed with ops/deploy.sh.
#
# Three jobs, run side by side on GitHub's standard runners (free for a public repo):
# frontend the production build of the Angular app (the same command its Dockerfile runs),
# after checking the shipped packages for known High or Critical holes
# backend the Release build of the API, and EF Core's check that the model matches
# the last migration (EF Core 9+ refuses to migrate at startup otherwise);
# restore fails on a known High or Critical hole in any NuGet package
# ops shellcheck on the server scripts, and docker compose config on the
# production stack alone and with the Tailscale add-on
#
# Nothing here deploys, and nothing reaches the tailnet. No secrets are used.
name: CI
on:
push:
branches: ["**"]
# CHANGED: every pull request gets its own full run, which checks the branch merged
# with main. The main ruleset requires these jobs, and a skipped job counts as a pass
# there, so pull request runs must never skip. A branch in this repo therefore runs
# CI twice (push and pull request); both are free for a public repo.
pull_request:
# The "Run workflow" button on the Actions tab.
workflow_dispatch:
# Read-only: CI only needs to check out the code.
permissions:
contents: read
# A newer push to the same branch cancels the older run, which is now out of date.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
frontend:
name: Frontend build
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v7
# Node 24, matching frontend/Dockerfile (node:24-slim). npm's download cache is
# keyed on the lockfile, so unchanged dependencies install from the cache.
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
# NEW: fail on a known High or Critical vulnerability in a package that ships to
# the browser. --omit=dev skips the build and test tools (Dependabot alerts and
# security updates cover those). npm audit asks npm's servers, so an npm outage
# can fail this step; re-run the job.
- name: Audit shipped packages
run: npm audit --omit=dev --audit-level=high
# CHANGED: a size-budget warning doesn't fail the build, but there should be none
# (they were cleared Oct 2026); an error budget does fail it.
- name: Production build
run: npx ng build --configuration production
backend:
name: Backend build and migration check
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: backend
env:
# Program.cs stops at startup without these, and dotnet ef runs Program.cs to find
# the DbContext. Placeholders only: nothing connects to a database here.
ConnectionStrings__DefaultConnection: "Host=localhost;Database=ci;Username=ci;Password=ci"
Jwt__SigningKey: "ci-only-placeholder-signing-key-not-a-secret"
DOTNET_NOLOGO: "true"
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
steps:
- uses: actions/checkout@v7
- uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
# CHANGED: NuGet audits every package, direct and transitive, while restoring.
# In CI only, a High (NU1903) or Critical (NU1904) advisory fails the restore;
# Moderate and Low stay warnings. %3B is an escaped ";" between the two codes.
- name: Restore
run: dotnet restore -p:NuGetAuditMode=all "-p:WarningsAsErrors=NU1903%3BNU1904"
- name: Build (Release)
run: dotnet build --configuration Release --no-restore
# The same version as the Microsoft.EntityFrameworkCore.Design package in backend.csproj.
- name: Install dotnet-ef
run: dotnet tool install --global dotnet-ef --version 10.0.15
# Fails when the model has changes that no migration covers yet.
- name: Check for pending model changes
run: dotnet ef migrations has-pending-model-changes --configuration Release --no-build
ops:
name: Server scripts and compose files
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
# shellcheck comes preinstalled on GitHub's Ubuntu runners.
- name: shellcheck
run: shellcheck ops/*.sh
# docker compose config resolves the files with .env's placeholders filled in and
# fails on a syntax or schema mistake. --quiet prints nothing when they're valid.
- name: Compose files
run: |
cp .env.example .env
docker compose -f docker-compose.prod.yml config --quiet
TS_HOSTNAME=studystack-ci docker compose -f docker-compose.prod.yml -f docker-compose.tailscale.yml config --quiet
echo "both compose configurations are valid"