Skip to content

Commit 69e508a

Browse files
committed
CI changes coming from add-combi
* Replace `lakefile.toml` by `lakefile.lean` * Acquire `scripts/build_docs.sh` * Drop `scripts/bump.sh` * Rename `docs/` to `website/`
1 parent b1f5c2a commit 69e508a

File tree

16 files changed

+127
-154
lines changed

16 files changed

+127
-154
lines changed

.github/workflows/push.yml

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Build Lean project
2+
13
on:
24
push:
35
branches:
@@ -29,94 +31,85 @@ jobs:
2931
name: Build project
3032
steps:
3133
- name: Checkout project
32-
uses: actions/checkout@v2
33-
with:
34-
fetch-depth: 0
34+
uses: actions/checkout@v4
3535

36-
- name: Print files to upstream
37-
run: |
38-
grep -r --files-without-match 'import PersistentDecomp' PersistentDecomp | sort > 1.txt
39-
grep -r --files-with-match 'sorry' PersistentDecomp | sort > 2.txt
40-
mkdir -p docs/_includes
41-
comm -23 1.txt 2.txt | sed -e 's/^\(.*\)$/- [`\1`](https:\/\/github.com\/Paul-Lez\/PersistentDecomp\/blob\/master\/\1)/' > docs/_includes/files_to_upstream.md
42-
rm 1.txt 2.txt
36+
- name: Copy README.md to website/index.md
37+
run: cp README.md website/index.md
4338

44-
- name: Count sorries
45-
run: python scripts/count_sorry.py
39+
- name: Check PersistentDecomp.Mathlib only imports from Mathlib or PersistentDecomp.Mathlib
40+
run: python3 scripts/check_mathlib_imports.py
41+
42+
- name: Upstreaming dashboard
43+
run: |
44+
mkdir -p website/_includes
45+
python3 scripts/upstreaming_dashboard.py
4646
4747
- name: Install elan
48-
run: curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain leanprover/lean4:4.5.0
48+
run: curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain leanprover/lean4:4.15.0
4949

5050
- name: Get cache
5151
run: ~/.elan/bin/lake exe cache get || true
5252

5353
- name: Build project
5454
run: ~/.elan/bin/lake build PersistentDecomp
5555

56-
- name: Cache mathlib docs
57-
uses: actions/cache@v3
56+
- name: File dependencies
57+
run: |
58+
sudo apt-get update
59+
sudo apt install graphviz -y
60+
~/.elan/bin/lake exe graph website/file_deps.pdf
61+
62+
- name: Cache documentation
63+
uses: actions/cache@v4
5864
with:
59-
path: |
60-
.lake/build/doc/Init
61-
.lake/build/doc/Lake
62-
.lake/build/doc/Lean
63-
.lake/build/doc/Std
64-
.lake/build/doc/Mathlib
65-
.lake/build/doc/declarations
65+
path: website/docs
6666
key: MathlibDoc-${{ hashFiles('lake-manifest.json') }}
67-
restore-keys: |
68-
MathlibDoc-
67+
restore-keys: MathlibDoc-
6968

7069
- name: Build documentation
71-
run: ~/.elan/bin/lake -R -Kenv=dev build PersistentDecomp:docs
70+
run: scripts/build_docs.sh
7271

73-
# - name: Build blueprint and copy to `docs/blueprint`
72+
# - name: Build blueprint and copy to `website/blueprint`
7473
# uses: xu-cheng/texlive-action@v2
7574
# with:
76-
# docker_image: ghcr.io/xu-cheng/texlive-full:20231201
75+
# scheme: full
7776
# run: |
7877
# apk update
7978
# apk add --update make py3-pip git pkgconfig graphviz graphviz-dev gcc musl-dev
8079
# git config --global --add safe.directory $GITHUB_WORKSPACE
8180
# git config --global --add safe.directory `pwd`
82-
# python3 -m venv env
83-
# source env/bin/activate
84-
# pip install --upgrade pip requests wheel
85-
# pip install pygraphviz --global-option=build_ext --global-option="-L/usr/lib/graphviz/" --global-option="-R/usr/lib/graphviz/"
86-
# pip install leanblueprint
87-
# leanblueprint pdf
88-
# cp blueprint/print/print.pdf docs/blueprint.pdf
89-
# leanblueprint web
90-
# cp -r blueprint/web docs/blueprint
91-
92-
- name: Move documentation to `docs/docs`
81+
# python3 -m pip install --upgrade pip requests wheel
82+
# python3 -m pip install pygraphviz --global-option=build_ext --global-option="-L/usr/lib/graphviz/" --global-option="-R/usr/lib/graphviz/"
83+
# pip install -r blueprint/requirements.txt
84+
# python3 -m pip install invoke
85+
# inv all
86+
87+
- name: Copy documentation to `website/docs`
9388
run: |
94-
mv .lake/build/doc docs/docs
89+
mkdir -p website/docs
90+
mv docs/build website/docs
9591
9692
- name: Bundle dependencies
9793
uses: ruby/setup-ruby@v1
9894
with:
99-
working-directory: docs
100-
ruby-version: "3.0" # Specify Ruby version
101-
bundler-cache: true # Enable caching for bundler
95+
working-directory: website
96+
ruby-version: "3.0" # Not needed with a .ruby-version file
97+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
10298

