-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: prototype update action #5
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Check for updates | ||
|
||
# This action will run `lean update` and try `lean build` if there is an available update. | ||
# There are three possible outcomes: | ||
# - No update available (silent) | ||
# - Update available and build succeeds (open PR) | ||
# - Update available and build fails (open issue) | ||
|
||
on: | ||
schedule: | ||
- cron: "0 11 * * 4" # every Wednesday at 11:00 | ||
workflow_dispatch: # allows manual starts | ||
|
||
jobs: | ||
attempt-update: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
pull-requests: write | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- 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 | ||
|
||
- name: Update | ||
run: lake update | ||
|
||
- name: Check if anything was updated | ||
uses: tj-actions/verify-changed-files@v18 | ||
id: check-update | ||
with: | ||
files: | | ||
lean-toolchain | ||
lake-manifest.json | ||
|
||
- name: Try to build lean if something was updated | ||
if: steps.check-update.outputs.files_changed == 'true' | ||
id: build-lean | ||
continue-on-error: true | ||
run: | | ||
lake exe cache get || true | ||
lake build | ||
|
||
- name: Run step only if nothing was updated | ||
if: steps.check-update.outputs.files_changed == 'false' | ||
run: | | ||
echo "No update available" | ||
echo "outcome=no-update" >> "$GITHUB_ENV" | ||
|
||
- name: Run step only if the updated lean build was successful | ||
id: step | ||
if: steps.build-lean.outcome == 'success' | ||
run: | | ||
echo "Update available and build successful" | ||
echo "outcome=update-success" >> "$GITHUB_ENV" | ||
|
||
- name: Open PR if the updated lean build was successful | ||
if: steps.build-lean.outcome == 'success' | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
title: "Updates available and ready to merge." | ||
body: "To do: add useful details here..." | ||
delete-branch: true | ||
branch-suffix: random | ||
branch: auto-update/patch | ||
|
||
- name: Open issue if the updated lean build fails | ||
if: steps.build-lean.outcome == 'failure' | ||
run: | | ||
echo "outcome=update-fail" >> "$GITHUB_ENV" | ||
gh issue create \ | ||
--title "$TITLE" \ | ||
--label "$LABELS" \ | ||
--body "$BODY" | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GH_REPO: ${{ github.repository }} | ||
TITLE: Updates available but manual intervention required | ||
LABELS: bug | ||
BODY: | | ||
Run `lake update` and then investigate why this update causes the lean build to fail. | ||
Files changed in update: ${{ steps.check-update.outputs.changed_files }} | ||
|
||
# To do: Update action so that it will not create another issue until this present issue is closed. | ||
|
||
- name: Show the outcome | ||
run: echo "${{ env.outcome }}" | ||
# To do: properly have an action with outputs |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If tracking issues is tricky, this is a good compromise since we can easily close the old one by hand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A previous version had a bit of code which detected if there was still an issue produced from a prior run and then avoid creating a new issue. However it didn't work as expected and I failed to find my error. I'm sure it was just something stupid with the syntax. Another day I'll be able to find a way.
However I'm uncertain exactly what behaviour is preferred when it detects that an update is available but needs manual intervention. Options are:
We'll see what is best as we progress. I return to focus on completing the stuff in topology. It's been going well and soon should be done. Sebastien suggested to me to PR the alternate version of Cantor's theorem which we use into mathlib so that's also in progress.
Talk to you on Thursday!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "Fail the workflow so notify the maintainers that there is something to do" is already enough, at least I would see it in my github notifications anyway.
"Open new issue only if there is no open issue from a prior run" is a stronger signal than just a job failure, since in this case I would also get an email. I don't mind if it does not close the job though