-
Notifications
You must be signed in to change notification settings - Fork 71
174 lines (150 loc) · 5.08 KB
/
ci.yaml
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
name: agda-unimath CI
on:
# To run this workflow manually
workflow_dispatch:
inputs:
ref:
description: the repository ref to build
required: true
default: master
push:
branches:
- master
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
- ready_for_review
# Cancel previous runs of the same branch
concurrency:
group: '${{ github.workflow }}-${{ github.head_ref || github.run_id }}'
cancel-in-progress: true
jobs:
typecheck:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macOS-13, ubuntu-latest]
agda: ['2.6.4']
steps:
- name: Checkout our repository
uses: actions/checkout@v3
with:
path: master
- name: Setup Agda
uses: wenkokke/setup-agda@v2.1.0
with:
agda-version: ${{ matrix.agda }}
- uses: actions/cache/restore@v3
id: cache-agda-formalization
name: Restore Agda formalization cache
with:
path: master/_build
key:
${{ runner.os }}-check-${{ github.ref }}-${{ matrix.agda }}-${{
hashFiles('master/src/**') }}
restore-keys: |
${{ runner.os }}-check-${{ github.ref }}-${{ matrix.agda }}-
${{ runner.os }}-check-refs/heads/master-${{ matrix.agda }}-
- name: Typecheck library
run: |
cd master
make check
- name: Save Agda build cache
uses: actions/cache/save@v3
with:
path: master/_build
key: '${{ steps.cache-agda-formalization.outputs.cache-primary-key }}'
# Install Python and friends for website generation only where needed
- uses: actions/setup-python@v4
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
python-version: '3.8'
check-latest: true
cache: 'pip'
- run: python3 -m pip install -r master/scripts/requirements.txt
if: ${{ matrix.os == 'ubuntu-latest' }}
# We need to run the sources through Agda not only to get the highlighting
# (which is irrelevant for checking links), but because it flattens the
# directory structure to a format which is expected in the links we write.
# We don't need to produce this artifact for more than one configuration.
- name: Produce syntax highlighted markdown
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cd master
make website-prepare
# The lifetime of this cache is for one CI run only, so it's indexed by
# the run ID. According to the docs, caches are immutable, so we can't
# keep the same key for a branch and update it on pushes.
- name: Save pre-website cache
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/cache/save@v3
with:
key: pre-website-${{ github.run_id }}
path: master/docs
# We're only running the linkcheck renderer, so we don't need to install
# any other packages; that gives a warning during building, but doesn't
# fail the build.
link-check:
needs: typecheck
permissions:
actions: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: master
- uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: '0.4.34'
- uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-linkcheck
version: '0.7.7'
# Install Python and friends for website generation only where needed
- uses: actions/setup-python@v4
with:
python-version: '3.8'
check-latest: true
cache: 'pip'
- run: python3 -m pip install -r master/scripts/requirements.txt
- uses: actions/cache/restore@v3
with:
key: pre-website-${{ github.run_id }}
path: master/docs
# Tell mdbook to use only the linkcheck backend
- name: Check website links and bibtex references
env:
MDBOOK_OUTPUT: '{"linkcheck":{}}'
run: |
cd master
mdbook build
- name: Delete website cache
if: ${{ always() }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Note that the cleanup currently fails, because we don't give the
# `actions:write` permission to actions; hence the `set +e` to ignore
# the error
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
set +e
gh actions-cache delete pre-website-${{ github.run_id }} -R $REPO -B $BRANCH --confirm
# The previous command failing would report an error even with `set -e`
exit 0
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
check-latest: true
cache: 'pip'
- run: python3 -m pip install -r scripts/requirements.txt
- uses: pre-commit/action@v3.0.0