ci: Rewrite test-each-commit as py script #32680

pull maflcko wants to merge 2 commits into bitcoin:master from maflcko:2506-ci-rust-script changing 3 files +62 −23
  1. maflcko commented at 7:44 am on June 5, 2025: member

    This was requested in #32573 (comment), as it is currently not possible to catch this type of error in a Bash linter (https://github.com/bitcoin/bitcoin/pull/32573#pullrequestreview-2857077463). Also, reviewers are not familiar with it and didn’t catch the above bug either. (Thus, it is discouraged in the dev notes: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#scripts)

    So just use a simple python script.

  2. DrahtBot commented at 7:44 am on June 5, 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/32680.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK janb84, ryanofsky, achow101

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #31665 (build: Make config warnings fatal if -DWCONFIGURE_ERROR=ON by davidgumberg)
    • #30595 (kernel: Introduce initial C header API by TheCharlatan)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  3. DrahtBot added the label Tests on Jun 5, 2025
  4. maflcko force-pushed on Jun 5, 2025
  5. DrahtBot added the label CI failed on Jun 5, 2025
  6. DrahtBot commented at 8:01 am on June 5, 2025: contributor

    🚧 At least one of the CI tasks failed. Task lint: https://github.com/bitcoin/bitcoin/runs/43523418048 LLM reason (✨ experimental): Lint test failed due to permission issue on a script file.

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  7. maflcko force-pushed on Jun 5, 2025
  8. DrahtBot removed the label CI failed on Jun 5, 2025
  9. in .github/ci-test-each-commit-exec.rs:1 in fa9aced60a outdated
    0@@ -0,0 +1,104 @@
    1+// Copyright (c) The Bitcoin Core developers
    


    janb84 commented at 10:52 am on June 5, 2025:
    0---cargo
    1[package]
    2edition = "2024"
    3---
    4// Copyright (c) The Bitcoin Core developers
    

    nit / idea, add embedded manifest for direct cargo execution


    maflcko commented at 11:43 am on June 5, 2025:
    Sure, happy to review a pull doing that once it is stable
  10. in .github/workflows/ci.yml:84 in fa9aced60a outdated
    80@@ -81,7 +81,7 @@ jobs:
    81       - name: Compile and run tests
    82         run: |
    83           # Run tests on commits after the last merge commit and before the PR head commit
    84-          git rebase --exec "git merge --no-commit origin/${GITHUB_BASE_REF} && ./.github/ci-test-each-commit-exec.sh && git reset --hard" ${{ env.TEST_BASE }}
    85+          git rebase --exec "git merge --no-commit origin/${GITHUB_BASE_REF} && rustc -D warnings --edition=2024 ./.github/ci-test-each-commit-exec.rs -o ./a && ./a && git reset --hard" ${{ env.TEST_BASE }}
    


    janb84 commented at 10:55 am on June 5, 2025:
    0          git rebase --exec "git merge --no-commit origin/${GITHUB_BASE_REF} && cargo -Zscript ./.github/ci-test-each-commit-exec.rs  && git reset --hard" ${{ env.TEST_BASE }}
    

    This removes the extra execution step if cargo is used. Do note that this is stil in “unstable features” .


    maflcko commented at 11:44 am on June 5, 2025:
    I think you disabled warnings as errors. Otherwise: #32680 (review)
  11. janb84 commented at 10:56 am on June 5, 2025: contributor

    Concept ACK

    What do you think about the idea to use cargo for this (maybe not now because it’s still in ‘unstable) ?

  12. ryanofsky commented at 6:06 pm on June 5, 2025: contributor
    If I compare the added rust script to the removed bash script, the bash script does seem significantly simpler to me. I understand the rust script could have other improvements and maintenance advantages though, so no objections to this change.
  13. maflcko renamed this:
    ci: Rewrite test-each-commit as rust script
    ci: Rewrite test-each-commit as py script
    on Jun 6, 2025
  14. maflcko force-pushed on Jun 6, 2025
  15. maflcko commented at 6:20 am on June 6, 2025: member

    Hmm, yeah the boilerplate overhead is a bit unfortunate. I switched to python, which still has downsides such as #29068 (comment), but it seems manageable here. Also, updated the pull description.

    I think the danger of Bash, that it looks harmless and superficially simple and correct, but in many such “harmless” constructs can silently drop a failing return status is reason enough to prefer a slightly more verbose language. Maybe rust is too verbose here, but python seems acceptable. Bash also has many other issues, for example the version shipped by macOS is so ancient that it is older than Bitcoin itself and writing a CI script on a modern platform that uses a newer Bash feature will then only fail in CI when the pull is created/pushed. (Failing loudly if you are lucky, failing silently, if you are not)

  16. ci: Rewrite test-each-commit as py script fac60b9c48
  17. ci: [doc] fix url redirect
    This solves an URL redirect. (The commit is also used to trigger the test-each-commit CI)
    fa9cfdf3be
  18. maflcko force-pushed on Jun 6, 2025
  19. janb84 commented at 8:44 am on June 6, 2025: contributor

    After some contemplating I think the Python code is the better way to go. The Rust code was written a bit verbose and could have been made smaller, but Python seems like the more suitable tool for this task because:

    • Its more readable for CI maintenance, more people have python knowledge.
    • Python integrates better with existing CI tooling (e.g. is already used in the ci.yml)
    • Lower barrier to entry for contributors who need to debug CI issues.

    And Python still gives us the advantages over Bash!

    ACK https://github.com/bitcoin/bitcoin/commit/fa9cfdf3be754b01e6ce73a0cc2f998b81e12970

    code reviewed ✅ build & tested ✅ ran the python script separately ✅

  20. in .github/ci-test-each-commit-exec.py:12 in fac60b9c48 outdated
     7+import sys
     8+import shlex
     9+
    10+
    11+def run(cmd, **kwargs):
    12+    print("+ " + shlex.join(cmd), flush=True)
    


    ryanofsky commented at 1:12 pm on June 10, 2025:
    Could add file=sys.stderr if want to emulate bash tracing (not necessarily better though)

    maflcko commented at 1:31 pm on June 10, 2025:
    CI usually combines both stdout and stderr into one log file, so I’ll leave this as-is for now for simplicity.
  21. ryanofsky approved
  22. ryanofsky commented at 1:16 pm on June 10, 2025: contributor
    Code review ACK fa9cfdf3be754b01e6ce73a0cc2f998b81e12970
  23. achow101 commented at 6:17 pm on June 10, 2025: member
    ACK fa9cfdf3be754b01e6ce73a0cc2f998b81e12970
  24. achow101 merged this on Jun 10, 2025
  25. achow101 closed this on Jun 10, 2025

  26. maflcko deleted the branch on Jun 11, 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-06-15 06:13 UTC

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