A GitHub Action that attempts to update Lean and dependencies of a Lean project. This is basically a fork of oliver-butterley/lean-update but more feature-rich.
Create a file named update.yml
in the .github/workflows
directory.
To keep dependencies always up-to-date, you might want to configure as follows:
name: Update Lean Project
on:
schedule:
- cron: "0 0 * * *" # every day
workflow_dispatch: # allows workflow to be triggered manually
jobs:
update_lean:
# this is needed for private repositories
permissions:
contents: write
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update Lean project
uses: leanprover-community/lean-update@main
If you want to skip updates unless there is a change to the lean-toolchain
file, you might want to configure as follows:
name: Update Lean Project
on:
schedule:
- cron: "0 0 * * *" # every day
workflow_dispatch: # allows workflow to be triggered manually
jobs:
update_lean:
# this is needed for private repositories
permissions:
contents: write
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update Lean project
uses: leanprover-community/lean-update@main
with:
update_if_modified: lean-toolchain
- First, create a bot in Zulip and note its API key. Be careful not to create a new account - Zulip has a dedicated feature for "creating a bot".
- Next, register the bot's API key as a secret named
ZULIP_API_KEY
in your repository. You can set up secrets from the repository's "Settings". - Prepare a workflow file like the following:
name: Update Lean Project
on:
schedule:
- cron: "0 0 * * *" # every day
workflow_dispatch: # allows workflow to be triggered manually
jobs:
update_lean:
# this is needed for private repositories
permissions:
contents: write
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update Lean project
id: lean-update
uses: leanprover-community/lean-update@main
with:
on_update_fails: "silent"
- name: Notification
if: steps.lean-update.outputs.result == 'update-fail' # only send a message when the update fails
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_API_KEY }} # Zulip API key of your bot
email: "***[email protected]" # your Zulip bot's email
organization-url: 'https://leanprover.zulipchat.com'
to: "123456" # user_id
type: "private" # private message
content: |
❌ The update of ${{ github.repository }} has failed
- [See Action Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
- [See Commit](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
-
This Action first installs elan and runs
lake update
. This fetches any new Lean prereleases or releases and updates all dependent packages to their latest versions. -
If
lake update
determines that all dependencies are already up to date, this Action does nothing further. -
Subsequently, this GitHub Action calls another GitHub Action called lean-action to check if the updated code works correctly. This performs the build process, runs tests if a test driver is configured, and executes lint checks if a lint driver is set up. Whether to perform tests or lint checks is automatically determined by lean-action. However, you can configure what build arguments are passed to
lake build
when lean-action is executed using thebuild_args
option. -
This Action classifies the results of lean-action into two categories: success or failure.
- If successful, it behaves according to the setting specified in the
on_update_succeeds
option. By default, this is set topr
, which submits the updated code as a pull request. However, if theupdate_if_modified
option is set tolean-toolchain
, the Action does nothing unless the Lean version has been updated. - If it fails, it behaves according to the setting specified in the
on_update_fails
option. By default, this is set toissue
, which submits an issue indicating that the update failed.
- If successful, it behaves according to the setting specified in the
What to do when an update is available and the build is successful.
Allowed values:
silent
: Do nothingcommit
: directly commit the updated filesissue
: notify the user by creating an issue. No new issue will be created if one already exists.pr
: notify the user by creating a pull request. No new PR will be created if one already exists.
Default: pr
.
What to do when an update is available and the build fails.
Allowed values:
silent
: Do nothingissue
: notify the user by creating an issue. No new issue will be created if one already exists.pr
: notify the user by creating a pull request. No new PR will be created if one already exists.
Default: issue
.
Specifies which files, when updated during lake update
, will cause the action to update code or notify the user.
This option does not affect the behavior when the build/test/lint fail after lake update
.
Allowed values:
lean-toolchain
: Iflean-toolchain
is specified, this GitHub Action will skip updates unless the Lean version is updated. Here, "skipping updates" means "not attempting to update code or send notifications when the build/test/lint succeed after lake update".lake-manifest.json
: iflake-manifest.json
is specified, this GitHub Action will perform an update if any dependent package is updated.
Default: lake-manifest.json
This GitHub Action uses leanprover/lean-action to build and test the repository. This parameter determines what to pass to the build-args argument of leanprover/lean-action.
Default: --log-level=warning
The directory containing the Lake package to build. This parameter is passed to the lake-package-directory argument of leanprover/lean-action.
Default: .
Controls whether to update the lean-toolchain file for projects with no dependencies.
Allowed values:
auto
: Automatically update lean-toolchain to the latest stable release (default behavior)never
: Never update the lean-toolchain file
Default: auto
A Github token to be used for committing and creating issues/PRs.
Default: ${{ github.token }}
If set to true
, executes lake -R -Kenv=dev update
instead of lake update
.
Default: false
The action outputs no-update
, update-success
or update-fail
depending on the three possible scenarios.
Description of each value:
no-update
: No update was available.update-success
: An update was available and lean-action step was successful.update-fail
: An update was available but the lean-action step failed.
The latest Lean release version, including both stable and pre-release versions.
Indicates whether there is an event worth notifying the user about.
Returns true
in the following cases:
- When updates are available and the build succeeds. However, if
update_if_modified
is set tolean-toolchain
, this is only true when the Lean version has been updated. - When updates are available and the build fails.
Returns
false
in all other cases.