Skip to content
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: lake: postUpdate? + test #2603

Merged
merged 1 commit into from
Oct 13, 2023
Merged

Conversation

tydeu
Copy link
Member

@tydeu tydeu commented Sep 29, 2023

Closes leanprover/lake#185.

This feature is implemented in a very straightforward mannaer. It is simply a monadic package configuration option. lake update runs all the workspace's packages' postUpdate? actions after resolving dependencies and finalizing the workspace but before writing the manifest to its file.

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Sep 29, 2023
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 29, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Sep 29, 2023
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Sep 29, 2023

@@ -164,6 +164,7 @@ Lake provides a large assortment of configuration options for packages.

### Build & Run

* `postUpdate?`: A post-`lake update` hook. The monadic action is run after a successful `lake update` execution on this package or one of its downstream dependents. Defaults to `none`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have an example? Looking at this diff, the only clue as to how to actually define such a hook is:

  • reading the type Option (LakeT LogIO PUnit)
  • looking at src/lake/tests/postUpdate/dep/lakefile.lean.

If this is meant to help Mathlib run lake exe cache get after an update, then there needs to be an example in a documentation file that shows how to run an exe target as an update hook.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semorrison While I agree in spirit, I am not quite sure where to put such an example. Putting it here in the README would be awkward as none of the other configuration options have examples. Thus, giving it one would would draw the reader's attention, focusing them on an option that is likely not useful for most users. Would putting the example in the docstring be sufficient?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe start a new file? I don't really mind where it goes. If one option is better documented than others that's a good thing, and the "fix" is to document the others as well...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just hoping that we can say "Patrick, do you want to see if you can make lake exe cache get run automatically as part of lake update", and he replies with "Wow, that was easy" rather than "Option (LakeT LogIO PUnit)???".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semorrison Does the new docstring look good?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring is great, and I've verified that it works.

My only concern is about the code block in the comment eventually rotting.

  • Maybe the API is uses is sufficiently stable to just not worry?
  • Alternatively we could have a test that is effectively isomorphic (in terms of API calls) to the example in the doc-string, and a comment saying "If you need to fix this test, make sure you also update the doc-string on postUpdate?".

I'm happy either way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semorrison I went with option 2. If everything looks good, this feature should be ready to merge. 😄

@tydeu tydeu added the awaiting-review Waiting for someone to review the PR label Oct 11, 2023
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 11, 2023
@tydeu tydeu mentioned this pull request Oct 12, 2023
1 task
@tydeu tydeu force-pushed the lake-post-update branch 2 times, most recently from a72b160 to a908d58 Compare October 12, 2023 20:01
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 13, 2023
@tydeu tydeu merged commit 42802f9 into leanprover:master Oct 13, 2023
@tydeu tydeu deleted the lake-post-update branch October 13, 2023 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Waiting for someone to review the PR builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support project-specific post-update hooks called after running lake update
4 participants