ci: Allow running iwyu CI in worktree #34441

pull maflcko wants to merge 2 commits into bitcoin:master from maflcko:2601-ci-iwyu-worktree changing 4 files +32 −3
  1. maflcko commented at 9:21 am on January 29, 2026: member

    Currently, the iwyu CI fails to run in a git-worktree, or git-archive. This is due to the use of git diff.

    Fix this by force-initializing a dummy git repo with a single dummy commit.

    It may be possible to detect when git diff is not available in the directory, and only apply the fallback when needed, but the git history is not needed and it is easier to unconditionally apply the git init.

  2. DrahtBot added the label Tests on Jan 29, 2026
  3. DrahtBot commented at 9:22 am on January 29, 2026: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK willcl-ark, hebasto

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    No conflicts as of last run.

  4. maflcko force-pushed on Jan 29, 2026
  5. DrahtBot added the label CI failed on Jan 29, 2026
  6. DrahtBot commented at 9:32 am on January 29, 2026: contributor

    🚧 At least one of the CI tasks failed. Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/21472570144/job/61848516389 LLM reason (✨ experimental): IWYU reported a failure in the CI run.

    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. DrahtBot removed the label CI failed on Jan 29, 2026
  8. in ci/test/03_test_script.sh:52 in 88887114b8
    43@@ -44,6 +44,19 @@ echo "=== BEGIN env ==="
    44 env
    45 echo "=== END env ==="
    46 
    47+if [[ "${RUN_IWYU}" == true ]]; then
    48+  # The CI framework should be flexible where it is run from. For example, from
    49+  # a git-archive, a git-worktree, or a normal git repo.
    50+  # The iwyu task requires a working git repo, which may not always be
    51+  # available, so initialize one with force.
    52+  rm -rf .git
    


    ryanofsky commented at 8:29 pm on January 30, 2026:

    In commit “ci: Allow running iwyu ci in worktree” (88887114b89de6642197fce8afd005172f8bc260)

    This seems dangerous. It should be safe to run ci commands locally without expecting your git history to be wiped away. Would suggest a tweak like:

    0# Initialize git if this is not a normal git directory (e.g. is a worktree)
    1if [[ "$RUN_IWYU" == true && ! -d .git ]]; then
    2  [[ -e .git || -L .git ]] && mv .git .git-previous
    3  git init
    4fi
    

    maflcko commented at 9:02 am on January 31, 2026:

    I’d doubt that this script will pass at all when run locally and it is not designed to be used that way. Maybe there should be a check in the beginning, with an early abort if DANGER_RUN_CI_ON_HOST is not set?

    In any case, I’ve replaced this line with mv .git .git_ci_backup || true

  9. maflcko force-pushed on Jan 31, 2026
  10. maflcko force-pushed on Feb 3, 2026
  11. willcl-ark commented at 9:24 pm on February 16, 2026: member

    In the case that someone runs this script locally, might it be prudent to add a

    0mv .git_ci_backup .git || true
    

    to the end of the script to restore their .git directory to it’s original state and minimise broken worktree-related disappointments where possible?

    edit: sorry, just seen yours and ryanofsky’s comments above!

  12. maflcko force-pushed on Feb 17, 2026
  13. maflcko commented at 8:30 am on February 17, 2026: member

    edit: sorry, just seen yours and ryanofsky’s comments above!

    No worries. I’ve implemented my idea from the comment now.

  14. maflcko force-pushed on Feb 17, 2026
  15. DrahtBot added the label CI failed on Feb 17, 2026
  16. maflcko commented at 9:02 am on February 17, 2026: member

    The bash pipes are broken. Sigh, I guess it is time to re-write this in Python.

    https://github.com/bitcoin/bitcoin/actions/runs/22091425710/job/63837401348?pr=34441#step:11:2611 https://github.com/bitcoin/bitcoin/actions/runs/22091425710/job/63837401339?pr=34441#step:11:5205

    edit: dropped pipefail for now. This is unrelated and can be done in a follow-up.

  17. maflcko force-pushed on Feb 17, 2026
  18. maflcko force-pushed on Feb 17, 2026
  19. willcl-ark approved
  20. willcl-ark commented at 9:52 am on February 17, 2026: member

    ACK 99997ca18520783cbcf9eba8bac1dc5785362fb9

    Guarding with DANGER_RUN_CI_ON_HOST make good sense for these scripts as they modify the filesystem.

    Tested locally in a worktree (but I did not test outside of a container!).

    nit: tiny typo in commit message “exection”

  21. maflcko force-pushed on Feb 17, 2026
  22. maflcko force-pushed on Feb 17, 2026
  23. ci: Reject unsafe execution of shell scripts
    The shell scripts are inherently unsafe, because they will install new
    software packages, modify global configuration settings, write to the
    root / or $HOME, and possibly modify the git repo.
    
    The only safe way to run them is through the CI system itself, that is
    the ci_exec python function.
    
    The ci_exec funtion ensures that the user has set up a sandbox
    externally and set DANGER_RUN_CI_ON_HOST=1 at their own risk, or that a
    sandbox was set up with the given container_id, in which case it is safe
    to set DANGER_RUN_CI_ON_HOST=1 for that sandbox.
    Also, it is safe to set DANGER_RUN_CI_ON_HOST=1 when building the
    sandbox image in ci/test_imagefile.
    
    Then, the two shell scripts can reject early if unsafe execution is
    detected.
    fab73e213d
  24. ci: Allow running iwyu ci in worktree fafdb8f635
  25. maflcko force-pushed on Feb 17, 2026
  26. DrahtBot removed the label CI failed on Feb 17, 2026
  27. maflcko commented at 11:59 am on February 17, 2026: member

    nit: tiny typo in commit message “exection”

    thx, fixed

  28. willcl-ark approved
  29. willcl-ark commented at 12:08 pm on February 17, 2026: member

    reACK fafdb8f635bc157f55e23890264d12170ecd41ae

    Based on range-diff (excluding rebase) of:

     0src/core/bitcoin on  pcp-loglevel [$?] via △ v4.1.2 via 🐍 v3.13.11 via ❄️  impure (nix-shell-env)
     1❯ prw upstream 34441
     2From github.com:bitcoin/bitcoin
     3 * branch                    refs/pull/34441/head -> FETCH_HEAD
     4git range-diff 35e6444fdc4068adc79082648f9889ad593e623b..99997ca18520783cbcf9eba8bac1dc5785362fb9 c8c9c1e61759f689615a304254fed33cda7f895e..fafdb8f635bc157f55e23890264d12170ecd41ae
     51:  fa591c49a98 ! 1:  fab73e213de ci: Reject unsafe exection of shell scripts
     6    @@ Metadata
     7     Author: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
     8
     9      ## Commit message ##
    10    -    ci: Reject unsafe exection of shell scripts
    11    +    ci: Reject unsafe execution of shell scripts
    12
    13         The shell scripts are inherently unsafe, because they will install new
    14         software packages, modify global configuration settings, write to the
    152:  99997ca1852 = 2:  fafdb8f635b ci: Allow running iwyu ci in worktree
    16HEAD is now at fafdb8f635b ci: Allow running iwyu ci in worktree
    
  30. maflcko requested review from ryanofsky on Feb 17, 2026
  31. fanquake requested review from hebasto on Feb 17, 2026
  32. hebasto approved
  33. hebasto commented at 10:45 am on February 19, 2026: member
    ACK fafdb8f635bc157f55e23890264d12170ecd41ae, I have reviewed the code and it looks OK. Tested on Fedora 43.

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: 2026-02-22 18:12 UTC

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