Skip to content

Commit 8733a8f

Browse files
committed
move build steps into Makefile, call make check from CI
1 parent b463de0 commit 8733a8f

3 files changed

Lines changed: 23 additions & 46 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,7 @@ jobs:
2525
node-version: 20
2626
cache: npm
2727

28-
- run: npm ci
29-
30-
- run: npx myst build --html
31-
32-
- run: node scripts/generate-feed.js
33-
34-
- run: npx linkinator ./_build/html/
35-
36-
- name: Accessibility check
37-
# pa11y-ci needs a running server to crawl the built site.
38-
# Chromium requires --no-sandbox on GitHub Actions runners (see .pa11yci).
39-
run: |
40-
npx serve _build/html -p 4117 &
41-
SERVER_PID=$!
42-
# Ensure the server is killed even if pa11y-ci fails, so the
43-
# background process doesn't linger until the job times out.
44-
trap "kill $SERVER_PID" EXIT
45-
# Wait for server to be ready (more reliable than a fixed sleep)
46-
timeout 30 bash -c 'until curl -s http://localhost:4117 > /dev/null; do sleep 1; done'
47-
npx pa11y-ci --sitemap http://localhost:4117/sitemap.xml \
48-
--sitemap-find 'http://localhost:[0-9]+' \
49-
--sitemap-replace 'http://localhost:4117'
28+
- run: make check
5029

5130
- uses: peaceiris/actions-gh-pages@v4
5231
with:

.github/workflows/pr.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,7 @@ jobs:
2424
node-version: 20
2525
cache: npm
2626

27-
- run: npm ci
28-
29-
- run: npx myst build --html
30-
31-
- run: node scripts/generate-feed.js
32-
33-
- run: npx linkinator ./_build/html/
34-
35-
- name: Accessibility check
36-
# pa11y-ci needs a running server to crawl the built site
37-
run: |
38-
npx serve _build/html -p 4117 &
39-
SERVER_PID=$!
40-
# Ensure the server is killed even if pa11y-ci fails, so the
41-
# background process doesn't linger until the job times out.
42-
trap "kill $SERVER_PID" EXIT
43-
# Wait for server to be ready (more reliable than a fixed sleep)
44-
timeout 30 bash -c 'until curl -s http://localhost:4117 > /dev/null; do sleep 1; done'
45-
npx pa11y-ci --sitemap http://localhost:4117/sitemap.xml \
46-
--sitemap-find 'http://localhost:[0-9]+' \
47-
--sitemap-replace 'http://localhost:4117'
27+
- run: make check
4828

4929
# continue-on-error because fork PRs don't have write access to push
5030
# the preview to gh-pages. The build check above still validates the PR.

Makefile

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
1-
.PHONY: help install html serve clean
1+
.PHONY: help install html serve clean lint a11y check
22
.DEFAULT_GOAL := help
33

44
help:
55
@grep ": ##" Makefile | grep -v grep | tr -d '#'
66

77
install: ## Install Node dependencies (mystmd)
8-
npm install
8+
npm ci
99

1010
html: ## Build MyST site in ./_build/html
1111
html: install
12-
npx myst build --html && node scripts/generate-feed.js
12+
npx myst build --html
13+
node scripts/generate-feed.js
1314

1415
serve: ## Serve MyST site locally (live reload)
1516
serve: install
1617
npx myst start
1718

19+
lint: ## Check for broken links in the built site
20+
lint: html
21+
npx linkinator ./_build/html/
22+
23+
a11y: ## Run accessibility checks against the built site
24+
a11y: html
25+
npx serve _build/html -p 4117 & \
26+
SERVER_PID=$$!; \
27+
trap "kill $$SERVER_PID" EXIT; \
28+
timeout 30 bash -c 'until curl -s http://localhost:4117 > /dev/null; do sleep 1; done'; \
29+
npx pa11y-ci --sitemap http://localhost:4117/sitemap.xml \
30+
--sitemap-find 'http://localhost:[0-9]+' \
31+
--sitemap-replace 'http://localhost:4117'
32+
33+
check: ## Run full build + lint + accessibility (same as CI)
34+
check: lint a11y
35+
1836
clean: ## Remove built files
1937
clean:
2038
rm -rf _build

0 commit comments

Comments
 (0)