lint: Call more checks from test_runner #31653

pull maflcko wants to merge 3 commits into bitcoin:master from maflcko:2501-lint-commit-range changing 3 files +80 −64
  1. maflcko commented at 1:59 pm on January 14, 2025: member

    The lint commit-script-check.sh can not be called from the test_runner at all and must be called manually. Also, some checks require COMMIT_RANGE to be set.

    Fix all issues by moving two lint checks into the test_runner. Also, the proper commit range is passed to the checks by the test_runner, so that the user no longer has to do it.

  2. DrahtBot commented at 1:59 pm on January 14, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31653.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK kevkevinpal, willcl-ark

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot renamed this:
    lint: Call more checks from test_runner
    lint: Call more checks from test_runner
    on Jan 14, 2025
  4. DrahtBot added the label Tests on Jan 14, 2025
  5. in test/lint/test_runner/src/main.rs:730 in fa42b4aa5e outdated
    723@@ -650,6 +724,10 @@ fn main() -> ExitCode {
    724     };
    725 
    726     let git_root = get_git_root();
    727+    let commit_range = commit_range();
    728+    let commit_log = check_output(git().args(["log", "--no-merges", "--oneline", &commit_range]))
    729+        .expect("git error");
    730+    println!("Checking commit range ({commit_range}):\n{commit_log}\n");
    


    kevkevinpal commented at 11:14 pm on January 20, 2025:

    looks like this adds a new log added to the CI (which I think is fine)

    For other reviewers this is what this log looks like in Cirrus CI

    0[12:23:15.442] Checking commit range (HEAD~..HEAD):
    1[12:23:15.442] fa42b4aa5e lint: Call lint_commit_msg from test_runner
    2[12:23:15.442] faee335285 lint: Call lint_scripted_diff from test_runner
    

    maflcko commented at 7:56 am on January 21, 2025:

    looks like this adds a new log added to the CI (which I think is fine)

    It shouldn’t add a new log to the CI. The commits were logged in the CI before this pull request (See the echo).

    The goal of this pull request is to move the logic into the test_runner, so that it is easier to run the test_runner locally and replicate the CI.


    kevkevinpal commented at 12:39 pm on January 21, 2025:

    I guess it doesnt add a new line but modify’s what is already there adding Checking commit range

    example from #31690

    0[20:29:08.514] + echo
    1[20:29:08.514] 
    2[20:29:08.514] + git log --no-merges --oneline HEAD~..HEAD
    3[20:29:08.516] 2db6923332 [doc] Amend notes on benchmarking
    

    either way looks good to me!


    maflcko commented at 9:56 am on January 23, 2025:
    split into a separate commit to clarify
  6. in test/lint/test_runner/src/main.rs:729 in fa42b4aa5e outdated
    723@@ -650,6 +724,10 @@ fn main() -> ExitCode {
    724     };
    725 
    726     let git_root = get_git_root();
    727+    let commit_range = commit_range();
    728+    let commit_log = check_output(git().args(["log", "--no-merges", "--oneline", &commit_range]))
    729+        .expect("git error");
    


    kevkevinpal commented at 11:17 pm on January 20, 2025:
    nit: In commit_range there is also a .expect which has the text “git command failed” it would make sense to have the same text for consistency, but feel free to ignore

    maflcko commented at 7:56 am on January 21, 2025:
    I think it is unlikely for git log to fail, but since RUST_BACKTRACE=1 is set, the error should be self-explanatory anyway. Possibly expect could be replaced by unwrap?

    kevkevinpal commented at 12:35 pm on January 21, 2025:
    yea should be fine just thought I’d point it out, I think it is fine as is

    maflcko commented at 9:56 am on January 23, 2025:
    thx, made the error string equal for both calls
  7. kevkevinpal approved
  8. kevkevinpal commented at 11:20 pm on January 20, 2025: contributor

    crACK fa42b4a

    I think this is a good change moves some of our python linting scripts into our rust lint runner which reduces the number of python files we need to maintain and does the same thing.

    Looks like this change adds another log which lists the commits being linted and their oneline which I think is fine

  9. lint: Call lint_scripted_diff from test_runner
    Allowing to call the check from the test_runner allows for consistent
    error messages and better UX by having a single test_runner for all
    checks.
    
    This requires the env var to be set for now. The next commit makes the
    commit range optional.
    fa673cf344
  10. lint: Move commit range printing to test_runner
    Having a single test_runner for all logic improves the consistency and
    UX.
    fa99728b0c
  11. lint: Call lint_commit_msg from test_runner
    Allowing to call the check from the test_runner allows for consistent
    error messages. Also, manually setting the commit range is no longer
    needed.
    faf8fc5487
  12. in ci/lint/06_script.sh:18 in fa42b4aa5e outdated
    18-  # Otherwise, assume that a merge commit exists. This merge commit is assumed
    19-  # to be the base, after which linting will be done. If the merge commit is
    20-  # HEAD, the range will be empty.
    21-  COMMIT_RANGE="$( git rev-list --max-count=1 --merges HEAD )..HEAD"
    22 fi
    23 export COMMIT_RANGE
    


    kevkevinpal commented at 0:10 am on January 21, 2025:

    I think we can delete this line and then do the following on line 12 export COMMIT_RANGE="HEAD~..HEAD"

    since now this export sometimes is empty


    maflcko commented at 7:56 am on January 21, 2025:
    The two should be equivalent, right? Happy to push, if I have to touch again.

    maflcko commented at 9:56 am on January 23, 2025:
    thx, pushed
  13. maflcko force-pushed on Jan 23, 2025
  14. kevkevinpal commented at 5:30 pm on January 23, 2025: contributor
    reACK faf8fc5
  15. willcl-ark approved
  16. willcl-ark commented at 4:00 pm on February 3, 2025: member

    tACK faf8fc5487d409eeff7b7b260eabb6929a7b7a5f

    Makes sense to move this into test_runner.

    Worked correctly for me, although I did forget that we currently can’t run the linter (and local CI) in a worktree, which I was using.

    I’ll try and open a PR to fix that shortly.

  17. maflcko commented at 4:04 pm on February 3, 2025: member

    can’t run the linter (and local CI) in a worktree

    Jup, see #30028 for the CI part.

  18. fanquake merged this on Feb 4, 2025
  19. fanquake closed this on Feb 4, 2025

  20. maflcko deleted the branch on Feb 5, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-02-22 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me