Skip to content

ci: add Guix builds to CI - #36082

Open
willcl-ark wants to merge 5 commits into
bitcoin:masterfrom
willcl-ark:guix-ci-v2
Open

willcl-ark wants to merge 5 commits into
bitcoin:masterfrom
willcl-ark:guix-ci-v2

Conversation

@willcl-ark

@willcl-ark willcl-ark commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

Currently there is limited continuous testing of our exact release binaries. This is acceptable today as we use many similar toolchain configurations in CI which has most/everything we use in Guix pretty much covered. Many PRs also see Guix builds, although few of those probably run tests against the Guix-built binaries.

This PR would continuously exercise the Guix building process itself, but also, in the event that we start shipping some fully-static Linux builds (x64 and aarch64) as per current revision of #25573, our entire custom-built static glibc and compiler toolchain would be relatively untested by current CI jobs, and that would also be tested here.


This adds Guix builds for the following platforms:

  • arm64-apple-darwin
  • x86_64-linux-gnu
  • x86_64-w64-mingw32

The resulting binaries are then tested in a subsequent job.

@DrahtBot DrahtBot added the Tests label Aug 25, 2026
@DrahtBot

DrahtBot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

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

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK fanquake, sedited

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #35855 (guix: update time-machine by fanquake)

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.

@willcl-ark

Copy link
Copy Markdown
Member Author

#36006 got auto-closed by a linked PR.

More info on the infra side of things:

I have configured two physically separate bitcoin core substitute servers for better availability (using this module. One server evaluates the guix closure and builds it. Then uses guix copy to copy store items to the second server via ssh.

We could include the default substitute servers (https://bordeaux.guix.gnu.org https://ci.guix.gnu.org), but this makes the CI runs noticeably slower as these (slow) servers are queried even when not used/selected. These servers obviously will never include our custom compilers, which are the slowest thing to build, too.

I tested a run with a single substitute server, shutting the server off part way through, and Guix didn't like that it thought a substitute should be available but then wasn't and so failed. I think our use of --fallback protects us in the case that no substitute servers are available before the run begins; everything is just rebuilt, but have not tested this yet.

@willcl-ark
willcl-ark marked this pull request as ready for review August 26, 2026 07:15
@willcl-ark
willcl-ark marked this pull request as draft August 26, 2026 08:14
@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task macOS native, fuzz: https://github.com/bitcoin/bitcoin/actions/runs/32941900565/job/98094394757
LLM reason (✨ experimental): CI failed because the rpc fuzz target returned exit code 1 due to an “Error processing input” during fuzzing.

Hints

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.

@willcl-ark
willcl-ark force-pushed the guix-ci-v2 branch 3 times, most recently from b4c694c to aa794bc Compare August 26, 2026 12:38
@willcl-ark

Copy link
Copy Markdown
Member Author

@hebasto I think that efbb911 (the first commit here) and #35929 are duplicating solutions in different ways.

I believe that #35929 is the neater solution, and still covers the multi-toolchain (dual Guix build) scenario via embedding the toolchain info in the build ID as part of:

BASE_CACHE/<host>/<package>/<package>-<version>-<build_id>.tar.gz

Do you agree? If so I think I'll drop efbb911 from here, and rebase on/review #35929.

@hebasto

hebasto commented Aug 28, 2026

Copy link
Copy Markdown
Member

@hebasto I think that efbb911 (the first commit here) and #35929 are duplicating solutions in different ways.

I've reviewed and tested efbb911. Compared to #35929, it manages to fix the first subissue: "1. All depends are rebuilt when switching to another branch with identical Guix scripts and the depends subdirectory". Unfortunately, it fails to resolve the second one: "2. All non-GUI packages are built twice per host (mostly relevant for non-Linux hosts)".

Another point worth mentioning: for your commit to work as expected, the BASE_CACHE environment variable must be set explicitly.

I believe that #35929 is the neater solution, and still covers the multi-toolchain (dual Guix build) scenario via embedding the toolchain info in the build ID as part of:

BASE_CACHE/<host>/<package>/<package>-<version>-<build_id>.tar.gz

Do you agree? If so I think I'll drop efbb911 from here, and rebase on/review #35929.

That sounds good to me.

@hebasto

hebasto commented Aug 28, 2026

Copy link
Copy Markdown
Member

@willcl-ark

Please also consider #35929 (comment).

@willcl-ark

Copy link
Copy Markdown
Member Author

Thanks hebasto, that sounds reasonable to me

@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/actions/runs/36594516478/job/109495857711
LLM reason (✨ experimental): CI failed because the lint-files check reported an executable-permission issue: .github/ci-guix-test.py has mode 644 despite a shebang, instead of 755.

Hints

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.

@willcl-ark

Copy link
Copy Markdown
Member Author

If we start shipping fully static (glibc-based) linux binaries it would seem prudent to have a CI job testing them.

This PR would cover x64 linux in that regard. We could probably add aarch64 too, or even start with just those two jobs.

An alternative would be to add a non-Guix job which built the static toolchain(s) and binary (re-inventing the Guix build in the process though).

@maflcko

maflcko commented Oct 2, 2026

Copy link
Copy Markdown
Member

If we start shipping fully static (glibc-based) linux binaries it would seem prudent to have a CI job testing them.

I think that is a good reason. Mind including the goal/motivation in the pull description, so that it is easier to follow? Currently it just repeats what the code changes are, but this is visible from looking at the commits already.

@willcl-ark

Copy link
Copy Markdown
Member Author

Thanks I've updated the description as you suggest.

I'd gone for linux + windows + mac here to cover as many bases as possible in the fewest number of jobs, but perhaps aarch64-linux is worth covering too post-#25573, or could replace the windows or macos job?

I'll rebase and push a few tidy-ups to the top two commits which were LLM-written as a PoC/test.

@fanquake

fanquake commented Nov 5, 2026

Copy link
Copy Markdown
Member

Could you rebase again, post #36193?

Make the pinned repository and commit available to callers that source the
Guix prelude.

A Bitcoin Core-specific substitute server only needs to build the
packages in the guix closure at a specific time machine commit. It does
not need to build the bitcoin core binary applications.

To facilitate extracting the time-machine commit, export it as a
variable, so substitute builders (and anybody else) can re-use it by
sourcing the prelude, instead of requiring error-prone command string parsing.
@willcl-ark

Copy link
Copy Markdown
Member Author

Rebased with a small depends sources cache fixup

range-diff
  1:  b0807c964c0 = 182:  95e52e18b5e guix: expose time-machine metadata
  2:  25f3e5fc8e1 ! 183:  31daf63b454 ci: add Guix build job
    @@ .github/workflows/guix.yml (new)
     +        with:
     +          provider: ${{ github.repository == 'bitcoin/bitcoin' && 'warp' || 'gha' }}
     +          path: ${{ env.SOURCES_PATH }}
    -+          key: guix-depends-sources-${{ hashFiles('depends/**') }}
    -+          restore-keys: guix-depends-sources-
    ++          key: guix-depends-sources-${{ matrix.host }}-${{ hashFiles('depends/**') }}
    ++          restore-keys: guix-depends-sources-${{ matrix.host }}-
     +
     +      - name: Restore built depends cache
     +        id: built-depends-cache
  3:  e088de7527f = 184:  6ab622eaec3 ci: test Guix codesign environments
  4:  69adb897849 = 185:  8233281ada8 guix: copy config.ini before deleting build dir
  5:  cc8149b24f3 ! 186:  f14dc8b180f ci: test Guix release binaries
    @@ .github/ci-guix-test.py (new)
     +    with (workspace / "test" / "config.ini").open("w", encoding="utf-8") as file:
     +        config.write(file)
     +
    ++    sanitizer_template = (workspace / "test" / "with_sanitizer_env.py.in").read_text(encoding="utf-8")
    ++    (workspace / "test" / "with_sanitizer_env.py").write_text(
    ++        sanitizer_template.replace("@PROJECT_SOURCE_DIR@", workspace.as_posix()), encoding="utf-8",
    ++    )
    ++
     +    env = os.environ.copy()
     +    binaries = {
     +        "BITCOIN_BIN": "bitcoin",
    @@ .github/workflows/guix.yml: jobs:
     +          }
     +          & $venvPython -m pip install pyzmq
     +          if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
    ++          if (!$IsWindows) {
    ++            & $venvPython -m pip install pycapnp
    ++            if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
    ++          }
     +          & $venvPython .github/ci-guix-test.py
     +          exit $LASTEXITCODE
     +
  6:  4bac9a480fc <   -:  ----------- fixup! ci: test Guix release binaries

@willcl-ark

Copy link
Copy Markdown
Member Author

Added the fail-fast cleanup guard and the existing SKIP_BRANCH_PUSH opt-out suggested by ralph. Deferring the other change for now.

Also selected Python 3.14 for the native test jobs to fix the CI failure: macOS picked up Python 3.15, which forced a pycapnp source build that failed against the runner’s OpenSSL headers. Python 3.14 has a prebuilt macOS ARM64 wheel.

range-diff
1:  31daf63b454 ! 1:  601b37e89d8 ci: add Guix build job
    @@ .github/workflows/guix.yml (new)
     +jobs:
     +  guix:
     +    name: Guix, ${{ matrix.host }}
    ++    if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}
     +    runs-on: ${{ github.repository == 'bitcoin/bitcoin' && 'warp-ubuntu-latest-x64-8x' || 'ubuntu-24.04' }}
     +    timeout-minutes: 360
     +    strategy:
2:  6ab622eaec3 = 2:  31f9c9345f6 ci: test Guix codesign environments
3:  8233281ada8 = 3:  9de6048cf6f guix: copy config.ini before deleting build dir
4:  f14dc8b180f ! 4:  b000dd58365 ci: test Guix release binaries
    @@ .github/workflows/guix.yml: jobs:
     +    runs-on: ${{ matrix.runner }}
     +    timeout-minutes: 180
     +    env:
    ++      CI_FAILFAST_TEST_LEAVE_DANGLING: 1
     +      PYTHONUTF8: 1
     +    strategy:
     +      fail-fast: false
    @@ .github/workflows/guix.yml: jobs:
     +          path: releases
     +          key: guix-previous-releases-${{ matrix.host }}-${{ hashFiles('test/get_previous_releases.py') }}
     +
    ++      - name: Set up Python
    ++        uses: actions/setup-python@v7
    ++        with:
    ++          python-version: '3.14'
    ++
     +      - name: Test release binaries
     +        shell: pwsh
     +        run: |

@DrahtBot

DrahtBot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/actions/runs/42245724026/job/127987305599
LLM reason (✨ experimental): CI failed lint checks: ci/guix-entrypoint.sh lacks executable permissions and LC_ALL=C.UTF-8 exports are missing from both Guix scripts.

Hints

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.

@hebasto

hebasto commented Nov 9, 2026

Copy link
Copy Markdown
Member

https://github.com/bitcoin/bitcoin/actions/runs/42245724026/job/127987305599?pr=36082:

File "ci/guix-entrypoint.sh" contains a shebang line, but has the file permission 644 instead of the expected executable permission 755. Do "chmod 755 ci/guix-entrypoint.sh" (or remove the shebang line).
ERROR: There were 1 failed tests in the lint-files.py lint test. Please resolve the above errors.
^---- ⚠️ Failure generated from lint-files.py
<snip>
[3](https://github.com/bitcoin/bitcoin/actions/runs/42245724026/job/127987305599?pr=36082#step:6:194)
Missing "export LC_ALL=C.UTF-8" (to avoid locale dependence) as first non-comment non-empty line in ci/guix-entrypoint.sh
Missing "export LC_ALL=C.UTF-8" (to avoid locale dependence) as first non-comment non-empty line in ci/guix_run_all.sh
^---- ⚠️ Failure generated from lint-shell-locale.py

Run single-host Guix builds on pull requests and branch pushes. Cache the
prepared Guix image as well as depends sources, built dependencies, and
the macOS SDK so fresh runners can reuse the pinned build environment.

Pass channel metadata from the Guix prelude to the image build. Preserve
its authenticated time-machine profile and store closure, refreshing the
profile timestamp at startup so older cached images remain usable.

Keep container orchestration in one CI script. Copy the read-only checkout
and restored caches into a private build directory, then export outputs
and updated caches as the host user. This avoids changing ownership of the
host checkout. Allow Guix's namespace and personality operations during
image preparation and runtime builds.
The regular Guix builds do not evaluate the codesign manifest, so missing
imports and broken signing dependencies can go unnoticed until signing.

Realize each signing target's environment before its main build to catch
these failures without requiring signatures or signing keys.
This allows us to use the build config.ini in later testing as it's not
deleted.
Test x64, windows and macOS binaries on native runners.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants