stratum-mining / stratum

stratum
https://stratumprotocol.org
Other
204 stars 121 forks source link

`pre-push` git hooks errors + should be limited to formatting only #1038

Closed rrybarczyk closed 1 week ago

rrybarczyk commented 2 months ago

Background

act is a tool that works with Docker to run GitHub Actions workflows locally, designed to be run before pushing changes. The .githooks/pre-push uses act to run some GitHub workflows with % ./.githooks/pre-push origin https://github.com/stratum-mining/stratum.git.

The currently defined workflows in this pre-push script are:

During the 2024.07.02 dev meet, the team decided that the pre-push should only containing more commonly needed workflows, like for formatting. Additionally, because of long run times when using act, the usage of act should be replaced with calling the bash scripts in the scripts/ directory in the repo root. This will keep the pre-push runtime shorter, and then any more specific workflows needed can be run manually by executing the bash scripts in the scripts/ directory on the dev branch.

Problem

Solution

In .githooks/pre-push, replace the use of act with calls to the following bash scripts in the scripts/ directory on the dev branch:

rrybarczyk commented 2 months ago

Here are the run times for the scripts:

Total run time of the ./.githooks/pre-push:

@plebhash, do you want to keep the cargo test or remove? I have no preference, just comes down to a 1 minute run time with tests vs a 4 second run time without and what we want the user experience to be.

rrybarczyk commented 2 months ago

I am experiencing the following issues in running ./scripts/sv2-header-check.sh:

  1. zsh: ./scripts/sv2-header-check.sh: bad interpreter: /usr/bin/sh: no such file or directory
    • This is solved by changing #! /usr/bin/sh at the top of the file to #!/bin/sh. However, will changing this break on other user's systems? The #!/bin/sh is what clippy-on-all-workspaces.sh uses.
  2. Running for the first time yields a success, however running a second time fails because the scripts/sv2.h file generated by this script does not get deleted after the run has completed.

My solution is to add rm -f scripts/sv2.h at the top of the file before running, which deletes the file if it exists.

rrybarczyk commented 2 months ago

@plebhash, thoughts on splitting up the clippy-on-all-workspaces into the following stand alone bash scripts:

Or is there a reason why these are all grouped together? If we choose to keep in same file, we should rename to clippy-fmt-and-test.sh or something.

GitGab19 commented 2 months ago

@plebhash, thoughts on splitting up the clippy-on-all-workspaces into the following stand alone bash scripts:

* `scripts/clippy`: Runs `cargo clippy` on all workspaces.

* `scripts/test`: Runs `cargo test` on all workspaces.

* `scripts/fmt`: Runs `cargo nightly fmt` on all workspaces.

Or is there a reason why these are all grouped together? If we choose to keep in same file, we should rename to clippy-fmt-and-test.sh or something.

I think they are grouped just for convenience. I would keep them together, renaming the script in clippy-fmt-and-test.sh as you suggested.