forked from PrairieLearn/PrairieLearn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
232 lines (199 loc) · 8.02 KB
/
Makefile
File metadata and controls
232 lines (199 loc) · 8.02 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
export PATH := $(CURDIR)/.venv/bin:$(PATH)
export TURBO_NO_UPDATE_NOTIFIER := 1
# On macOS, set flags for pygraphviz to find graphviz headers
# See https://github.com/pygraphviz/pygraphviz/blob/main/INSTALL.txt
ifeq ($(shell uname -s),Darwin)
export CFLAGS := -I$(shell brew --prefix graphviz)/include
export LDFLAGS := -L$(shell brew --prefix graphviz)/lib
endif
.PHONY: build
build:
@yarn turbo run build --output-logs=errors-only
build-verbose:
@yarn turbo run build
build-sequential:
@yarn turbo run --concurrency 1 build
# Note the `--compile-bytecode` flag, which is needed to ensure fast
# performance the first time things run:
# https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
python-deps-core:
@uv sync --no-default-groups --compile-bytecode
python-deps-docs:
@uv sync --only-group docs --compile-bytecode
python-deps-dev:
@uv sync --only-group dev --compile-bytecode
python-deps:
@uv sync --compile-bytecode
# This is a separate target since we can't currently install the necessary
# browsers in the development Docker image.
e2e-deps:
@yarn playwright install chromium --with-deps
deps:
@yarn
@$(MAKE) python-deps build
migrate:
@yarn migrate
migrate-dev:
@yarn migrate-dev
refresh-workspace-hosts:
@yarn refresh-workspace-hosts
refresh-workspace-hosts-dev:
@yarn refresh-workspace-hosts-dev
dev: start-support python-deps
@yarn dev
dev-vite: start-support python-deps
@yarn dev-vite
dev-bun: python-deps
@yarn dev-bun
dev-workspace-host: start-support
@yarn dev-workspace-host
dev-all:
@$(MAKE) -s -j2 dev dev-workspace-host
start: start-support
@yarn start
start-workspace-host: start-support
@yarn start-workspace-host
start-executor:
@node apps/prairielearn/dist/executor.js
start-all: start-support
@$(MAKE) -s -j2 start start-workspace-host
update-database-description:
@yarn workspace @prairielearn/prairielearn pg-describe postgres -o ../../database
start-support: start-postgres start-redis start-s3rver
start-postgres:
@scripts/start_postgres.sh
start-redis:
@scripts/start_redis.sh
start-s3rver:
@scripts/start_s3rver.sh
# Runs additional tests that may not work in the container.
test-all: test-js test-python test-e2e
test: test-js test-python
test-js: start-support
@yarn test
test-prairielearn-docker-smoke-tests: start-support
@yarn workspace @prairielearn/prairielearn run test:docker-smoke-tests
test-prairielearn-dist: start-support build
@yarn workspace @prairielearn/prairielearn run test:dist
test-python:
@uv run pytest
@uv run coverage xml -o ./apps/prairielearn/python/coverage.xml
test-prairielearn: start-support
@yarn workspace @prairielearn/prairielearn run test
test-e2e: start-support
@yarn workspace @prairielearn/prairielearn run test:e2e
fix-dependencies:
@yarn knip -c .knip.ts --fix --fix-type exports --fix-type types --fix-type dependencies
lint-dependencies:
@yarn knip -c .knip.ts
@yarn depcruise apps/*/src apps/*/assets packages/*/src
check-jsonschema:
@yarn dlx tsx scripts/gen-jsonschema.mts check
compile-badge-colors:
@npx sass --no-source-map apps/prairielearn/public/stylesheets/colors.scss apps/prairielearn/public/stylesheets/colors.css
@yarn prettier --write apps/prairielearn/public/stylesheets/colors.css
check-badge-contrast:
@node scripts/check-badge-contrast.mjs
check-npm-packages:
@node scripts/check-npm-packages.mjs
update-jsonschema:
@yarn dlx tsx scripts/gen-jsonschema.mts && yarn prettier --write "apps/prairielearn/src/schemas/**/*.json" && yarn prettier --write "docs/assets/*.schema.json"
# Runs additional third-party linters
lint-all: lint-js lint-python lint-html lint-mustache lint-docs lint-docker lint-actions lint-shell lint-sql-migrations lint-sql
lint: lint-js lint-python lint-html lint-links lint-changeset
lint-js:
@yarn eslint "**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,html,mustache}"
@yarn prettier "**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,md,sql,json,yml,toml,html,css,scss,sh}" --check
# Separate target since the caches don't respect updates to plugins.
# Split into two passes: the first pass lints the type-aware files without a cache (see `typeAwareFiles` in eslint.config.mjs), and the second
# pass lints the non-type-aware files with a cache. We check apps/prairielearn first since it is more likely to have lint errors.
# Keep the Prettier cache locations split too: each Prettier run reconciles all entries in its cache, even entries outside the current glob.
lint-js-cached:
@yarn eslint "apps/prairielearn/**/*.{ts,tsx}"
@yarn prettier "apps/prairielearn/**/*.{ts,tsx}" --check --cache --cache-strategy content --cache-location node_modules/.cache/prettier/apps-prairielearn-tsx
@yarn eslint --cache --cache-strategy content \
--ignore-pattern "apps/prairielearn/**/*.{ts,tsx}" \
"**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,html,mustache}"
@yarn prettier \
"**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,md,sql,json,yml,toml,html,css,scss,sh}" \
"!apps/prairielearn/**/*.{ts,tsx}" \
--check --cache --cache-strategy content --cache-location node_modules/.cache/prettier/non-apps-prairielearn-tsx
lint-python:
@uv run ruff check ./
@uv run ruff format --check ./
lint-docs-links: build-docs
@yarn linkinator ./site | python3 scripts/process_linkinator_output.py
# Lint HTML files, and the build output of the docs
lint-html:
@yarn htmlhint "testCourse/**/question.html" "exampleCourse/**/question.html" "site"
lint-mustache:
@yarn htmlmustache check
lint-markdown:
@yarn markdownlint-cli2
lint-links:
@node scripts/validate-links.mjs
lint-docker:
@hadolint ./graders/**/Dockerfile ./workspaces/**/Dockerfile ./images/**/Dockerfile Dockerfile
lint-shell:
@shellcheck -S warning $(shell find . -type f -name "*.sh" ! -path "./node_modules/*" ! -path "./.venv/*" ! -path "./testCourse/*")
lint-sql:
@uv run sqlfluff lint
lint-sql-migrations:
@uv run squawk apps/prairielearn/src/migrations/*.sql
lint-actions:
@actionlint
lint-changeset:
@yarn changeset status
# Runs additional third-party formatters
format-all: format-js format-python format-sql format-mustache
format: format-js format-python
format-sql:
@uv run sqlfluff fix
fix-js:
@yarn eslint --ext js --fix "**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,html,mustache}"
@yarn prettier --write "**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,md,sql,json,yml,toml,html,css,scss,sh}"
# This is a separate target since the caches don't respect updates to plugins.
fix-js-cached:
@yarn prettier --write --cache --cache-strategy content "**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,md,sql,json,yml,toml,html,css,scss,sh}"
@yarn eslint --ext js --fix --cache --cache-strategy content "**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,html,mustache}"
format-js:
@yarn prettier --write "**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,md,sql,json,yml,toml,html,css,scss,sh}"
format-js-cached:
@yarn prettier --write --cache --cache-strategy content "**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,md,sql,json,yml,toml,html,css,scss,sh}"
format-mustache:
@yarn htmlmustache format --write
format-python:
@uv run ruff check --fix ./
@uv run ruff format ./
format-changed:
@node scripts/format-changed.mjs
typecheck: typecheck-js typecheck-python typecheck-contrib typecheck-scripts typecheck-sql
typecheck-contrib:
@yarn tsgo -p contrib --noEmit
typecheck-scripts:
@yarn tsgo -p scripts --noEmit
typecheck-js:
@yarn turbo run build --output-logs=errors-only
typecheck-python: python-deps
@yarn pyright
typecheck-sql:
@yarn postgres-language-server check .
changeset:
@yarn changeset
@yarn prettier --write ".changeset/**/*.md"
lint-docs: lint-d2 lint-links lint-markdown lint-docs-links
build-docs:
@NO_MKDOCS_2_WARNING=1 DISABLE_MKDOCS_2_WARNING=true uv run mkdocs build --strict
dev-docs:
@NO_MKDOCS_2_WARNING=1 DISABLE_MKDOCS_2_WARNING=true uv run mkdocs serve --livereload
format-d2:
@d2 fmt docs/**/*.d2
lint-d2:
@d2 fmt --check docs/**/*.d2
dangerous-drop-all-dbs:
@echo "Dropping all databases matching 'prairielearn_%'..."
@psql -h localhost -U postgres -tAc "SELECT datname FROM pg_database WHERE datname LIKE 'prairielearn_%'" | while read db; do \
echo "Dropping $$db"; \
psql -h localhost -U postgres -c "DROP DATABASE \"$$db\""; \
done
ci: lint typecheck lint-dependencies test