-
Notifications
You must be signed in to change notification settings - Fork 12
252 lines (221 loc) · 7.74 KB
/
ci.yml
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- published
- released
name: "Build and check HTML"
jobs:
build:
name: Build site and generate HTML
runs-on: ubuntu-latest
steps:
- name: Install deps for figures (OS packages)
run: |
sudo apt update && sudo apt install -y poppler-utils
- name: Install deps for figures (TeX)
uses: teatimeguest/setup-texlive-action@v3
with:
packages: |
scheme-minimal
latex-bin
fontspec
standalone
pgf
pdftexcmds
luatex85
lualatex-math
infwarerr
ltxcmds
xcolor
fontawesome
spath3
inter
epstopdf-pkg
tex-gyre
tex-gyre-math
unicode-math
amsmath
sourcecodepro
- name: Install elan
run: |
set -o pipefail
curl -sSfL https://github.com/leanprover/elan/releases/download/v3.0.0/elan-x86_64-unknown-linux-gnu.tar.gz | tar xz
./elan-init -y --default-toolchain none
echo "$HOME/.elan/bin" >> "$GITHUB_PATH"
- uses: actions/checkout@v4
- name: Lean Version
run: |
lean --version
- name: Cache .lake
uses: actions/cache/restore@v4
with:
path: .lake
key: ${{ runner.os }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ hashFiles('lakefile.lean') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ hashFiles('lakefile.lean') }}-${{ github.sha }}
${{ runner.os }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ hashFiles('lakefile.lean') }}
${{ runner.os }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-
${{ runner.os }}-${{ hashFiles('lean-toolchain') }}-
- name: Build figures
run: |
lake build figures
- name: Build
run: |
lake build
- name: Save cache for .lake
uses: actions/cache/save@v4
with:
path: .lake
key: ${{ runner.os }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ hashFiles('lakefile.lean') }}-${{ github.sha }}
- name: Generate HTML (non-release)
if: github.event_name != 'release'
run: |
lake --quiet exe generate-manual --depth 2 --with-word-count "words.txt" --verbose --without-html-single
- name: Generate HTML (release)
if: github.event_name == 'release'
# Include the base to fix trailing slash issue on Netlify
run: |
lake --quiet exe generate-manual --depth 2 --with-word-count "words.txt" --verbose --site-base-url "/doc/reference/latest/"
- name: Generate proofreading HTML
if: github.event_name == 'pull_request'
run: |
lake --quiet exe generate-manual --depth 2 --verbose --draft --without-html-single --output "_out/draft"
- name: Save generated HTML to artifact storage
uses: actions/upload-artifact@v4
with:
name: 'html'
path: '_out/'
retention-days: 5
overwrite: true
- name: Report word count
run: |
echo "Word Counts"
echo "-----------"
cat words.txt
- name: Save word count
run: |
echo "# Word Counts" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cat words.txt >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Offline link checker (non-release)
uses: lycheeverse/[email protected]
if: github.event_name == 'push' || github.event_name == 'pull_request'
with:
fail: true
args: --base './_out/html-multi/' --no-progress --offline './_out/html-multi/**/*.html'
# This saved number is used by a workflow_run trigger. It
# manages labels that indicate the status of the built HTML.
- name: Save PR number
if: github.event_name == 'pull_request'
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
- uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: pr
path: pr/
deploy:
name: Deploy release
runs-on: ubuntu-latest
needs: [build]
if: github.event_name == 'release'
outputs:
ref-url: ${{ steps.deploy-release.outputs.deploy-url }}
steps:
- name: Get generated HTML from artifact storage
uses: actions/download-artifact@v4
with:
name: 'html'
path: '_out/'
# deploy-alias computes a URL component for the PR preview. This
# is so we can have a stable name to use for feedback on draft
# material.
- id: deploy-alias
uses: actions/github-script@v7
name: Compute Alias
with:
script: |
if (process.env.PR) {
return `pr-${process.env.PR}`
} else {
return 'deploy-preview-main';
}
env:
PR: ${{ github.event.number }}
# deploy-info computes metadata that's shown in the Netlify interface
# about the deployment (for non-PR deploys)
- id: deploy-info
name: Compute Deployment Metadata
if: github.event_name != 'pull_request'
run: |
set -e
echo "message=$(git log -1 --pretty=format:"%s")" >> "$GITHUB_OUTPUT"
# When a release is created in GH, push to the main site without proofreading info
- name: Deploy releases when tags are pushed
id: deploy-release
uses: nwtgck/[email protected]
if: github.event_name == 'release'
with:
publish-dir: _out/html-multi
production-branch: main
production-deploy: true
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: |
Release from tag ${{ github.ref }}
enable-commit-comment: false
enable-pull-request-comment: false
fails-without-credentials: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: "447031bf-9a96-4cee-831b-1f73599a7cb2"
check-links:
name: Check links
runs-on: ubuntu-latest
needs: [deploy]
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
.skip-link-check
- name: Online link checker
uses: filiph/[email protected]
continue-on-error: true
with:
arguments: --skip-file .skip-link-check -e ${{ needs.deploy.outputs.ref-url }}
prose-lint:
name: Check prose
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- name: Get generated HTML from artifact storage
uses: actions/download-artifact@v4
with:
name: 'html'
path: '_out/'
- name: Install prose linter
run: |
sudo snap install vale
- name: Preprocess HTML for prose linter
run: |
# First the HTML needs preprocessing to work well with Vale
pushd _out
python3 -m venv venv
. venv/bin/activate
pip install beautifulsoup4
python ../.vale/scripts/rewrite_html.py html-multi html-vale
popd
- name: Prose linter
run: |
set -o pipefail
vale --output JSON _out/html-vale/ | python .vale/scripts/report.py