-
Notifications
You must be signed in to change notification settings - Fork 3
153 lines (147 loc) · 6.29 KB
/
Copy pathci.yml
File metadata and controls
153 lines (147 loc) · 6.29 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: CI
on:
pull_request:
push:
branches: [main]
# Shared by every job. POSTGRES_PASSWORD is required at settings import
# (no default), so even the non-DB jobs need the block to load Django.
env:
DJANGO_ENV: local
DJANGO_SECRET_KEY: ci-not-a-secret
BASE_URL: http://localhost:8000
APP_BASE_URL: http://localhost:3001
MARKETING_BASE_URL: http://localhost:3000
# No LLM in CI ; the test suite mocks the engine, this just satisfies config.
ENGINE_BASE_URL: http://localhost:11434/v1
ENGINE_MODEL: qwen2.5:7b
POSTGRES_DB: openmagpie
POSTGRES_USER: openmagpie
POSTGRES_PASSWORD: openmagpie
POSTGRES_HOST: localhost # the service is published on the runner's localhost
POSTGRES_PORT: "5432"
jobs:
# PR-only: validate the source branch name. On push to main there's no
# feature branch to check (main is exempt), so this job skips.
branch-name:
name: branch-name
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check branch name
run: ./scripts/check-branch-name.sh "${{ github.head_ref }}"
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
# --frozen: fail if uv.lock drifts. --all-packages: every workspace
# member (core + cli + schema) incl. dev tools (ruff, ty).
- name: Sync workspace
run: uv sync --all-packages --frozen
- name: ruff
run: |
uv run ruff check .
uv run ruff format --check .
- name: ty
run: uv run --package openmagpie-core ty check apps/core packages/openmagpie-schema tools/schema_sync
- name: whitespace + file length
run: |
./scripts/check-whitespace.sh
./scripts/check-file-length.sh
# Everything in scripts/ is POSIX sh; -s sh fails on any bashism so the
# curl|sh installer (and the dev tooling) stays portable. shellcheck ships
# on GitHub's ubuntu runners today; install it if a future image drops it.
- name: shellcheck (scripts are POSIX sh)
run: |
command -v shellcheck >/dev/null || { sudo apt-get update && sudo apt-get install -y shellcheck; }
find scripts -name '*.sh' -print0 | xargs -0 -r shellcheck -s sh
# Fail if a model change has no committed migration — compares models.py
# against the migration files (the autodetector), no DB involved.
# --check implies no-write on Django >=4.2, so no --dry-run needed.
- name: migrations match models
run: uv run --package openmagpie-core python apps/core/manage.py makemigrations --check
# The committed schema.json is generated from the Pydantic models (the
# web client generates its validators from it). Mirror the local
# pre-commit `schema-sync` hook so a stale artifact, a forgotten model,
# or an input mode divergence can't reach main via a contributor who
# skipped `make hooks` or used `git commit --no-verify`. --no-sync uses
# the workspace env synced above (the generator needs pydantic + the
# openmagpie-schema package, both installed by that sync).
- name: schema.json is fresh
run: uv run --no-sync python -m tools.schema_sync.generate --check
# Smoke-test the CLI wheel build (the PyPI publish path in release-cli.yml).
# A packaging break - name drift, a missing schema force-include - fails
# here instead of at the first real release. Build only; not published.
- name: CLI wheel builds
run: uv build --package openmagpie --wheel
test:
name: test
runs-on: ubuntu-latest
# The app is a multi-writer pipeline on Postgres (not SQLite), so the
# test DB needs a real Postgres ; mirror the compose dev creds.
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: openmagpie
POSTGRES_USER: openmagpie
POSTGRES_PASSWORD: openmagpie
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U openmagpie -d openmagpie"
--health-interval 5s --health-timeout 3s --health-retries 10
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Sync workspace
run: uv sync --all-packages --frozen
# Run from apps/core so Django's test discovery finds every app (they are
# importable as top-level there); no hardcoded app list to drift out of date.
- name: Tests
working-directory: apps/core
run: uv run --package openmagpie-core python manage.py test --noinput
# Backstop for hop 2 of the schema contract (schema.json -> web zod). The `lint`
# job's "schema.json is fresh" step guards hop 1 (Pydantic -> schema.json); this
# guards that the committed web validators (packages/schema/src/generated.ts)
# aren't stale relative to schema.json + the generator. Mirrors the local
# `web-schema` pre-commit hook, unconditionally, for anyone without pnpm.
web-schema:
name: web-schema
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
cache-dependency-path: web/pnpm-lock.yaml
- name: Install web deps
working-directory: web
run: pnpm install --frozen-lockfile
- name: generated.ts is fresh
working-directory: web
run: pnpm --filter @magpie/schema check
# Freshness is a string diff; typecheck the WHOLE workspace (not just
# @magpie/schema) so a contract change that type-breaks a CONSUMER
# (@magpie/api-utils, the apps) or a zod-4 usage issue fails on the PR here,
# not later on push-to-main (images.yml). Deps are already installed above.
- name: web packages typecheck
working-directory: web
run: pnpm -r typecheck
# typecheck never EXECUTES the module, so also run the generated schemas: a
# fresh but throw-on-import generated.ts (a zod runtime bump) fails here too.
- name: generated.ts runtime smoke
working-directory: web
run: pnpm --filter @magpie/schema smoke