103-
- name: Build website using Jekyll
104-
working-directory: docs
105-
run: JEKYLL_ENV=production bundle exec jekyll build # Note this will also copy the blueprint and API doc into docs/_site
99+
- name: Bundle website
100+
working-directory: website
101+
run: JEKYLL_ENV=production bundle exec jekyll build
106102

107103
- name: Upload docs & blueprint artifact
108-
uses: actions/upload-pages-artifact@v1
104+
uses: actions/upload-pages-artifact@v3
109105
with:
110-
path: docs/_site
106+
path: website/_site
111107

112108
- name: Deploy to GitHub Pages
113109
id: deployment
114-
uses: actions/deploy-pages@v1
115-
116-
# - name: Check declarations
117-
# run: |
118-
# ~/.elan/bin/lake exe checkdecls blueprint/lean_decls
110+
uses: actions/deploy-pages@v4
119111

120112
- name: Make sure the cache works
121113
run: |
122-
mv docs/docs .lake/build/doc
114+
mkdir -p docbuild/.lake/build/doc
115+
mv website/docs docbuild/.lake/build/doc

docs/index.md

Lines changed: 0 additions & 62 deletions
This file was deleted.

scripts/build_docs.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Build HTML documentation for add-combi
2+
# The output will be located in docs/build
3+
4+
# Template lakefile.toml
5+
template() {
6+
cat <<EOF
7+
name = "docbuild"
8+
reservoir = false
9+
version = "0.1.0"
10+
packagesDir = "../.lake/packages"
11+
12+
[[require]]
13+
name = "PersistentDecomp"
14+
path = "../"
15+
16+
[[require]]
17+
scope = "leanprover"
18+
name = "doc-gen4"
19+
rev = "TOOLCHAIN"
20+
EOF
21+
}
22+
23+
# Create a temporary docbuild folder
24+
mkdir -p docbuild
25+
26+
# Equip docbuild with the template lakefile.toml
27+
template > docbuild/lakefile.toml
28+
29+
# Substitute the toolchain from lean-toolchain into docbuild/lakefile.toml
30+
sed -i s/TOOLCHAIN/`grep -oP 'v4\..*' lean-toolchain`/ docbuild/lakefile.toml
31+
32+
# Fetch the docs cache if it exists
33+
mkdir -p website/docs
34+
mkdir -p docbuild/.lake/build/doc
35+
mv website/docs docbuild/.lake/build/doc
36+
37+
# Initialise docbuild as a Lean project
38+
cd docbuild
39+
MATHLIB_NO_CACHE_ON_UPDATE=1 # Disable an error message due to a non-blocking bug. See Zulip
40+
~/.elan/bin/lake update PersistentDecomp
41+
~/.elan/bin/lake exe cache get
42+
43+
# Build the docs
44+
~/.elan/bin/lake build PersistentDecomp:docs
45+
46+
# Move them out of docbuild
47+
cd ../
48+
mkdir -p docs/build
49+
mv docbuild/.lake/build/doc docs/build
50+
51+
# Clean up after ourselves
52+
rm -rf docbuild

scripts/check_mathlib_imports.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
3+
def list_files_by_type_recursive(folder_path, file_extension):
4+
"""Recursively lists all files in a folder and subfolders with the specified file extension."""
5+
matching_files = []
6+
for root, _, files in os.walk(folder_path):
7+
matching_files.extend(os.path.join(root, f) for f in files if f.endswith(file_extension))
8+
return matching_files
9+
10+
folder = "PersistentDecomp/Mathlib"
11+
extension = ".lean"
12+
files = list_files_by_type_recursive(folder, extension)
13+
14+
for file in files:
15+
code = None
16+
with open(file, "r") as reader:
17+
code = reader.read()
18+
lines = code.split("\n")
19+
header = [line for line in lines if line.lstrip().startswith("import")]
20+
21+
for imp in header:
22+
imp_file = imp.lstrip()[len("import"):].strip()
23+
if (not imp_file.startswith("Mathlib.")) and \
24+
(not imp_file.startswith("PersistentDecomp.Mathlib")):
25+
raise OSError(f"""
26+
MathlibImportError: A file in PersistentDecomp.Mathlib imports a file not in Mathlib or PersistentDecomp.Mathlib
27+
\tImporting file: {file}
28+
\tImported file: {imp_file}
29+
""")

scripts/count_sorry.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

scripts/update_mathlib.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)