Add annotate-able ones #165
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lean 4 Playground | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch and "v4*" branches | |
push: | |
branches: | |
- main | |
- 'v4*' | |
pull_request: | |
branches: | |
- main | |
- 'v4*' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
# This workflow contains a single job called "lean4" | |
lean4: | |
name: Lean 4 Examples | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
fail-fast: false | |
steps: | |
- name: install elan on Ubuntu and macOS | |
if: matrix.os != 'windows-latest' | |
run: | | |
set -o pipefail | |
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | bash -s -- -y | |
echo "$HOME/.elan/bin" >> $GITHUB_PATH | |
- name: install elan on Windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
curl -O --location https://raw.githubusercontent.com/leanprover/elan/master/elan-init.ps1 | |
.\elan-init.ps1 -NoPrompt 1 -DefaultToolchain none | |
echo "$HOME\.elan\bin" >> $env:GITHUB_PATH | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
# cache: 'pip' # caching pip dependencies | |
- name: check examples | |
run: | | |
cd lean4 | |
lake exe cache get | |
lake script run check_examples | |
- name: annotate examples | |
# annotation is enabled for Github Pages deployment or for commits with '[annotate]' in the message | |
if: >- | |
matrix.os == 'ubuntu-latest' && ( | |
startsWith(github.ref, 'refs/heads/v4') || | |
contains(github.event.head_commit.message, '[annotate]') | |
) | |
run: | | |
cd lean4 | |
./install_deps.sh | |
./annotate_all.sh | |
# lake env leanInk analyze examples/Help.lean | |
- name: Upload artifact | |
# For now, disable the deployment job for the main branch | |
# and enable for v4* branches | |
if: >- | |
matrix.os == 'ubuntu-latest' && ( | |
(github.ref == 'main' && contains(github.event.head_commit.message, '[annotate]')) || | |
startsWith(github.ref, 'refs/heads/v4') | |
) | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./lean4/dist | |
# Deployment job | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
fail-fast: false | |
needs: lean4 | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
# For now, disable the deployment job for the main branch | |
# and enable for v4* branches | |
if: >- | |
matrix.os == 'ubuntu-latest' && ( | |
(github.ref == 'main' && contains(github.event.head_commit.message, '[annotate]')) || | |
startsWith(github.ref, 'refs/heads/v4') | |
) | |
uses: actions/deploy-pages@v4 |