Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ jobs:
runs-on: ubuntu-latest

env:
NIXPKGS_CHANNEL: nixos-25.05
NIX_EXTRA_CONFIG: |
keep-env-derivations = true
keep-outputs = true
NIX_EXTRA_CONFIG_ACT: |
sandbox = false
filter-syscalls = false
Expand All @@ -145,14 +149,33 @@ jobs:
steps:
- uses: actions/checkout@v5

- name: Determine CI configuration
id: config
env:
CI_CONFIG: ci/configs/${{ matrix.config }}.bash
run: ci/scripts/config.sh

- name: Install Nix
uses: cachix/install-nix-action@v31 # 2025-05-27, from https://github.com/cachix/install-nix-action/tags
with:
nix_path: nixpkgs=channel:nixos-25.05 # latest release
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/${{ steps.config.outputs.nixpkgs_rev }}.tar.gz
# Act executes inside an unprivileged container (Docker or Podman),
# so KVM support isn't available.
enable_kvm: "${{ github.actor != 'nektos/act' }}"
extra_nix_config: ${{ github.actor == 'nektos/act' && env.NIX_EXTRA_CONFIG_ACT || '' }}
extra_nix_config: |
${{ env.NIX_EXTRA_CONFIG }}
${{ github.actor == 'nektos/act' && env.NIX_EXTRA_CONFIG_ACT || '' }}

- name: Cache Nix store
if: steps.config.outputs.cache_nix_store == 'true'
uses: nix-community/cache-nix-action@v7
with:
primary-key: nix-${{ runner.os }}-${{ matrix.config }}-${{ steps.config.outputs.nixpkgs_rev }}-${{ hashFiles('shell.nix', 'ci/patches/*.patch', format('ci/configs/{0}.bash', matrix.config)) }}
restore-prefixes-first-match: |
nix-${{ runner.os }}-${{ matrix.config }}-${{ steps.config.outputs.nixpkgs_rev }}-
nix-${{ runner.os }}-${{ matrix.config }}-
nix-${{ runner.os }}-
gc-max-store-size-linux: 10G

- name: Run CI script
env:
Expand Down
2 changes: 2 additions & 0 deletions ci/configs/gnu32.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
CI_DESC="CI job cross-compiling to 32-bit"
CI_DIR=build-gnu32
# Cache the heaviest Nix job to stay within GitHub's cache budget.
CI_CACHE_NIX_STORE=true
NIX_ARGS=(
--arg minimal true
--arg crossPkgs 'import <nixpkgs> { crossSystem = { config = "i686-unknown-linux-gnu"; }; }'
Expand Down
24 changes: 24 additions & 0 deletions ci/scripts/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#
# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Source CI configuration and output variables needed by the workflow.

set -o errexit -o nounset -o pipefail -o xtrace

readonly SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"

source "${SCRIPT_DIR}/ci_helpers.sh"

[ "${CI_CONFIG+x}" ] && source "$CI_CONFIG"

# Resolve the nixpkgs channel to a specific revision for use in cache keys.
if [[ -n "${NIXPKGS_CHANNEL:-}" ]]; then
rev="$(curl --fail --location --silent --show-error "https://channels.nixos.org/${NIXPKGS_CHANNEL}/git-revision")"
test -n "${rev}"
write_output_var nixpkgs_rev "${rev}"
fi

write_output_var cache_nix_store "${CI_CACHE_NIX_STORE:-false}"
11 changes: 11 additions & 0 deletions ci/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ set -o errexit -o nounset -o pipefail -o xtrace
[ "${CI_CONFIG+x}" ] && source "$CI_CONFIG"

nix develop --ignore-environment --keep CI_CONFIG --keep CI_CLEAN "${NIX_ARGS[@]+"${NIX_ARGS[@]}"}" -f shell.nix --command ci/scripts/ci.sh

# Create a GC root for the shell closure so the cache-nix-action save step
# does not garbage-collect it.
if [ -n "${CI_CACHE_NIX_STORE-}" ]; then
nix-build shell.nix \
-o "$CI_DIR/gcroot" \
"${NIX_ARGS[@]+"${NIX_ARGS[@]}"}"
# Verify the closure is complete so the cache-nix-action save step has
# everything it needs.
nix-store --query --requisites "$CI_DIR/gcroot" >/dev/null
fi
Loading