Skip to content

Commit cc24943

Browse files
nos1dot618claude
andcommitted
ci: check formatting, lint, types and links
Runs the pre-commit hooks, builds the site against the language repository and verifies every link and anchor with lychee, also weekly to catch external links that rot. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 7325f17 commit cc24943

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: CI
2+
3+
# Checks the build scripts, builds the site, and verifies every link in it.
4+
# The weekly run catches external links that have rotted since the last change.
5+
on:
6+
push:
7+
branches: [master]
8+
pull_request:
9+
workflow_dispatch:
10+
schedule:
11+
- cron: "41 4 * * 1"
12+
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
env:
21+
UPSTREAM: https://github.com/lambda-discipline/lambda-discipline
22+
UPSTREAM_BRANCH: master
23+
24+
jobs:
25+
lint:
26+
name: Format, lint and types
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: actions/setup-python@v5
31+
with:
32+
python-version: "3.13"
33+
cache: pip
34+
cache-dependency-path: requirements*.txt
35+
- run: pip install -r requirements-dev.txt
36+
# black, ruff, mypy and the file hygiene hooks, as configured in
37+
# .pre-commit-config.yaml.
38+
- run: pre-commit run --all-files --show-diff-on-failure --color always
39+
40+
build:
41+
name: Build and check links
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Clone the language repository
47+
run: git clone --depth 1 --branch "$UPSTREAM_BRANCH" "$UPSTREAM" .cache/lambda-discipline
48+
49+
- name: Install Rust
50+
# Installs the version the language repository's rust-toolchain.toml asks for.
51+
working-directory: .cache/lambda-discipline
52+
run: rustup toolchain install
53+
54+
- uses: Swatinem/rust-cache@v2
55+
with:
56+
workspaces: .cache/lambda-discipline
57+
58+
- uses: actions/setup-python@v5
59+
with:
60+
python-version: "3.13"
61+
cache: pip
62+
cache-dependency-path: requirements*.txt
63+
64+
- run: pip install -r requirements.txt
65+
66+
- name: Build the site
67+
run: python build.py --no-update
68+
69+
- uses: actions/upload-artifact@v4
70+
with:
71+
name: site
72+
path: _site
73+
include-hidden-files: true
74+
75+
- name: Restore the link checker's cache
76+
uses: actions/cache@v4
77+
with:
78+
path: .lycheecache
79+
key: lychee-${{ github.sha }}
80+
restore-keys: lychee-
81+
82+
- name: Check links
83+
# Settings are in lychee.toml. --root-dir resolves links such as
84+
# /reference/ against the built site instead of the live one.
85+
uses: lycheeverse/lychee-action@v2
86+
with:
87+
lycheeVersion: v0.24.2
88+
args: --root-dir "${{ github.workspace }}/_site" _site
89+
fail: true
90+
jobSummary: true
91+
env:
92+
# Authenticated requests avoid GitHub's rate limit for links to it.
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎lychee.toml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Link checker settings for lychee 0.24 (https://lychee.cli.rs). Run it on a built site:
2+
# lychee --root-dir "$PWD/_site" _site
3+
# Add --offline to check only the site's own pages.
4+
5+
# Check that `#fragment` links point at an element that exists.
6+
include_fragments = "full"
7+
8+
# Links to a directory resolve to its index.html, like on GitHub Pages.
9+
index_files = ["index.html"]
10+
11+
# Remember results for a day so reruns don't hammer the same servers.
12+
cache = true
13+
max_cache_age = "1d"
14+
15+
max_retries = 3
16+
timeout = 20
17+
18+
# 429 means rate limited, not broken.
19+
accept = ["200..=299", "429"]
20+
21+
exclude = [
22+
# The site's own absolute URLs (canonical links, the sitemap) point at the
23+
# deployed copy; the same pages are checked as local files instead.
24+
'^https://lambda-discipline\.github\.io',
25+
]

0 commit comments

Comments
 (0)