Skip to content

Commit

Permalink
feat: add support for lean4checker (#5)
Browse files Browse the repository at this point in the history
Add an input and corresponding step for checking the enviornment
with lean4checker.

When run with `lean4checker: true`, lean-action automatically detects the toolchain 
of the package and runs the corresponding version of `lean4checker.`

Note, this input is only supported for lean packages on version >= 4.8.0-rc1 due to the
change in naming convention of `lean4checker` version tags.
  • Loading branch information
austinletson authored May 11, 2024
1 parent 788e73f commit de5c38a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ jobs:
# Allowed values: "true" or "false".
# Default: false
check-reservoir-eligibility: false

# Check environment with lean4checker.
# Lean version must be 4.8 or higher.
# The version of lean4checker is automatically detected using `lean-toolchain`.
# Allowed values: "true" or "false".
# Default: false
lean4checker: false
```
## Examples
Expand Down
17 changes: 16 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,19 @@ inputs:
description: |
Check if the repository is eligible for the reservoir.
Allowed values: "true" or "false".
If check-reservoir-elibility input is not provided, the action will not check for reservoir eligibility.
If check-reservoir-eligibility input is not provided, the action will not check for reservoir eligibility.
required: false
default: "false"
lean4checker:
description: |
Check environment with lean4checker.
Lean version must be 4.8 or higher.
The version of lean4checker is automatically detected using `lean-toolchain`.
Allowed values: "true" or "false".
If lean4checker input is not provided, the action will not check the environment with lean4checker.
required: false
default: "false"

runs:
using: "composite"
steps:
Expand Down Expand Up @@ -97,3 +107,8 @@ runs:
"${{ github.event.repository.stargazers_count }}"\
"${{ github.event.repository.license.spdx_id }}"
shell: bash

- name: check environment with lean4checker
if: ${{ inputs.lean4checker == 'true' }}
run: ${{ github.action_path }}/scripts/run_lean4checker.sh
shell: bash
30 changes: 30 additions & 0 deletions scripts/run_lean4checker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -e

echo "Checking environment with lean4checker"

# clone lean4checker
echo "Cloning and building lean4checker"
git clone https://github.com/leanprover/lean4checker

# build and test lean4checker in a subshell
(
# detect toolchain version from lean-toolchain file
# assumes toolchain is of the form ".*:{VERSION}" (e.g., "leanprover/lean4:v4.8.0-rc1")
toolchain_version=$(< lean-toolchain cut -d: -f 2)
echo "Detected toolchain version: $toolchain_version"

# checkout version of lean4checker corresponding to toolchain version
cd lean4checker || exit
git config advice.detachedHead false # turn off git warning about detached head
git checkout "$toolchain_version"
cp ../lean-toolchain .

# build lean4checker and test lean4checker
lake build
./test.sh
)

# run lean4checker
echo "Running lean4checker"
lake env lean4checker/.lake/build/bin/lean4checker

0 comments on commit de5c38a

Please sign in to comment.