Repository navigation
111 lines (99 loc) · 4.31 KB
/
Copy pathstd-drift.yml
File metadata and controls
111 lines (99 loc) · 4.31 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
name: Std drift
# The pages under `docs/docs/reference/package/schema/std/` are not written by hand: they are `comline
# doc` run over the standard library package core embeds
# (`core_stdlib/packages/std`), and the std block of `docs/mkdocs.yml` is its
# generated nav. This regenerates both and fails on a difference, so a
# docstring changed in core, or a renderer change in the CLI, reaches the
# site, and a hand edit to a generated page does not stay.
#
# It lives apart from the Docs workflow for the reason the CLI drift check
# does: it needs the CLI binary, so a Rust build, and a fetch against other
# repos has no business blocking a Pages deploy.
on:
schedule:
# Drift arrives when core's std or the CLI's renderer changes, which this
# repo never sees. Weekly is the backstop for that; the pull_request
# trigger below only covers edits made here.
- cron: '15 7 * * 1'
pull_request:
paths:
- 'docs/docs/reference/package/schema/std/**'
- 'docs/mkdocs.yml'
- 'scripts/sync-std-docs.py'
- '.github/workflows/std-drift.yml'
workflow_dispatch:
permissions:
contents: read
# A newer push to the same pull request supersedes this run; scheduled and
# manual runs queue.
concurrency:
group: std-drift-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
std:
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: 3.14.10
# Checking against the tip of the default branch, not a pinned rev: a
# CLI that has moved ahead of the docs is what this is here to catch.
# `HEAD` of the remote is its default branch, whatever that is called
# (ComlineProject repos are not consistent about `main` vs `master`);
# the repo is public, so this needs no token.
- name: Resolve the CLI's current commit
id: cli
run: |
sha=$(git ls-remote https://github.com/ComlineProject/cli HEAD | cut -f1)
[[ "$sha" =~ ^[0-9a-f]{40}$ ]] || { echo "::error::no commit for the CLI's HEAD"; exit 1; }
echo "sha=$sha" >> "$GITHUB_OUTPUT"
# Keyed on that exact commit, so an unchanged CLI costs nothing and a
# changed one rebuilds. Without this every run pays a full cargo build.
- name: Cache the comline binary
id: cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cargo/bin/comline
key: comline-${{ runner.os }}-rust-1.99.1-${{ steps.cli.outputs.sha }}
# The toolchain the CLI pins (its rust-toolchain.toml), by exact version:
# the runner's own Rust is whatever its image has that week.
- name: Install the Rust toolchain
if: steps.cache.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
with:
toolchain: 1.99.1
# comline-core and the generator crates resolve from the pinned git revs
# in the CLI's Cargo.lock.
- name: Install the CLI
if: steps.cache.outputs.cache-hit != 'true'
env:
CLI_SHA: ${{ steps.cli.outputs.sha }}
run: |
cargo install --locked --git https://github.com/ComlineProject/cli \
--rev "$CLI_SHA" comline
# std from core's default branch, rendered by the CLI's default branch.
- name: Check for drift
# `shell: bash` for pipefail: the `if !` must see the checker's exit
# status, not tee's.
shell: bash
run: |
if ! python3 scripts/sync-std-docs.py --check | tee drift.txt; then
{
echo '### Std drift'
echo
echo "The std pages no longer match what \`comline doc\` renders from core."
echo
echo '```'
cat drift.txt
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
exit 1
fi
cat drift.txt >> "$GITHUB_STEP_SUMMARY"