leanprover / lean-action Goto Github PK
View Code? Open in Web Editor NEWGitHub action for standard CI in Lean projects
License: Apache License 2.0
GitHub action for standard CI in Lean projects
License: Apache License 2.0
Currently, lean-action
uses grep to determine if a package is downstream of Mathlib. This is brittle. Instead, we should leverage Lake's API to determine if a package is downstream of Mathlib.
Some existing lean projects use -K to pass parameters to lake when running lake build
etc (see this line in the batteries workflow).
Supporting this will require some thinking about how these parameters should be passed into lean-action
.
From https://github.com/leanprover-community/batteries/actions/runs/9181778942/job/25249274199?pr=805:
Mathlib Detection
Trying to detect if project is downstream of Mathlib.
grep: lakefile.toml: No such file or directory
lean-action
contains an automated functional test suite, revisit RELEASING.md
to make sure it aligns with the new processCurrently, the tests in .github/functional_tests
do not verify the expected steps ran during the test run of lean-action
. We can leverage workflow commands and output parameters to verify the correct steps ran.
In the future, we may expose these outputs to lean-action
users so they can use the results of lean-action
in later workflow steps.
Currently functional tests use 4.8.0.
We want a way to run the functional test suite with any version of lean:
Note: This is based on my assumptions and might not be entirely accurate.
This issue occurs when we update our project from v4.9.0-rc1
to v4.9.0-rc2
. FormalizedFormalLogic/Foundation#85
And it seems to be happens same problem branch in the nightly branch of the import-graph.
In our project, we set the GitHub Action cache strategy as follows
path: .lake
key: lake-${{ runner.os }}-${{ hashFiles('lake-manifest.json') }}-${{ github.ref }}
restore-keys: |
lake-${{ runner.os }}-${{ hashFiles('lake-manifest.json') }}-${{ github.ref }}
lake-${{ runner.os }}-${{ hashFiles('lake-manifest.json') }}
lake-${{ runner.os }}
The problem we encountered was with the restore-keys
we specified. The issue is that when updating the Lean version itself, the previous version's cache also becomes a fallback candidate. In our project, it seems we referenced the v4.9.0-rc1 cache, which caused the build to fail.
Solution is remove fallbacks of restore-keys
to lake-${{ runner.os }}-${{ hashFiles('lake-manifest.json') }}-${{ github.ref }}
only.
Currently, the cache strategy of this action is similar (i.e., it doesn't avoid using the cache when the Lean version itself is updated).
Lines 93 to 99 in 52906d4
This seems to be why the nightly branch of the import-graph is broken.
As a solution, specifying ${{ hashFiles('lean-toolchain') }}
as the key should work.
The logging produced by each step of lean-action
is not properly grouped. This make it is difficult to tell which logs are generated by which steps when reading the output of lean-action
(see example form aesop here).
GitHub provides ::group::
and ::endgroup::
workflow commands which allow us to group the logs of each step into a collapsible group.
This workflow raise an error: https://github.com/lean-ja/lean-by-example/actions/runs/9530357340/workflow
The workflow content is simple: Just install elan, run lake update and then lean-action.
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
# - name: update lean-toolchain
# run: |
# LATEST_LEAN=$(gh release list --repo leanprover/lean4 --limit 1 | awk '{print $1}')
# echo "The latest release/prerelase is: $LATEST_LEAN"
# echo "leanprover/lean4:$LATEST_LEAN" > lean-toolchain
# env:
# GH_TOKEN: ${{ github.token }}
# shell: bash
- name: Install elan
run: |
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y
echo "$HOME/.elan/bin" >> $GITHUB_PATH
shell: bash
- name: Update dependencies of ${{ github.repository }}
run: lake update
shell: bash
- name: build lean
uses: leanprover/lean-action@main
with:
test: false
You can see error details: https://github.com/lean-ja/lean-by-example/actions/runs/9530357340/job/26270125659
error message:
▼ Run : Get Mathlib Cache
: Get Mathlib Cache
echo "::group::Mathlib Cache"
lake exe cache get
echo "::endgroup::"
echo
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
▼ Mathlib Cache
info: mdgen: updating repository '././.lake/packages/mdgen' to revision '6a6a412465e82572f6e30385592eac52ab055c83'
info: mathlib: updating repository '././.lake/packages/mathlib' to revision '03092720f68254315c95a5bf2[49](https://github.com/lean-ja/tactic-cheatsheet/actions/runs/9530357340/job/26270125659#step:5:55)c5f2cdef717d6'
error: external command 'git' exited with code 1
Error: Process completed with exit code 1.
I have no idea what caused it.
lake check-test
will return exit code 1 if no test runner is available.
When lean-action tries to run tests, we should check this first, and provide a helpful error message. (For now, as the test framework is changing quickly, it doesn't need to be particularly helpful! Later we can point to some proper documentation on how to set up test runners.)
We don't necessarily actually need to parse the TOML (although there is a TOML parser baked into core lean now!) and can probably get away with grepping for now. We'd be looking for:
[[require]]
name = "mathlib"
git = "https://github.com/leanprover-community/mathlib4"
Add a step to lean-action
(ideally after detect mathlib
) to log:
This aligns with logging practices in existing Lean CI workflows (e.g., import-graph
).
Some projects rebuild the leanblueprint site when a new PR is merged into the main branch to keep the blueprint updated with the latest progress, e.g., this workflow from carleson.
I imagine there are a range of workflows for this CI step, so this may be difficult to support. But this seems like a nice feature to add to lean-action
.
One area for improvement is that currently the action caches the mathlib cache generated by lake exe cache get
which seems redundant and takes up significant space in the GitHub cache.
One potential fix for this would be to exclude certain subfolders of .lake from the cache. This behavior of the cache action may be relevant.
Add an input for users to enable lean4checker
and a corresponding step which runs lean4checker
In many cases, Lean developers will want to run additional Lean related CI steps after lean-action
runs which take advantage of the features of lean-action
. For instance in import-graph
, there is a step to verify lake exe graph
which uses the elan setup and .lake
caching features from lean-action
(see leanprover-community/import-graph#9).
The lean-action
README.md should document where this is possible and give examples.
Automatically checks if test_driver
or test_runner
is defined in lakefile.lean
and executes lake test
if it is defined, otherwise does not.
It would be tedious to have the user manually enter whether or not to run lake test
each time. default input should be auto
.
I sometimes want just to install elan
and not to run lake build
release/v1-beta
branch for the release candidate.functional_tests.yml
workflow on release/v1-beta
.release/v1-beta
on existing test projects.release/v1-beta
with a v1-beta
tag.
## Unreleased
section of CHANGELOG.md
.uses: leanprover/lean-action@v1-beta
.README.md
and CHANGELOG.md
.Instead of users manually providing a module to lint with the lint-module
input, automatically detect which module to lint.
Depending on how this automatic detection works, we may still want to allow users to manually specify which module to lint.
Some projects contain Lean packages within a subdirectory of the GitHub repository (e.g. cedar-spec).
Two ways to potentially support this case:
lean-action
should runrelease/v1-beta.1
branch off of main
for the release candidate.functional_tests.yml
workflow on release/v1-beta.1
.release/v1-beta
on existing test projects (Given that the automated functional tests cover much of the original manual functional test suite, this is more of a sanity check).release/v1-beta.1
with a v1-beta.1
tag.
v1-beta.0
tag to point to v1-beta
to preserve a tag to the last release.v1-beta
tag to point to v1-beta.1
.uses: leanprover/lean-action@v1-beta
.The current situation is:
mathlib-cache:
description: |
Run "lake exe cache get" before build.
Project must be downstream of Mathlib.
Allowed values: "true" or "false".
If mathlib-cache input is not provided, the action will attempt to automatically detect if the project is downstream of Mathlib.
required: false
default: ""
- name: detect mathlib
# only detect Mathlib if the user did not provide the mathlib-cache input
if: ${{ inputs.mathlib-cache == '' }}
# etc...
An input here of either "true" or "false" will have the same effect. Possible solutions:
required: true
and default: false
for this input and change the conditional to ${{ inputs.mathlib-cache == 'false' }}Style note: could be clearer for the input name to be "get-mathlib-cache" or "use-mathlib-cache". (At the moment "mathlib-cache: true" could be understood to mean that the action can expect mathlib-cache to have already been obtained in a step prior to lean-action
.)
It is useful to have an option to disable GitHub caching because GitHub caching doesn't work well with automated testing of lean-action
output messages are usually unnecessary.
Add examples to README.md of lean projects which use lean-action
release/v1-alpha
branch for release candidaterelease/v1-alpha
on existing test projectsrelease/v1-alpha
with v1-alpha
taguses: leanprover/lean-action@v1-alpha
I have created a workflow running on Windows.
Almost always building on Windows is not necessary, but I sometimes need this. (For example, when trying to provide an environment which reproduce a lean bug on Windows machine...)
release/v1.0.0
branch off of main
for the release candidate.functional_tests.yml
workflow on release/v1.0.0
.release/v1.0.0
with a v1.0.0
tag.
v1.0.0
pointing to the release/v1.0.0
branchv1
.v1
tag to point to release/v1.0.0
.uses: leanprover/[email protected]
in test repo as a sanity check.leanprover/lean-action@{{MAJOR_SPECIFIC_RELEASE}}
in README.md.general/lean-action
Zulip topic. # Run "lake exe runLinter" on the specified module.
# Project must be downstream of Std.
# Allowed values: name of module to lint.
# If lint-module input is not provided, linter will not run.
lint-module: ""
The GitHub cache can cause problems when updating Lean version. To fix this and improve the overall caching strategy, we can add hashes of the lean-toolchain
and lake-manifest.json
files to the cache keys to narrow cache hits to runs of lean-action
with the same toolchain and lake manifest.
In action.yml
,
- uses: actions/cache@v4
step to use the following key
and restore-key
inputs:key: lake-${{ runner.os }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ github.sha }}
restore-keys: lake-${{ runner.os }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}
- uses: actions/cache/save@v4
step to use the following key
input:key: lake-${{ runner.os }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ github.sha }}
leanprover/lean4#4261 adds support for a new lake lint
command. We should refactor the lint step to use this more flexible linting command. We should still test that the batteries
linting framework works when wrapped with lake lint
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.