Skip to content

Commit 1efc5fa

Browse files
committed
Add basic CI
1 parent d6a01bb commit 1efc5fa

File tree

6 files changed

+123
-61
lines changed

6 files changed

+123
-61
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: "Install the dependencies for the HCI project"
2+
description: "Install uv, and then use uv to install Python dependencies for the project"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: "Install uv"
7+
uses: "astral-sh/setup-uv@v5"
8+
- name: "Install Python dependencies"
9+
shell: bash
10+
run: "uv sync"

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: "CI"
2+
on:
3+
pull_request:
4+
branches:
5+
- "reorg"
6+
push:
7+
branches:
8+
- "reorg"
9+
jobs:
10+
format:
11+
runs-on: "ubuntu-latest"
12+
steps:
13+
- uses: "actions/checkout@v4"
14+
- uses: "./.github/actions/install-dependencies"
15+
- name: "Make sure the code is properly formatted"
16+
working-directory: ./src
17+
run: "uv run ruff format --check"
18+
lint:
19+
runs-on: "ubuntu-latest"
20+
steps:
21+
- uses: "actions/checkout@v4"
22+
- uses: "./.github/actions/install-dependencies"
23+
- name: "Make sure the code is free of lint errors"
24+
working-directory: ./src
25+
run: "uv run ruff check"
26+
type:
27+
runs-on: "ubuntu-latest"
28+
steps:
29+
- uses: "actions/checkout@v4"
30+
- uses: "./.github/actions/install-dependencies"
31+
- name: "Run the type checker on the code"
32+
working-directory: ./src
33+
run: "uv run mypy ."
34+
test:
35+
runs-on: "ubuntu-latest"
36+
env:
37+
DJANGO_SECRET_KEY: "dummy"
38+
DJANGO_SETTINGS_MODULE: "config.settings.dev"
39+
PUBMED_API_KEY: "dummy"
40+
PYTHONUNBUFFERED: "1"
41+
steps:
42+
- uses: "actions/checkout@v4"
43+
- uses: "./.github/actions/install-dependencies"
44+
- name: "Run tests"
45+
working-directory: ./src
46+
run: "uv run pytest"
47+
build_docs:
48+
runs-on: "ubuntu-latest"
49+
steps:
50+
- uses: "actions/checkout@v4"
51+
- uses: "./.github/actions/install-dependencies"
52+
- name: "Build the developer documentation site"
53+
working-directory: ./docs
54+
run: "uv run make html"
55+
build_coverage:
56+
runs-on: "ubuntu-latest"
57+
steps:
58+
- uses: "actions/checkout@v4"
59+
- uses: "./.github/actions/install-dependencies"
60+
- name: "Collect test coverage stats"
61+
working-directory: ./src
62+
run: "uv run coverage -m pytest"
63+
- name: "Build the test coverage report"
64+
working-directory: ./src
65+
run: "uv run coverage html"

TODO.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
- [ ] The code transforms the underscore into a colon.
115115
- [ ] There is an include for help text
116116
- [ ] All help texts use this include.
117+
- [ ] The public recipes in the justfile use the private recipes.
118+
- [ ] All recipes in the justfile use `uv run`.
117119

118120
## The app test deployed to the test server and the prod server.
119121

@@ -126,7 +128,9 @@
126128
- [ ] We have the following CI workflow: PR approved and merged → deploy to prod.
127129
- [ ] We have a footer in Ingrid's purple.
128130
- [ ] The help text can be edited by non-developers.
129-
- [ ] We have a Sphinx dev docs site.
130-
- [ ] We have the following CI workflow: PR opened → check dev docs site.
131-
- [ ] We have the following CI workflow: PR approved and merged → deploy dev docs.
131+
- [x] We have a Sphinx dev docs site.
132+
- [x] We have the following CI workflow: PR opened → check dev docs site.
133+
- [x] We have the following CI workflow: PR opened → check test coverage report.
134+
- [ ] We have the following CI workflow: PR approved and merged → deploy dev docs site.
135+
- [ ] We have the following CI workflow: PR approved and merged → test coverage report.
132136
- [ ] We've added Firebase.

docs/source/_static/.keep

Whitespace-only changes.

docs/source/_templates/.keep

Whitespace-only changes.

justfile

Lines changed: 41 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -24,114 +24,97 @@
2424
set dotenv-load := true
2525

2626
#=======================================================================================
27-
# Aliases
27+
# Public Recipes
2828
#=======================================================================================
2929

