feat: new CI setup

main
Henrik Böving 2023-03-11 17:48:27 +01:00
parent 755f06fb0d
commit 0c415232cd
6 changed files with 93 additions and 63 deletions

View File

@ -1,8 +1,6 @@
name: build and deploy docs name: std4 test build
on: on:
schedule:
- cron: '0 */8 * * *' # every 8 hours
push: push:
branches: branches:
- "main" - "main"
@ -10,7 +8,7 @@ on:
jobs: jobs:
build: build:
name: build and deploy docs name: std4 test build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repo - name: Checkout repo
@ -27,27 +25,14 @@ jobs:
run: | run: |
lake build lake build
- name: Checkout and compile mathlib4 - name: Checkout and compile std4
run: | run: |
cd ../ cd ../
git clone https://github.com/leanprover-community/mathlib4 git clone https://github.com/leanprover/std4
cd mathlib4 cd std4
lake exe cache get
lake build lake build
- name: generate docs (PRs only) - name: generate docs
if: github.event_name == 'pull_request'
run: | run: |
cd ../ cd ../
./doc-gen4/deploy_docs.sh "mathlib4" "doc-gen4" "false" "LeanInk" ./doc-gen4/test_docs.sh "std4" "doc-gen4"
env:
DOC_GEN_REF: ${{ github.event.pull_request.head.sha }}
- name: generate and deploy docs (main only)
if: (github.event_name == 'push' || github.event_name == 'schedule') && github.repository == 'leanprover/doc-gen4' && github.ref_name == 'main'
run: |
cd ../
./doc-gen4/deploy_docs.sh "mathlib4" "doc-gen4" "true" "LeanInk"
env:
MATHLIB4_DOCS_KEY: ${{ secrets.MATHLIB4_DOCS_KEY }}
DOC_GEN_REF: ${{ github.sha }}

29
.github/workflows/mathlib4docs.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: build and deploy mathlib4 docs
on:
workflow_dispatch:
schedule:
- cron: '0 */8 * * *' # every 8 hours
jobs:
build:
name: build and deploy mathlib4 docs
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: install elan
run: |
set -o pipefail
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- --default-toolchain none -y
~/.elan/bin/lean --version
echo "$HOME/.elan/bin" >> $GITHUB_PATH
- name: generate and deploy docs
if: github.repository == 'leanprover/doc-gen4'
run: |
cd ../
./doc-gen4/deploy_docs.sh
env:
MATHLIB4_DOCS_KEY: ${{ secrets.MATHLIB4_DOCS_KEY }}
DOC_GEN_REF: ${{ github.sha }}

View File

@ -16,7 +16,8 @@ def index : BaseHtmlM Html := do templateExtends (baseHtml "Index") <|
<main> <main>
<a id="top"></a> <a id="top"></a>
<h1> Welcome to the documentation page </h1> <h1> Welcome to the documentation page </h1>
<p>This was built for commit <a href={s!"{← getProjectGithubUrl}/tree/{← getProjectCommit}"}>{s!"{← getProjectCommit} "}</a> using Lean 4 at commit <a href={s!"https://github.com/leanprover/lean4/tree/{Lean.githash}"}>{Lean.githash}</a></p> -- Temporary comment until the lake issue is resolved
<p>This was built /-for commit <a href={s!"{← getProjectGithubUrl}/tree/{← getProjectCommit}"}>{s!"{← getProjectCommit} "}</a>-/ using Lean 4 at commit <a href={s!"https://github.com/leanprover/lean4/tree/{Lean.githash}"}>{Lean.githash}</a></p>
</main> </main>
end Output end Output

View File

