Zulip Chat Archive
Stream: Equational
Topic: New script: run_before_push.sh
Terence Tao (Oct 03 2024 at 21:49):
@Pietro Monticone has created a new script, run_before_push.sh
(see equational#238) to allow one to locally run most (though not all) of the CI checks in advance of a PR. It can be run from the top level directory of the local copy of the repository.
I have just recently implemented branch protection to try to force myself to not abuse admin privileges by pushing to the main branch directly. Ironically in my experiments to do so I have still accidentally broken the build at least once today by clicking on the wrong button, but hopefully this will all get worked out soon.
Pietro Monticone (Oct 03 2024 at 22:06):
Added the related warning in the relevant section of the contributing guide.
Shreyas Srinivas (Oct 03 2024 at 22:08):
I applaud this effort. In practice I expect mixed results because a lot of people have a set up where they automatically keep pushing commits.
Shreyas Srinivas (Oct 03 2024 at 22:08):
You can have your editor of choice handle this automatically, only asking for a commit message from the user.
Shreyas Srinivas (Oct 03 2024 at 22:11):
Vscode encourages this in particular if one uses the included git GUI
Shreyas Srinivas (Oct 03 2024 at 22:12):
What we need to do is embed your script as a git pre-push hook : https://stackoverflow.com/questions/4196148/git-pre-push-hooks
Shreyas Srinivas (Oct 03 2024 at 22:18):
Better source: https://git-scm.com/book/ms/v2/Customizing-Git-Git-Hooks
Pietro Monticone (Oct 03 2024 at 22:40):
Seems a good idea. Let me test it.
Pietro Monticone (Oct 03 2024 at 22:47):
Done.
Pietro Monticone (Oct 03 2024 at 22:51):
I have tested on VS Code, Git CLI and GitHub Desktop. It seems to work everywhere.
Pietro Monticone (Oct 03 2024 at 22:56):
If I understand correctly git hooks work only locally. Therefore I need to add another paragraph to the CONTRIBUTING guide.
Floris van Doorn (Oct 03 2024 at 23:03):
I don't want this script as a mandatory requirement before pushing. It's quite long, and it's doing the same as the CI already running on PRs, right?
Shreyas Srinivas (Oct 03 2024 at 23:05):
Something less than that
Pietro Monticone (Oct 03 2024 at 23:05):
Much less.
It ensures that the key components of the Lean project are functional before changes are pushed to the repository by checking that:
- You are in the correct directory;
- The project builds successfully;
- The blueprint is successfully generated in both PDF and web versions;
- LaTeX declarations in the blueprint match Lean declarations in the codebase.
It takes seconds, not minutes.
Shreyas Srinivas (Oct 03 2024 at 23:05):
It doesn't compile docs
Shreyas Srinivas (Oct 03 2024 at 23:05):
It doesn't do Jekyll compilation
Pietro Monticone (Oct 03 2024 at 23:06):
But it covers basically all errors I have manually fixed in different PR branches
Pietro Monticone (Oct 03 2024 at 23:06):
It seems to be a decent tradeoff.
Shreyas Srinivas (Oct 03 2024 at 23:08):
Does the git hook get pushed to GitHub?
Shreyas Srinivas (Oct 03 2024 at 23:11):
Okay it doesn't
Pietro Monticone (Oct 03 2024 at 23:11):
No no, but I wrote the installation script. It's coming.
Shreyas Srinivas (Oct 03 2024 at 23:11):
(deleted)
Floris van Doorn (Oct 03 2024 at 23:14):
the reply here gives a way to add it to the repository which is then very easy to enable by each user that wants it: https://stackoverflow.com/questions/3462955/putting-git-hooks-into-a-repository
Pietro Monticone (Oct 03 2024 at 23:14):
Done https://github.com/teorth/equational_theories/pull/256/
Shreyas Srinivas (Oct 03 2024 at 23:16):
Shreyas Srinivas (Oct 03 2024 at 23:16):
Oh okay
Floris van Doorn (Oct 03 2024 at 23:17):
Pietro Monticone said:
It takes seconds, not minutes.
If you can build this project in seconds, I am very interested to know what hardware you're running, because I would also like a 10-100x speedup in my Lean compilation time. For me it takes 6m15.691s
to run the script (and this number likely grows as the repository grows).
Shreyas Srinivas (Oct 03 2024 at 23:19):
Btw, Floris, the end user still has the option to not run the install script
Shreyas Srinivas (Oct 03 2024 at 23:20):
What Pietro has implemented is close to the solution in your link and it requires user action on the client side to enable the hook
Floris van Doorn (Oct 03 2024 at 23:20):
I know, but thanks for the reminder.
Pietro Monticone (Oct 03 2024 at 23:21):
Floris van Doorn said:
Pietro Monticone said:
It takes seconds, not minutes.
If you can build this project in seconds, I am very interested to know what hardware you're running, because I would also like a 10-100x speedup in my Lean compilation time. For me it takes
6m15.691s
to run the script (and this number likely grows as the repository grows).
I am confused here. I might have run after some lake exe cache get
and lake build
...
Pietro Monticone (Oct 03 2024 at 23:31):
Of course I did not have a fresh build
Pietro Monticone (Oct 03 2024 at 23:32):
I will remove the "strongly recommended" in the CONTRIBUTING guide and offer the 3 alternatives:
- installing the hook
- running the script
- waiting for the CI
Pietro Monticone (Oct 03 2024 at 23:51):
Done
Pietro Monticone (Oct 03 2024 at 23:54):
Updated the warning block.
Screenshot 2024-10-04 at 02.02.02.png
Cody Roux (Oct 04 2024 at 01:07):
Cool! Thanks for all the hard work! I think we'll need many more devops before the AI overlords take us...
Last updated: May 02 2025 at 03:31 UTC