30-
alias f := fmt
31-
alias l := lint
32-
alias ty := type
33-
alias t := test
34-
alias tc := test-contract
35-
# TODO(Liam): Revert back to regular check once you're done fixing type check issues.
36-
alias cv := coverage
37-
alias do := docs
38-
alias c := temp-check
39-
alias d := dev
30+
# Run all code quality checks.
31+
check: format lint type _dj_check test coverage
4032

41-
#=======================================================================================
42-
# Public Recipes
43-
#=======================================================================================
33+
# Show test coverage.
34+
coverage: _py_coverage
35+
36+
# Run the development server.
37+
dev: _dj_makemigrations _dj_migrate _dj_runserver
38+
39+
# Build the developer documentation site.
40+
docs: _sp_build_html
4441

4542
# Format Python code.
46-
fmt: _py_fmt
43+
format: _py_format
4744

4845
# Check Python code for common mistakes that can be identified by static analysis.
4946
lint: _py_lint
5047

51-
# Check Python code for problems with type hints.
52-
type: _py_type
53-
5448
# Run all tests.
55-
test: _dj_makemigrations _dj_migrate
56-
cd src && coverage run -m pytest
57-
58-
# Run contract tests.
59-
test-contract: _dj_makemigrations _dj_migrate
60-
cd src && pytest -m contract
49+
test: _dj_makemigrations _dj_migrate _py_test
6150

62-
# Show test coverage.
63-
coverage:
64-
cd src && coverage report -m
65-
66-
# Build the developer documentation site.
67-
docs:
68-
cd docs && make html
69-
70-
# Run all code quality checks.
71-
check: fmt lint type test _dj_check
72-
73-
# TODO(Liam): Remove this once you're done fixing type check issues.
74-
# Run all code quality checks except type checking.
75-
temp-check: fmt lint test _dj_check
76-
77-
# Run the development server.
78-
dev: _dj_makemigrations _dj_migrate
79-
cd src && python manage.py runserver
51+
# Check Python code for problems with type hints.
52+
type: _py_type
8053

8154
#=======================================================================================
8255
# Django Recipes
8356
#=======================================================================================
8457

8558
# Use the system check framework to inspect the project for common problems.
8659
_dj_check:
87-
cd src && python manage.py check
60+
cd src && uv run manage.py check
8861

8962
# Make migrations.
9063
_dj_makemigrations:
91-
cd src && python manage.py makemigrations
64+
cd src && uv run manage.py makemigrations
9265

9366
# Apply migrations.
9467
_dj_migrate:
95-
cd src && python manage.py migrate
68+
cd src && uv run manage.py migrate
9669

9770
# Run the development server.
9871
_dj_runserver:
99-
cd src && python manage.py runserver
72+
cd src && uv run manage.py runserver
10073

10174
# Enter the shell.
10275
_dj_shell:
103-
cd src && python manage.py shell
76+
cd src && uv run manage.py shell
10477

10578
#=======================================================================================
10679
# Python Code Quality Recipes
10780
#=======================================================================================
10881

10982
# Format all files in the current directory and all subdirectories.
110-
_py_fmt:
111-
uv run ruff format
83+
_py_format:
84+
cd src && uv run ruff format
11285

11386
# Check all files in the current directory and all subdirectories for formatting issues.
114-
_py_fmt_check:
115-
uv run ruff format --check
87+
_py_format_check:
88+
cd src && uv run ruff format --check
11689

11790
# Lint all files in the current directory and all subdirectories.
11891
_py_lint:
119-
uv run ruff check
92+
cd src && uv run ruff check
12093

12194
# Try to fix lint errors in current directory and all subdirectories.
12295
_py_lint_fix:
123-
uv run ruff check --fix
96+
cd src && uv run ruff check --fix
12497

12598
# Check type hints in the `src` directory and all subdirectories.
12699
_py_type:
127100
cd src && uv run mypy .
128101

102+
# Run test suite and collect coverage stats.
103+
_py_test:
104+
cd src && uv run coverage run -m pytest
105+
106+
# Report the test coverage stats.
107+
_py_coverage:
108+
cd src && uv run coverage report
109+
110+
# Build the test coverage report site.
111+
_py_build_coverage_html:
112+
cd src && uv run coverage html
113+
129114
#=======================================================================================
130115
# Sphinx Documentation Recipes
131116
#=======================================================================================
132117

133-
_sp_build:
134-
cd docs && make html
135-
136-
_sp_run:
137-
echo "Serving developer documentation: http://localhost:8001/html/index.html" && cd docs/build && python -m http.server 8001 --directory .
118+
# Build the developer documentation site.
119+
_sp_build_html:
120+
cd docs && uv run make html

0 commit comments

Comments
 (0)