@ -1,49 +1,47 @@
# Arguments:
# $1 : path to mathlib4 from working directory
# $2 : path to doc-gen4 from working directory
# $3 : whether to deploy
set -e set -e
set -x set -x
cp -r $2/lake-packages/* $1/lake-packages git config --global user.email "leanprover.community@gmail.com"
cd $1 git config --global user.name "leanprover-community-bot"
mathlib_short_git_hash="$(git log -1 --pretty=format:%h)"
cd ../$2
DOC_GEN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
cd ../
git clone "https://github.com/leanprover-community/mathlib4_docs.git" mathlib4_docs git clone "https://github.com/leanprover-community/mathlib4_docs.git" mathlib4_docs
# skip if docs for this commit have already been generated # Workaround for the lake issue
if [ "$(cd mathlib4_docs && git log -1 --pretty=format:%s)" == "automatic update to mathlib4 $mathlib_short_git_hash using doc-gen4 $DOC_GEN_REF" ]; then elan default leanprover/lean4:nightly
lake new workaround math
cd workaround
echo 'require «doc-gen4» from ".." / "doc-gen4" ' >> lakefile.lean
# doc-gen4 expects to work on github repos with at least one commit
git add .
git commit -m "workaround"
git remote add origin "https://github.com/leanprover/workaround"
lake update
cd lake-packages/mathlib
mathlib_short_git_hash="$(git log -1 --pretty=format:%h)"
cd ../../
if [ "$(cd ../mathlib4_docs && git log -1 --pretty=format:%s)" == "automatic update to mathlib4 $mathlib_short_git_hash using doc-gen4 $DOC_GEN_REF" ]; then
exit 0 exit 0
fi fi
# generate the docs lake exe cache get
cd $1 lake build Mathlib:docs Std:docs
sed -i "s|from git \"https://github.com/leanprover/doc-gen4\" @ \"main\"| from \"..\" / \"doc-gen4\" with NameMap.empty|" lakefile.lean
# This can destroy caching properties if std4 or aesop master are out of sync with mathlib4 but cd ..
# we need it since lake does not provide the ability to update singular deps rm -rf mathlib4_docs/docs/
# right now. Once the feature is implemented we can stop doing that. cp -r "workaround/build/doc" mathlib4_docs/docs
lake -Kdoc=on update mkdir ~/.ssh
lake -Kdoc=on build Mathlib:docs Std:docs echo "$MATHLIB4_DOCS_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
cd mathlib4_docs/docs
git remote set-url origin "git@github.com:leanprover-community/mathlib4_docs.git"
git config user.email "leanprover.community@gmail.com"
git config user.name "leanprover-community-bot"
git add -A .
git checkout --orphan master2
git commit -m "automatic update to mathlib4 $mathlib_short_git_hash using doc-gen4 $DOC_GEN_REF"
git push -f origin HEAD:master
if [ "$3" = "true" ]; then
cd ..
rm -rf mathlib4_docs/docs/
cp -r "$1/build/doc" mathlib4_docs/docs
mkdir ~/.ssh
echo "$MATHLIB4_DOCS_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
cd mathlib4_docs/docs
git remote set-url origin "git@github.com:leanprover-community/mathlib4_docs.git"
git config user.email "leanprover.community@gmail.com"
git config user.name "leanprover-community-bot"
git add -A .
git checkout --orphan master2
git commit -m "automatic update to mathlib4 $mathlib_short_git_hash using doc-gen4 $DOC_GEN_REF"
git push -f origin HEAD:master
fi

View File

@ -28,6 +28,6 @@
{"git": {"git":
{"url": "https://github.com/fgdorais/UnicodeData", {"url": "https://github.com/fgdorais/UnicodeData",
"subDir?": null, "subDir?": null,
"rev": "ece7fa88d13ae92b670e46035119bab89e5225df", "rev": "fb9efcfc2b832c2aff45a220779f35b79f62da11",
"name": "UnicodeData", "name": "UnicodeData",
"inputRev?": "main"}}]} "inputRev?": "main"}}]}

17
test_docs.sh Executable file
View File

@ -0,0 +1,17 @@
# Arguments:
# $1 : path to std4 from working directory
# $2 : path to doc-gen4 from working directory
set -e
set -x
# carry the already built doc-gen4 over
mkdir -p "$1"/lake-packages
cp -r "$2"/lake-packages/* "$1"/lake-packages
# generate the docs
cd "$1"
sed -i "s|from git \"https://github.com/leanprover/doc-gen4\" @ \"main\"| from \"..\" / \"doc-gen4\" with NameMap.empty|" lakefile.lean
lake -Kdoc=on update
lake -Kdoc=on build Std:docs