From 219da90eca3626c572dce2c019eba7b0ef3eddb0 Mon Sep 17 00:00:00 2001 From: Maxim Dozhdev Date: Mon, 16 Nov 2026 11:32:57 +0100 Subject: [PATCH 1/3] ci: run Mac test jobs on the self-hosted Mac mini again Move e2e-tests-local, integration tests and the Trezor emulator job off Namespace back to [self-hosted, macOS], with the regtest stack on the runner's own Docker, and drop the Namespace stack script. Co-Authored-By: Claude Opus 5.5 --- .github/scripts/namespace-stack.sh | 96 ------------------------- .github/workflows/ai-device-tests.yml | 18 ++--- .github/workflows/e2e-tests.yml | 55 ++++++-------- .github/workflows/integration-tests.yml | 14 ++-- 4 files changed, 32 insertions(+), 151 deletions(-) delete mode 100755 .github/scripts/namespace-stack.sh diff --git a/.github/scripts/namespace-stack.sh b/.github/scripts/namespace-stack.sh deleted file mode 100755 index ee22662761..0000000000 --- a/.github/scripts/namespace-stack.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash -# Runs a Docker Compose stack for a Namespace macOS runner on a separate Namespace Linux -# instance. macOS runners are VMs without nested virtualization, so Docker cannot run on them. -# -# namespace-stack.sh up create the instance, point docker at it, copy over; -# later steps get a docker wrapper that runs exec on the instance -# namespace-stack.sh forward ... expose instance ports on the runner's 127.0.0.1 under the same numbers -# namespace-stack.sh down destroy the instance -set -euo pipefail - -state_dir=/tmp/namespace-stack -instance_file="$state_dir/instance" - -install_compose() { - docker compose version >/dev/null 2>&1 && return - mkdir -p ~/.docker/cli-plugins - curl -fsSL -o ~/.docker/cli-plugins/docker-compose \ - https://github.com/docker/compose/releases/download/v5.6.0/docker-compose-darwin-aarch64 - chmod +x ~/.docker/cli-plugins/docker-compose -} - -up() { - local compose_dir - compose_dir="$(cd "$1" && pwd)" - mkdir -p "$state_dir/docker" - install_compose - - # The runner sets DOCKER_DEFAULT_PLATFORM=linux/arm64, so the instance must be arm64. - nsc create --bare --machine_type linux/arm64:8x16 --duration 4h --cidfile "$instance_file" - - # `attach-context --background` times out before its socket appears; the foreground form works. - nohup nsc docker attach-context --to "$(cat "$instance_file")" --name namespace-stack \ - --state "$state_dir/docker" --use > "$state_dir/attach.log" 2>&1 & - - local deadline=$((SECONDS + 300)) - until docker info >/dev/null 2>&1; do - if ((SECONDS > deadline)); then - cat "$state_dir/attach.log" >&2 - exit 1 - fi - sleep 5 - done - - # `docker exec` through the attached context returns no output, drops stdin and always exits 0. - # The same command run on the instance over `nsc ssh` behaves normally, except that any failure - # exits 1 rather than with the command's own code, so exec is routed there. - mkdir -p "$state_dir/bin" - cat > "$state_dir/bin/docker" <> "$GITHUB_PATH" - fi - - # Bind mounts resolve on the instance, so the compose directory has to exist there at the same path. - docker create --name namespace-stack-seed -v "$compose_dir:/seed" alpine:3 true >/dev/null - docker cp "$compose_dir/." namespace-stack-seed:/seed/ - docker rm namespace-stack-seed >/dev/null - docker run --rm -v "$compose_dir:/seed" alpine:3 chmod -R a+rwX /seed -} - -forward() { - local port - for port in "$@"; do - nohup nsc instance port-forward "$(cat "$instance_file")" --target_port "$port" \ - > "$state_dir/forward-$port.log" 2>&1 & - done - - local deadline=$((SECONDS + 300)) - for port in "$@"; do - until nc -z 127.0.0.1 "$port" 2>/dev/null; do - if ((SECONDS > deadline)); then - cat "$state_dir/forward-$port.log" >&2 - exit 1 - fi - sleep 3 - done - done -} - -down() { - pkill -f "nsc instance port-forward" || true - pkill -f "nsc docker attach-context" || true - docker context use default >/dev/null 2>&1 || true - if [[ -s "$instance_file" ]]; then - nsc destroy "$(cat "$instance_file")" --force || true - fi -} - -"$@" diff --git a/.github/workflows/ai-device-tests.yml b/.github/workflows/ai-device-tests.yml index b3ee750407..26b29d21b8 100644 --- a/.github/workflows/ai-device-tests.yml +++ b/.github/workflows/ai-device-tests.yml @@ -32,7 +32,7 @@ jobs: trezor-emu: if: inputs.suite == 'trezor-emu' name: Trezor emulator dashboard - runs-on: namespace-profile-mac + runs-on: [self-hosted, macOS] timeout-minutes: 90 steps: @@ -66,15 +66,6 @@ jobs: run: | xcodebuild -resolvePackageDependencies -onlyUsePackageVersionsFromResolvedFile | xcbeautify - - name: Start remote Docker - run: | - awk '{ print } /^ trezor-user-env-mac:$/ { print " extra_hosts:\n - \"host.docker.internal:host-gateway\"" }' \ - bitkit-docker/docker-compose.yml > /tmp/docker-compose.yml - mv /tmp/docker-compose.yml bitkit-docker/docker-compose.yml - mkdir -p bitkit-docker/lnd bitkit-docker/.trezor-user-env/{trezor-suite,logs/screens,logs/mcp-screenshots,firmware/user_downloaded} - .github/scripts/namespace-stack.sh up bitkit-docker - .github/scripts/namespace-stack.sh forward 43782 39388 60001 21325 21328 9001 23902 - - name: Start regtest and Trezor emulator working-directory: bitkit-docker run: | @@ -148,6 +139,9 @@ jobs: path: ai-device-artifacts/trezor if-no-files-found: warn - - name: Tear down emulator stack + - name: Stop emulator services if: always() - run: .github/scripts/namespace-stack.sh down + working-directory: bitkit-docker + run: | + ./scripts/trezor-emulator stop || true + docker compose down || true diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index e53032691a..cff5aa9dcb 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -228,11 +228,8 @@ jobs: checks: write actions: write if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true' - runs-on: namespace-profile-mac + runs-on: [self-hosted, macOS] needs: [detect-changes, build-local, e2e-branch] - env: - SIMULATOR_NAME: "iPhone 17" - SIMULATOR_OS_VERSION: "26.5" strategy: fail-fast: false @@ -247,12 +244,6 @@ jobs: name: e2e-tests-local - ${{ matrix.shard.name }} steps: - - name: Checkout stack scripts - uses: actions/checkout@v7 - with: - ref: ${{ inputs.merge_commit || '' }} - sparse-checkout: .github/scripts - - name: Checkout retarget reporter if: inputs.retarget_run != '' uses: actions/checkout@v7 @@ -315,11 +306,23 @@ jobs: working-directory: bitkit-e2e-tests run: npm ci + - name: Docker info + run: | + docker --version + docker info + docker ps + docker compose version + + - name: Reset regtest environment + working-directory: bitkit-e2e-tests/docker + continue-on-error: true + run: docker compose --verbose down -v -t 300 + - name: Run regtest setup + working-directory: bitkit-e2e-tests/docker run: | - .github/scripts/namespace-stack.sh up bitkit-e2e-tests/docker - (cd bitkit-e2e-tests/docker && docker compose up --force-recreate -d) - .github/scripts/namespace-stack.sh forward 43782 39388 60001 8080 9735 10009 3003 9001 9002 21325 21328 + mkdir -p lnd && chmod 777 lnd + docker compose --verbose up --force-recreate -d - name: Wait for electrum server run: | @@ -329,17 +332,6 @@ jobs: done exit 1 - - name: Copy LND credentials - working-directory: bitkit-e2e-tests/docker - run: | - mkdir -p lnd/data/chain/bitcoin/regtest - for _ in $(seq 1 60); do - docker cp lnd:/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon lnd/data/chain/bitcoin/regtest/ 2>/dev/null && break - sleep 5 - done - docker cp lnd:/home/lnd/.lnd/tls.cert lnd/tls.cert - test -s lnd/data/chain/bitcoin/regtest/admin.macaroon - - name: Clear previous E2E artifacts working-directory: bitkit-e2e-tests run: | @@ -348,16 +340,8 @@ jobs: - name: Clear iOS Simulator environment run: | - udid=$(xcrun simctl list devices available -j | python3 -c ' - import json, os, sys - runtime = "com.apple.CoreSimulator.SimRuntime.iOS-" + os.environ["SIMULATOR_OS_VERSION"].replace(".", "-") - devices = json.load(sys.stdin)["devices"].get(runtime, []) - print(next(d["udid"] for d in devices if d["name"] == os.environ["SIMULATOR_NAME"])) - ') xcrun simctl shutdown all || true - xcrun simctl erase "$udid" - xcrun simctl boot "$udid" - xcrun simctl bootstatus "$udid" -b + xcrun simctl erase "iPhone 17" || true defaults write com.apple.iphonesimulator DisableAllNotifications -bool true - name: Run E2E Tests 1 (${{ matrix.shard.name }}) @@ -397,9 +381,10 @@ jobs: path: bitkit-e2e-tests/artifacts/ retention-days: 7 - - name: Tear down regtest stack + - name: Cleanup Docker containers if: always() - run: .github/scripts/namespace-stack.sh down + working-directory: bitkit-e2e-tests/docker + run: docker compose down -v || true e2e-status: if: always() && github.event.pull_request.draft == false diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 1e8b2869c5..ca41a8d691 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -46,9 +46,7 @@ jobs: cache-mode: read if: github.event.pull_request.draft == false name: Run Integration Tests - # The suites fund and mine on a local regtest stack. macOS runners cannot run Docker, so this - # runs on Namespace, which hosts the stack on a Linux instance (see namespace-stack.sh). - runs-on: namespace-profile-mac + runs-on: [self-hosted, macOS] timeout-minutes: 60 permissions: contents: read @@ -96,12 +94,11 @@ jobs: path: bitkit-docker - name: Start local regtest + working-directory: bitkit-docker run: | - .github/scripts/namespace-stack.sh up bitkit-docker - .github/scripts/namespace-stack.sh forward 43782 60001 - (cd bitkit-docker && docker compose up -d bitcoind bitcoinsetup electrs) + docker compose down -v -t 60 || true + docker compose up -d bitcoind bitcoinsetup electrs - # A separate step: `namespace-stack.sh up` puts its `docker exec` wrapper on the PATH for later steps only. - name: Mine initial blocks timeout-minutes: 5 run: until docker exec bitcoin bitcoin-cli -regtest -rpcport=43782 -rpcuser=polaruser -rpcpassword=polarpass -generate 101; do sleep 2; done @@ -212,7 +209,8 @@ jobs: - name: Tear down regtest stack if: always() - run: .github/scripts/namespace-stack.sh down + working-directory: bitkit-docker + run: docker compose down -v || true report-retarget-result: name: Report retarget integration result From 5346ac05ba7225398fc34c27335d9dd4508da281 Mon Sep 17 00:00:00 2001 From: Maxim Dozhdev Date: Mon, 16 Nov 2026 12:54:36 +0100 Subject: [PATCH 2/3] ci: reset the integration simulator before booting it on the Mac mini Co-Authored-By: Claude Opus 5.5 --- .github/workflows/integration-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index ca41a8d691..f0fc9ccb5f 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -123,6 +123,8 @@ jobs: ') echo "SIMULATOR_UDID=$udid" >> "$GITHUB_ENV" echo "DESTINATION=platform=iOS Simulator,id=$udid" >> "$GITHUB_ENV" + xcrun simctl shutdown all || true + xcrun simctl erase "$udid" xcrun simctl boot "$udid" - name: Install xcbeautify From bb808a045910786425ec5b52f9fd22273219c0aa Mon Sep 17 00:00:00 2001 From: Maxim Dozhdev Date: Mon, 16 Nov 2026 13:13:33 +0100 Subject: [PATCH 3/3] ci: run integration tests on hosted macos-26 with a native regtest stack Hosted macOS cannot run Docker, but the suite only needs bitcoind and electrs, which run natively. Keeps integration off the Mac mini so it does not queue behind the E2E job. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/integration-tests.yml | 57 ++++++++++++++++--------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index f0fc9ccb5f..90f567fbdc 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -46,7 +46,7 @@ jobs: cache-mode: read if: github.event.pull_request.draft == false name: Run Integration Tests - runs-on: [self-hosted, macOS] + runs-on: macos-26 timeout-minutes: 60 permissions: contents: read @@ -86,22 +86,41 @@ jobs: const {reportRetargetResult} = require('./retarget-ci/.github/scripts/retarget-tests.cjs'); await reportRetargetResult({github, context, core, name: 'Run Integration Tests', phase: 'start'}); - - name: Checkout bitkit-docker - uses: actions/checkout@v7 + - name: Install bitcoind + run: | + curl -fsSL -o /tmp/bitcoin.tar.gz https://bitcoincore.org/bin/bitcoin-core-26.0/bitcoin-26.0-arm64-apple-darwin.tar.gz + tar -xzf /tmp/bitcoin.tar.gz -C /tmp + echo "/tmp/bitcoin-26.0/bin" >> "$GITHUB_PATH" + + - name: Cache electrs + id: electrs-cache + uses: actions/cache@v6 with: - repository: synonymdev/bitkit-docker - ref: main - path: bitkit-docker + path: ~/.cargo/bin/electrs + key: electrs-0.10.2-${{ runner.os }}-${{ runner.arch }} - - name: Start local regtest - working-directory: bitkit-docker + - name: Build electrs + if: steps.electrs-cache.outputs.cache-hit != 'true' run: | - docker compose down -v -t 60 || true - docker compose up -d bitcoind bitcoinsetup electrs + cargo install electrs --version 0.10.2 --locked - - name: Mine initial blocks - timeout-minutes: 5 - run: until docker exec bitcoin bitcoin-cli -regtest -rpcport=43782 -rpcuser=polaruser -rpcpassword=polarpass -generate 101; do sleep 2; done + - name: Start local regtest + env: + BITCOIN_DIR: ${{ runner.temp }}/bitcoin + ELECTRS_DB: ${{ runner.temp }}/electrs + run: | + mkdir -p "$BITCOIN_DIR" "$ELECTRS_DB" + bitcoind -regtest -daemon -datadir="$BITCOIN_DIR" \ + -rpcport=43782 -rpcbind=127.0.0.1 -rpcallowip=127.0.0.1 -port=39388 \ + -rpcauth='polaruser:5e5e98c21f5c814568f8b55d83b23c1c$066b03f92df30b11de8e4b1b1cd5b1b4281aa25205bd57df9be82caf97a05526' \ + -txindex=1 -fallbackfee=0.00002 -maxmempool=500 + cli() { bitcoin-cli -regtest -rpcport=43782 -rpcuser=polaruser -rpcpassword=polarpass "$@"; } + until cli getblockchaininfo >/dev/null 2>&1; do sleep 1; done + cli createwallet default >/dev/null + cli -generate 101 >/dev/null + nohup ~/.cargo/bin/electrs --network regtest --db-dir "$ELECTRS_DB" --daemon-dir "$BITCOIN_DIR" \ + --daemon-rpc-addr 127.0.0.1:43782 --daemon-p2p-addr 127.0.0.1:39388 \ + --electrum-rpc-addr 127.0.0.1:60001 > "${{ runner.temp }}/electrs.log" 2>&1 & - name: Set up Xcode uses: maxim-lobanov/setup-xcode@v1 @@ -123,8 +142,6 @@ jobs: ') echo "SIMULATOR_UDID=$udid" >> "$GITHUB_ENV" echo "DESTINATION=platform=iOS Simulator,id=$udid" >> "$GITHUB_ENV" - xcrun simctl shutdown all || true - xcrun simctl erase "$udid" xcrun simctl boot "$udid" - name: Install xcbeautify @@ -209,10 +226,12 @@ jobs: name: integration-test-results path: ${{ env.RESULT_BUNDLE }} - - name: Tear down regtest stack - if: always() - working-directory: bitkit-docker - run: docker compose down -v || true + - name: Upload electrs log + if: failure() + uses: actions/upload-artifact@v7 + with: + name: electrs-log + path: ${{ runner.temp }}/electrs.log report-retarget-result: name: Report retarget integration result