From ad0aff104fdd03aea24e4b28de64d31192d884b9 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 19 Nov 2026 10:22:20 +0100 Subject: [PATCH 01/25] test: wire iOS E2E to local Spark --- .github/workflows/e2e-tests.yml | 80 ++++++++++++++++++- Bitkit/Constants/Env.swift | 5 ++ Bitkit/Info.plist | 4 + Bitkit/Managers/SparkManager.swift | 27 ++++++- .../Advanced/SparkConnectionViews.swift | 2 + 5 files changed, 114 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 6f7e32974..6958bf510 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -5,6 +5,10 @@ run-name: >- on: workflow_dispatch: inputs: + spark_only: + description: "Run only @spark_1 on pinned local Spark" + type: boolean + default: false e2e_branch: description: "Branch of synonymdev/bitkit-e2e-tests to use (main | default-feature-branch | custom branch name)" required: false @@ -91,7 +95,7 @@ jobs: pull-requests: read checks: write actions: write - if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true' + if: "!inputs.spark_only && github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true'" runs-on: macos-26 steps: @@ -401,8 +405,80 @@ jobs: (cd docker && docker compose --profile trezor down --remove-orphans -v) || true fi + e2e-spark: + if: inputs.spark_only && !inputs.pr + needs: e2e-branch + runs-on: [self-hosted, macOS] + timeout-minutes: 120 + env: + COMPOSE_PROJECT_NAME: bitkit-spark-e2e + steps: + - uses: actions/checkout@v7 + with: + path: bitkit-ios + persist-credentials: false + + - name: Resolve E2E tests ref + id: e2e-ref + uses: synonymdev/bitkit-e2e-tests/.github/actions/resolve-e2e-ref@main + with: + selected: ${{ needs.e2e-branch.outputs.branch }} + e2e_branch_input: ${{ inputs.e2e_branch }} + + - uses: actions/checkout@v7 + with: + repository: synonymdev/bitkit-e2e-tests + ref: ${{ steps.e2e-ref.outputs.ref }} + path: bitkit-e2e-tests + persist-credentials: false + + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: npm + cache-dependency-path: bitkit-e2e-tests/package-lock.json + + - name: Install Appium dependencies + working-directory: bitkit-e2e-tests + run: npm ci + + - name: Start pinned Spark fixture + id: spark + working-directory: bitkit-e2e-tests + run: | + ./scripts/local-backend prepare + ./scripts/local-backend spark-down --remove-orphans -v + ./scripts/local-backend spark-up + ./scripts/local-backend spark-env >> "$GITHUB_ENV" + + - name: Build iOS Spark app + working-directory: bitkit-e2e-tests + run: ./scripts/build-ios-sim.sh + + - name: Run @spark_1 + working-directory: bitkit-e2e-tests + run: ./scripts/run-spark-e2e.sh ios + + - name: Collect Spark logs + if: failure() + working-directory: bitkit-e2e-tests + run: | + mkdir -p artifacts + ./scripts/local-backend spark-logs --tail 200 > artifacts/spark-docker.log 2>&1 || true + + - name: Stop Spark fixture + if: always() && steps.spark.outcome != 'skipped' + working-directory: bitkit-e2e-tests + run: ./scripts/local-backend spark-down --remove-orphans -v + + - uses: actions/upload-artifact@v7 + if: always() + with: + name: spark-ios-${{ github.run_number }} + path: bitkit-e2e-tests/artifacts/ + e2e-status: - if: always() && github.event.pull_request.draft == false + if: always() && !inputs.spark_only && github.event.pull_request.draft == false name: e2e-status runs-on: ubuntu-24.04 needs: [detect-changes, e2e-tests-local] diff --git a/Bitkit/Constants/Env.swift b/Bitkit/Constants/Env.swift index f0507dcf7..06065c69a 100644 --- a/Bitkit/Constants/Env.swift +++ b/Bitkit/Constants/Env.swift @@ -109,6 +109,11 @@ enum Env { isE2E && e2eBackend == "local" } + static var localSparkSettings: (configBase64: String?, chainURL: String?) { + guard isDebug, isLocalE2EBackend, network == .regtest else { return (nil, nil) } + return (infoPlistValue("SPARK_LOCAL_CONFIG_B64"), infoPlistValue("SPARK_LOCAL_CHAIN_URL")) + } + private static var e2eLocalHost: String { configValue("E2E_LOCAL_HOST") ?? "127.0.0.1" } diff --git a/Bitkit/Info.plist b/Bitkit/Info.plist index a33a05f78..ccc26042b 100644 --- a/Bitkit/Info.plist +++ b/Bitkit/Info.plist @@ -55,6 +55,10 @@ $(E2E_LOCAL_HOST) E2E_NETWORK $(E2E_NETWORK) + SPARK_LOCAL_CONFIG_B64 + $(SPARK_LOCAL_CONFIG_B64) + SPARK_LOCAL_CHAIN_URL + $(SPARK_LOCAL_CHAIN_URL) TREZOR_BRIDGE $(TREZOR_BRIDGE) TREZOR_BRIDGE_URL diff --git a/Bitkit/Managers/SparkManager.swift b/Bitkit/Managers/SparkManager.swift index 0a02b6497..fec9e4fac 100644 --- a/Bitkit/Managers/SparkManager.swift +++ b/Bitkit/Managers/SparkManager.swift @@ -451,13 +451,16 @@ final class SparkManager: ChannelFreeLightningRail { throw CustomServiceError.mnemonicNotFound } let passphrase = try Keychain.loadString(key: .bip39Passphrase(index: walletIndex)) - let config = Self.sdkConfig(network: network, apiKey: Env.breezApiKey, isExiting: isExiting) + var config = Self.sdkConfig(network: network, apiKey: Env.breezApiKey, isExiting: isExiting) + let localChainURL = try Self.configureLocalSpark(&config) let storageDir = Env.sparkStorage(walletIndex: walletIndex) try FileManager.default.createDirectory(at: storageDir, withIntermediateDirectories: true) // What `BreezSdkSpark.connect` builds, plus our own chain service where Env names one. let builder = SdkBuilder(config: config, seed: .mnemonic(mnemonic: mnemonic, passphrase: passphrase)) await builder.withDefaultStorage(storageDir: storageDir.path) - if let chainServiceUrl = Env.sparkChainServiceUrl(for: Env.network) { + if let localChainURL { + await builder.withRestChainService(url: localChainURL, apiType: .mempoolSpace, credentials: nil) + } else if let chainServiceUrl = Env.sparkChainServiceUrl(for: Env.network) { await builder.withRestChainService(url: chainServiceUrl, apiType: .esplora, credentials: nil) } syncedThisRun = false @@ -475,6 +478,26 @@ final class SparkManager: ChannelFreeLightningRail { Self.notifyExitStateChanged() } + private nonisolated static func configureLocalSpark(_ config: inout BreezSdkSpark.Config) throws -> String? { + let settings = Env.localSparkSettings + if settings.configBase64 == nil, settings.chainURL == nil { + return nil + } + guard let encoded = settings.configBase64, + let data = Data(base64Encoded: encoded), + let json = String(data: data, encoding: .utf8), + let chainURL = settings.chainURL + else { + throw NSError(domain: "LocalSparkConfiguration", code: 1, userInfo: [ + NSLocalizedDescriptionKey: "Local Spark requires a valid SPARK_LOCAL_CONFIG_B64 and SPARK_LOCAL_CHAIN_URL", + ]) + } + config.sparkConfig = try parseSparkConfig(json: json) + // The pinned regtest operators require anchored refunds. + config.watchtowerFeeLadderEnabled = false + return chainURL + } + /// The SDK config Bitkit connects with. nonisolated static func sdkConfig(network: BreezSdkSpark.Network, apiKey: String?, isExiting: Bool) -> BreezSdkSpark.Config { var config = defaultConfig(network: network) diff --git a/Bitkit/Views/Settings/Advanced/SparkConnectionViews.swift b/Bitkit/Views/Settings/Advanced/SparkConnectionViews.swift index 726a1bd2e..e2b395ebb 100644 --- a/Bitkit/Views/Settings/Advanced/SparkConnectionViews.swift +++ b/Bitkit/Views/Settings/Advanced/SparkConnectionViews.swift @@ -172,6 +172,8 @@ struct SparkConnectionDetailView: View { detailRow(label: t("lightning__receiving_label"), value: t("lightning__spark_receiving_unlimited")) } amountRow(label: t("lightning__spending_label"), amount: spark.shownBalanceSats) + .accessibilityElement(children: .contain) + .accessibilityIdentifier("SparkBalance") } if !spark.deposits.isEmpty { From 562760b5aba45987eb40b67101763ee0aec7a79f Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 19 Nov 2026 10:27:28 +0100 Subject: [PATCH 02/25] ci: isolate and validate iOS Spark dispatches --- .github/workflows/e2e-tests.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 6958bf510..4ad9396e8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -49,7 +49,7 @@ env: GIT_LFS_SKIP_SMUDGE: "1" concurrency: - group: e2e-tests-${{ github.event.pull_request.number || inputs.pr || github.ref }} + group: e2e-tests-${{ github.event.pull_request.number || inputs.pr || github.ref }}${{ inputs.spark_only && '-spark' || '' }} cancel-in-progress: true jobs: @@ -59,6 +59,11 @@ jobs: outputs: code: ${{ (github.event_name == 'workflow_dispatch' && !inputs.pr) || steps.filter.outputs.code == 'true' }} steps: + - name: Check Spark dispatch inputs + if: inputs.spark_only && inputs.pr + run: | + echo "::error::spark_only runs against the dispatched branch. Leave the pr input empty." + exit 1 - uses: actions/checkout@v7 with: ref: ${{ inputs.merge_commit || (inputs.pr && format('refs/pull/{0}/merge', inputs.pr)) || '' }} @@ -447,7 +452,7 @@ jobs: working-directory: bitkit-e2e-tests run: | ./scripts/local-backend prepare - ./scripts/local-backend spark-down --remove-orphans -v + (cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v) ./scripts/local-backend spark-up ./scripts/local-backend spark-env >> "$GITHUB_ENV" @@ -469,7 +474,7 @@ jobs: - name: Stop Spark fixture if: always() && steps.spark.outcome != 'skipped' working-directory: bitkit-e2e-tests - run: ./scripts/local-backend spark-down --remove-orphans -v + run: cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v - uses: actions/upload-artifact@v7 if: always() From 83303ed957e63cff0ef231fbd03a35dd19aed58a Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 19 Nov 2026 11:44:57 +0100 Subject: [PATCH 03/25] test: split Spark sweep signature preimage assembly --- BitkitTests/SparkExitSweepTests.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/BitkitTests/SparkExitSweepTests.swift b/BitkitTests/SparkExitSweepTests.swift index 1664ec2cd..a74aa3bf1 100644 --- a/BitkitTests/SparkExitSweepTests.swift +++ b/BitkitTests/SparkExitSweepTests.swift @@ -931,9 +931,17 @@ final class SparkExitSweepTests: XCTestCase { offset += 34 XCTAssertEqual(signature.last, 0x01, "SIGHASH_ALL") - let preimage = le32(2) + dsha(outpoints.flatMap { $0 }) + dsha(Array(repeating: sequence, count: utxos.count).flatMap { $0 }) - + outpoints[i] + [0x19, 0x76, 0xA9, 0x14] + pubkeyHash + [0x88, 0xAC] + le64(utxo.value) + sequence - + dsha(outputs) + le32(0) + le32(1) + let scriptCode: [UInt8] = [0x19, 0x76, 0xA9, 0x14] + pubkeyHash + [0x88, 0xAC] + var preimage = le32(2) + preimage.append(contentsOf: dsha(outpoints.flatMap { $0 })) + preimage.append(contentsOf: dsha(Array(repeating: sequence, count: utxos.count).flatMap { $0 })) + preimage.append(contentsOf: outpoints[i]) + preimage.append(contentsOf: scriptCode) + preimage.append(contentsOf: le64(utxo.value)) + preimage.append(contentsOf: sequence) + preimage.append(contentsOf: dsha(outputs)) + preimage.append(contentsOf: le32(0)) + preimage.append(contentsOf: le32(1)) let digest = dsha(preimage) var parsed = secp256k1_ecdsa_signature() let der = Array(signature.dropLast()) From 475881f86a7741fe0c82d9999d4a87e8ae4effad Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 19 Nov 2026 12:54:27 +0100 Subject: [PATCH 04/25] ci: run Spark in the local E2E nightly --- .github/workflows/e2e-local-nightly.yml | 87 +++++++++++++++++++++++++ .github/workflows/e2e-tests.yml | 87 +------------------------ 2 files changed, 90 insertions(+), 84 deletions(-) create mode 100644 .github/workflows/e2e-local-nightly.yml diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml new file mode 100644 index 000000000..6204a9371 --- /dev/null +++ b/.github/workflows/e2e-local-nightly.yml @@ -0,0 +1,87 @@ +name: Local E2E Nightly (iOS) + +on: + schedule: + - cron: "35 5 * * *" + workflow_dispatch: + inputs: + e2e_branch: + description: "Ref in synonymdev/bitkit-e2e-tests" + type: string + default: main + +permissions: + contents: read + +env: + TERM: xterm-256color + FORCE_COLOR: 1 + GIT_LFS_SKIP_SMUDGE: "1" + +concurrency: + group: bitkit-local-e2e-nightly-ios + cancel-in-progress: false + +jobs: + e2e-spark: + runs-on: [self-hosted, macOS] + timeout-minutes: 120 + env: + COMPOSE_PROJECT_NAME: bitkit-spark-e2e + steps: + - uses: actions/checkout@v7 + with: + path: bitkit-ios + persist-credentials: false + + - uses: actions/checkout@v7 + with: + repository: synonymdev/bitkit-e2e-tests + ref: ${{ inputs.e2e_branch || 'main' }} + path: bitkit-e2e-tests + persist-credentials: false + + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: npm + cache-dependency-path: bitkit-e2e-tests/package-lock.json + + - name: Install Appium dependencies + working-directory: bitkit-e2e-tests + run: npm ci + + - name: Start pinned Spark fixture + id: spark + working-directory: bitkit-e2e-tests + run: | + ./scripts/local-backend prepare + (cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v) + ./scripts/local-backend spark-up + ./scripts/local-backend spark-env >> "$GITHUB_ENV" + + - name: Build iOS Spark app + working-directory: bitkit-e2e-tests + run: ./scripts/build-ios-sim.sh + + - name: Run @spark_1 + working-directory: bitkit-e2e-tests + run: ./scripts/run-spark-e2e.sh ios + + - name: Collect Spark logs + if: failure() + working-directory: bitkit-e2e-tests + run: | + mkdir -p artifacts + ./scripts/local-backend spark-logs --tail 200 > artifacts/spark-docker.log 2>&1 || true + + - name: Stop Spark fixture + if: always() && steps.spark.outcome != 'skipped' + working-directory: bitkit-e2e-tests + run: cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v + + - uses: actions/upload-artifact@v7 + if: always() + with: + name: spark-ios-${{ github.run_number }} + path: bitkit-e2e-tests/artifacts/ diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 4ad9396e8..6f7e32974 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -5,10 +5,6 @@ run-name: >- on: workflow_dispatch: inputs: - spark_only: - description: "Run only @spark_1 on pinned local Spark" - type: boolean - default: false e2e_branch: description: "Branch of synonymdev/bitkit-e2e-tests to use (main | default-feature-branch | custom branch name)" required: false @@ -49,7 +45,7 @@ env: GIT_LFS_SKIP_SMUDGE: "1" concurrency: - group: e2e-tests-${{ github.event.pull_request.number || inputs.pr || github.ref }}${{ inputs.spark_only && '-spark' || '' }} + group: e2e-tests-${{ github.event.pull_request.number || inputs.pr || github.ref }} cancel-in-progress: true jobs: @@ -59,11 +55,6 @@ jobs: outputs: code: ${{ (github.event_name == 'workflow_dispatch' && !inputs.pr) || steps.filter.outputs.code == 'true' }} steps: - - name: Check Spark dispatch inputs - if: inputs.spark_only && inputs.pr - run: | - echo "::error::spark_only runs against the dispatched branch. Leave the pr input empty." - exit 1 - uses: actions/checkout@v7 with: ref: ${{ inputs.merge_commit || (inputs.pr && format('refs/pull/{0}/merge', inputs.pr)) || '' }} @@ -100,7 +91,7 @@ jobs: pull-requests: read checks: write actions: write - if: "!inputs.spark_only && github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true'" + if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true' runs-on: macos-26 steps: @@ -410,80 +401,8 @@ jobs: (cd docker && docker compose --profile trezor down --remove-orphans -v) || true fi - e2e-spark: - if: inputs.spark_only && !inputs.pr - needs: e2e-branch - runs-on: [self-hosted, macOS] - timeout-minutes: 120 - env: - COMPOSE_PROJECT_NAME: bitkit-spark-e2e - steps: - - uses: actions/checkout@v7 - with: - path: bitkit-ios - persist-credentials: false - - - name: Resolve E2E tests ref - id: e2e-ref - uses: synonymdev/bitkit-e2e-tests/.github/actions/resolve-e2e-ref@main - with: - selected: ${{ needs.e2e-branch.outputs.branch }} - e2e_branch_input: ${{ inputs.e2e_branch }} - - - uses: actions/checkout@v7 - with: - repository: synonymdev/bitkit-e2e-tests - ref: ${{ steps.e2e-ref.outputs.ref }} - path: bitkit-e2e-tests - persist-credentials: false - - - uses: actions/setup-node@v7 - with: - node-version: 22 - cache: npm - cache-dependency-path: bitkit-e2e-tests/package-lock.json - - - name: Install Appium dependencies - working-directory: bitkit-e2e-tests - run: npm ci - - - name: Start pinned Spark fixture - id: spark - working-directory: bitkit-e2e-tests - run: | - ./scripts/local-backend prepare - (cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v) - ./scripts/local-backend spark-up - ./scripts/local-backend spark-env >> "$GITHUB_ENV" - - - name: Build iOS Spark app - working-directory: bitkit-e2e-tests - run: ./scripts/build-ios-sim.sh - - - name: Run @spark_1 - working-directory: bitkit-e2e-tests - run: ./scripts/run-spark-e2e.sh ios - - - name: Collect Spark logs - if: failure() - working-directory: bitkit-e2e-tests - run: | - mkdir -p artifacts - ./scripts/local-backend spark-logs --tail 200 > artifacts/spark-docker.log 2>&1 || true - - - name: Stop Spark fixture - if: always() && steps.spark.outcome != 'skipped' - working-directory: bitkit-e2e-tests - run: cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v - - - uses: actions/upload-artifact@v7 - if: always() - with: - name: spark-ios-${{ github.run_number }} - path: bitkit-e2e-tests/artifacts/ - e2e-status: - if: always() && !inputs.spark_only && github.event.pull_request.draft == false + if: always() && github.event.pull_request.draft == false name: e2e-status runs-on: ubuntu-24.04 needs: [detect-changes, e2e-tests-local] From d4289e093bf6865edf98816bf6da1dc0cb4e870c Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 19 Nov 2026 12:58:00 +0100 Subject: [PATCH 05/25] ci: retry Spark nightly tests and retain attempt artifacts --- .github/workflows/e2e-local-nightly.yml | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index 6204a9371..611675c93 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -64,9 +64,33 @@ jobs: working-directory: bitkit-e2e-tests run: ./scripts/build-ios-sim.sh - - name: Run @spark_1 + - name: Run @spark_1 (attempt 1) + continue-on-error: true + id: test1 working-directory: bitkit-e2e-tests run: ./scripts/run-spark-e2e.sh ios + env: + RECORD_VIDEO: true + ATTEMPT: 1 + + - name: Run @spark_1 (attempt 2) + continue-on-error: true + if: steps.test1.outcome != 'success' + id: test2 + working-directory: bitkit-e2e-tests + run: ./scripts/run-spark-e2e.sh ios + env: + RECORD_VIDEO: true + ATTEMPT: 2 + + - name: Run @spark_1 (attempt 3) + if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success' + id: test3 + working-directory: bitkit-e2e-tests + run: ./scripts/run-spark-e2e.sh ios + env: + RECORD_VIDEO: true + ATTEMPT: 3 - name: Collect Spark logs if: failure() @@ -80,8 +104,10 @@ jobs: working-directory: bitkit-e2e-tests run: cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v + # Preserve logs and recordings from failed attempts even when a retry passes. - uses: actions/upload-artifact@v7 if: always() with: name: spark-ios-${{ github.run_number }} path: bitkit-e2e-tests/artifacts/ + retention-days: 7 From 78236a1bd46135daa4943341985a135eaa88001d Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 19 Nov 2026 15:36:20 +0100 Subject: [PATCH 06/25] ci: prepare iOS Spark fixture images on hosted Linux --- .github/workflows/e2e-local-nightly.yml | 53 ++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index 611675c93..421b19d51 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -23,7 +23,43 @@ concurrency: cancel-in-progress: false jobs: + spark-images: + runs-on: ubuntu-24.04-arm + timeout-minutes: 80 + outputs: + e2e-sha: ${{ steps.e2e.outputs.sha }} + steps: + - uses: actions/checkout@v7 + with: + repository: synonymdev/bitkit-e2e-tests + ref: ${{ inputs.e2e_branch || 'main' }} + persist-credentials: false + + - name: Record shared E2E revision + id: e2e + run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + + - name: Cache pinned Spark fixture images + id: images + uses: actions/cache@v6 + with: + path: ${{ runner.temp }}/spark-images.tar + key: spark-fixture-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('BITKIT_DOCKER_REVISION') }} + + - name: Package pinned Spark fixture images + if: steps.images.outputs.cache-hit != 'true' + run: ./scripts/local-backend spark-pack "$RUNNER_TEMP/spark-images.tar" + + - uses: actions/upload-artifact@v7 + with: + name: spark-fixture-images + path: ${{ runner.temp }}/spark-images.tar + if-no-files-found: error + compression-level: 0 + retention-days: 3 + e2e-spark: + needs: spark-images runs-on: [self-hosted, macOS] timeout-minutes: 120 env: @@ -37,7 +73,7 @@ jobs: - uses: actions/checkout@v7 with: repository: synonymdev/bitkit-e2e-tests - ref: ${{ inputs.e2e_branch || 'main' }} + ref: ${{ needs.spark-images.outputs.e2e-sha }} path: bitkit-e2e-tests persist-credentials: false @@ -51,10 +87,21 @@ jobs: working-directory: bitkit-e2e-tests run: npm ci + - uses: actions/download-artifact@v8 + with: + name: spark-fixture-images + path: ${{ runner.temp }} + - name: Start pinned Spark fixture id: spark working-directory: bitkit-e2e-tests + env: + SPARK_IMAGE_ARCHIVE: ${{ runner.temp }}/spark-images.tar run: | + if [[ "$RUNNER_ARCH" != ARM64 ]]; then + echo "::error::The Spark fixture archive requires an ARM64 Mac runner." + exit 1 + fi ./scripts/local-backend prepare (cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v) ./scripts/local-backend spark-up @@ -104,6 +151,10 @@ jobs: working-directory: bitkit-e2e-tests run: cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v + - name: Remove the imported image archive + if: always() + run: rm -f "$RUNNER_TEMP/spark-images.tar" + # Preserve logs and recordings from failed attempts even when a retry passes. - uses: actions/upload-artifact@v7 if: always() From f88626909f3196dff2f9948d0aefa4295fc0addb Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 19 Nov 2026 17:32:56 +0100 Subject: [PATCH 07/25] ci: compress the iOS Spark image archive for transfer --- .github/workflows/e2e-local-nightly.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index 421b19d51..40e9cae88 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -50,10 +50,13 @@ jobs: if: steps.images.outputs.cache-hit != 'true' run: ./scripts/local-backend spark-pack "$RUNNER_TEMP/spark-images.tar" + - name: Compress the fixture archive for transfer + run: gzip -1 -c "$RUNNER_TEMP/spark-images.tar" > "$RUNNER_TEMP/spark-images.tar.gz" + - uses: actions/upload-artifact@v7 with: name: spark-fixture-images - path: ${{ runner.temp }}/spark-images.tar + path: ${{ runner.temp }}/spark-images.tar.gz if-no-files-found: error compression-level: 0 retention-days: 3 @@ -96,7 +99,7 @@ jobs: id: spark working-directory: bitkit-e2e-tests env: - SPARK_IMAGE_ARCHIVE: ${{ runner.temp }}/spark-images.tar + SPARK_IMAGE_ARCHIVE: ${{ runner.temp }}/spark-images.tar.gz run: | if [[ "$RUNNER_ARCH" != ARM64 ]]; then echo "::error::The Spark fixture archive requires an ARM64 Mac runner." @@ -153,7 +156,7 @@ jobs: - name: Remove the imported image archive if: always() - run: rm -f "$RUNNER_TEMP/spark-images.tar" + run: rm -f "$RUNNER_TEMP/spark-images.tar.gz" # Preserve logs and recordings from failed attempts even when a retry passes. - uses: actions/upload-artifact@v7 From b343d896d50d2dec63fc475b4dcbc9926d2deedc Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 19 Nov 2026 19:24:05 +0100 Subject: [PATCH 08/25] ci: build the Spark simulator app on hosted macOS --- .github/workflows/e2e-local-nightly.yml | 89 +++++++++++++++++++++---- 1 file changed, 76 insertions(+), 13 deletions(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index 40e9cae88..55be7f88f 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -28,6 +28,8 @@ jobs: timeout-minutes: 80 outputs: e2e-sha: ${{ steps.e2e.outputs.sha }} + spark-config: ${{ steps.settings.outputs.SPARK_LOCAL_CONFIG_B64 }} + spark-chain-url: ${{ steps.settings.outputs.SPARK_LOCAL_CHAIN_URL }} steps: - uses: actions/checkout@v7 with: @@ -50,6 +52,12 @@ jobs: if: steps.images.outputs.cache-hit != 'true' run: ./scripts/local-backend spark-pack "$RUNNER_TEMP/spark-images.tar" + - name: Generate pinned Spark app settings + id: settings + run: | + docker image load --quiet --input "$RUNNER_TEMP/spark-images.tar" + ./scripts/local-backend spark-init-env >> "$GITHUB_OUTPUT" + - name: Compress the fixture archive for transfer run: gzip -1 -c "$RUNNER_TEMP/spark-images.tar" > "$RUNNER_TEMP/spark-images.tar.gz" @@ -61,16 +69,13 @@ jobs: compression-level: 0 retention-days: 3 - e2e-spark: + build-spark-ios: needs: spark-images - runs-on: [self-hosted, macOS] - timeout-minutes: 120 - env: - COMPOSE_PROJECT_NAME: bitkit-spark-e2e + runs-on: macos-26 + timeout-minutes: 45 steps: - uses: actions/checkout@v7 with: - path: bitkit-ios persist-credentials: false - uses: actions/checkout@v7 @@ -80,6 +85,51 @@ jobs: path: bitkit-e2e-tests persist-credentials: false + - name: Set up Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: "26.6" + + - name: Install xcbeautify + run: brew install xcbeautify + + - name: Swift packages + uses: ./.github/actions/swift-packages + + - name: Build iOS Spark app + working-directory: bitkit-e2e-tests + env: + IOS_ROOT: ${{ github.workspace }} + SPARK_LOCAL_CONFIG_B64: ${{ needs.spark-images.outputs.spark-config }} + SPARK_LOCAL_CHAIN_URL: ${{ needs.spark-images.outputs.spark-chain-url }} + run: | + test -n "$SPARK_LOCAL_CONFIG_B64" + test -n "$SPARK_LOCAL_CHAIN_URL" + ./scripts/build-ios-sim.sh + tar -C aut -czf "$RUNNER_TEMP/spark-ios-app.tar.gz" Bitkit.app + + - uses: actions/upload-artifact@v7 + with: + name: spark-ios-app + path: ${{ runner.temp }}/spark-ios-app.tar.gz + if-no-files-found: error + compression-level: 0 + retention-days: 3 + + e2e-spark: + needs: [spark-images, build-spark-ios] + runs-on: [self-hosted, macOS] + timeout-minutes: 120 + env: + COMPOSE_PROJECT_NAME: bitkit-spark-e2e + steps: + - uses: actions/checkout@v7 + with: + repository: synonymdev/bitkit-e2e-tests + ref: ${{ needs.spark-images.outputs.e2e-sha }} + path: bitkit-e2e-tests + persist-credentials: false + - uses: actions/setup-node@v7 with: node-version: 22 @@ -95,11 +145,24 @@ jobs: name: spark-fixture-images path: ${{ runner.temp }} + - uses: actions/download-artifact@v8 + with: + name: spark-ios-app + path: ${{ runner.temp }} + + - name: Unpack the hosted simulator build + working-directory: bitkit-e2e-tests + run: | + mkdir -p aut + tar -C aut -xzf "$RUNNER_TEMP/spark-ios-app.tar.gz" + - name: Start pinned Spark fixture id: spark working-directory: bitkit-e2e-tests env: SPARK_IMAGE_ARCHIVE: ${{ runner.temp }}/spark-images.tar.gz + SPARK_LOCAL_CONFIG_B64: ${{ needs.spark-images.outputs.spark-config }} + SPARK_LOCAL_CHAIN_URL: ${{ needs.spark-images.outputs.spark-chain-url }} run: | if [[ "$RUNNER_ARCH" != ARM64 ]]; then echo "::error::The Spark fixture archive requires an ARM64 Mac runner." @@ -108,11 +171,11 @@ jobs: ./scripts/local-backend prepare (cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v) ./scripts/local-backend spark-up - ./scripts/local-backend spark-env >> "$GITHUB_ENV" - - - name: Build iOS Spark app - working-directory: bitkit-e2e-tests - run: ./scripts/build-ios-sim.sh + expected="$(printf 'SPARK_LOCAL_CONFIG_B64=%s\nSPARK_LOCAL_CHAIN_URL=%s' "$SPARK_LOCAL_CONFIG_B64" "$SPARK_LOCAL_CHAIN_URL")" + if [[ "$(./scripts/local-backend spark-env)" != "$expected" ]]; then + echo "::error::The running Spark fixture differs from the simulator build settings." + exit 1 + fi - name: Run @spark_1 (attempt 1) continue-on-error: true @@ -154,9 +217,9 @@ jobs: working-directory: bitkit-e2e-tests run: cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v - - name: Remove the imported image archive + - name: Remove the imported archives if: always() - run: rm -f "$RUNNER_TEMP/spark-images.tar.gz" + run: rm -f "$RUNNER_TEMP/spark-images.tar.gz" "$RUNNER_TEMP/spark-ios-app.tar.gz" # Preserve logs and recordings from failed attempts even when a retry passes. - uses: actions/upload-artifact@v7 From 5e495852facabbd028119a8f9f2de66d821cb5fc Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 19 Nov 2026 19:36:20 +0100 Subject: [PATCH 09/25] ci: build the Spark simulator app for ARM64 --- .github/workflows/e2e-local-nightly.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index 55be7f88f..d0ae06331 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -100,6 +100,7 @@ jobs: working-directory: bitkit-e2e-tests env: IOS_ROOT: ${{ github.workspace }} + IOS_SIMULATOR_ARCH: arm64 SPARK_LOCAL_CONFIG_B64: ${{ needs.spark-images.outputs.spark-config }} SPARK_LOCAL_CHAIN_URL: ${{ needs.spark-images.outputs.spark-chain-url }} run: | From 095fc737cb2f5211d65ca6447f2bbfc8ff48fdc5 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 19 Nov 2026 19:55:57 +0100 Subject: [PATCH 10/25] ci: reuse verified Spark images on the shared Mac --- .github/workflows/e2e-local-nightly.yml | 36 ++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index d0ae06331..3f5114209 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -30,6 +30,7 @@ jobs: e2e-sha: ${{ steps.e2e.outputs.sha }} spark-config: ${{ steps.settings.outputs.SPARK_LOCAL_CONFIG_B64 }} spark-chain-url: ${{ steps.settings.outputs.SPARK_LOCAL_CHAIN_URL }} + image-fingerprint: ${{ steps.settings.outputs.image-fingerprint }} steps: - uses: actions/checkout@v7 with: @@ -57,6 +58,8 @@ jobs: run: | docker image load --quiet --input "$RUNNER_TEMP/spark-images.tar" ./scripts/local-backend spark-init-env >> "$GITHUB_OUTPUT" + fingerprint="$(./scripts/local-backend spark-image-fingerprint)" + echo "image-fingerprint=$fingerprint" >> "$GITHUB_OUTPUT" - name: Compress the fixture archive for transfer run: gzip -1 -c "$RUNNER_TEMP/spark-images.tar" > "$RUNNER_TEMP/spark-images.tar.gz" @@ -141,11 +144,36 @@ jobs: working-directory: bitkit-e2e-tests run: npm ci + - name: Check the local Spark images + id: local-images + working-directory: bitkit-e2e-tests + env: + SPARK_IMAGE_FINGERPRINT: ${{ needs.spark-images.outputs.image-fingerprint }} + run: | + if [[ "$RUNNER_ARCH" != ARM64 ]]; then + echo "::error::The Spark fixture archive requires an ARM64 Mac runner." + exit 1 + fi + test -n "$SPARK_IMAGE_FINGERPRINT" + ./scripts/local-backend prepare + if actual="$(./scripts/local-backend spark-image-fingerprint 2>/dev/null)" && + [[ "$actual" == "$SPARK_IMAGE_FINGERPRINT" ]]; then + echo 'Reusing the exact pinned Spark images on this runner.' + echo 'match=true' >> "$GITHUB_OUTPUT" + fi + - uses: actions/download-artifact@v8 + if: steps.local-images.outputs.match != 'true' with: name: spark-fixture-images path: ${{ runner.temp }} + - name: Load the pinned Spark images + if: steps.local-images.outputs.match != 'true' + run: | + docker image load --input "$RUNNER_TEMP/spark-images.tar.gz" + rm -f "$RUNNER_TEMP/spark-images.tar.gz" + - uses: actions/download-artifact@v8 with: name: spark-ios-app @@ -156,20 +184,16 @@ jobs: run: | mkdir -p aut tar -C aut -xzf "$RUNNER_TEMP/spark-ios-app.tar.gz" + rm -f "$RUNNER_TEMP/spark-ios-app.tar.gz" - name: Start pinned Spark fixture id: spark working-directory: bitkit-e2e-tests env: - SPARK_IMAGE_ARCHIVE: ${{ runner.temp }}/spark-images.tar.gz + SPARK_IMAGE_FINGERPRINT: ${{ needs.spark-images.outputs.image-fingerprint }} SPARK_LOCAL_CONFIG_B64: ${{ needs.spark-images.outputs.spark-config }} SPARK_LOCAL_CHAIN_URL: ${{ needs.spark-images.outputs.spark-chain-url }} run: | - if [[ "$RUNNER_ARCH" != ARM64 ]]; then - echo "::error::The Spark fixture archive requires an ARM64 Mac runner." - exit 1 - fi - ./scripts/local-backend prepare (cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v) ./scripts/local-backend spark-up expected="$(printf 'SPARK_LOCAL_CONFIG_B64=%s\nSPARK_LOCAL_CHAIN_URL=%s' "$SPARK_LOCAL_CONFIG_B64" "$SPARK_LOCAL_CHAIN_URL")" From 7367ef70ef39a2dece632db5e4b680815c5cbd68 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 09:06:35 +0100 Subject: [PATCH 11/25] ci: summarize local E2E nightly in Slack --- .github/workflows/e2e-local-nightly.yml | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index 3f5114209..e6602b594 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -9,6 +9,10 @@ on: description: "Ref in synonymdev/bitkit-e2e-tests" type: string default: main + post_to_slack: + description: "Post Local E2E Nightly summary to Slack (#bitkit-staging-nightly)" + type: boolean + default: false permissions: contents: read @@ -124,6 +128,13 @@ jobs: needs: [spark-images, build-spark-ios] runs-on: [self-hosted, macOS] timeout-minutes: 120 + outputs: + spark-case: >- + ${{ (steps.test1.outputs.spark-case == 'passed' || steps.test2.outputs.spark-case == 'passed' || + steps.test3.outputs.spark-case == 'passed') && 'success' || + (steps.test1.outputs.spark-case == 'started' || steps.test2.outputs.spark-case == 'started' || + steps.test3.outputs.spark-case == 'started') && 'failure' || '' }} + spark-fixture: ${{ steps.spark.outcome }} env: COMPOSE_PROJECT_NAME: bitkit-spark-e2e steps: @@ -253,3 +264,38 @@ jobs: name: spark-ios-${{ github.run_number }} path: bitkit-e2e-tests/artifacts/ retention-days: 7 + + slack-report: + if: >- + always() && + (github.event_name == 'schedule' || + (github.event_name == 'workflow_dispatch' && inputs.post_to_slack == true)) + needs: [spark-images, build-spark-ios, e2e-spark] + runs-on: ubuntu-24.04 + timeout-minutes: 5 + permissions: + contents: read + steps: + - name: Checkout shared Slack reporter + uses: actions/checkout@v7 + with: + repository: synonymdev/bitkit-e2e-tests + ref: main + persist-credentials: false + + - name: Post Slack summary + run: python3 scripts/slack_summary.py e2e-local-nightly + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_STAGING }} + PLATFORM: ios + LOCAL_NIGHTLY_RESULT: >- + ${{ contains(needs.*.result, 'failure') && 'failure' || + contains(needs.*.result, 'cancelled') && 'cancelled' || needs.e2e-spark.result }} + SPARK_IMAGES_RESULT: ${{ needs.spark-images.result }} + BUILD_RESULT: ${{ needs.build-spark-ios.result }} + E2E_TESTS_REF: ${{ needs.spark-images.outputs.e2e-sha || inputs.e2e_branch || 'main' }} + SPARK_FIXTURE_RESULT: ${{ needs.e2e-spark.outputs.spark-fixture }} + E2E_TESTS_RESULT: ${{ needs.e2e-spark.result }} + SPARK_CASE_RESULT: ${{ needs.e2e-spark.outputs.spark-case }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + RUN_ATTEMPT: ${{ github.run_attempt }} From c59720182a1801e09e5d3ef8f614b59a0324df77 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 09:10:12 +0100 Subject: [PATCH 12/25] ci: preserve explicit Spark case outcomes --- .github/workflows/e2e-local-nightly.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index e6602b594..e49881b05 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -130,10 +130,10 @@ jobs: timeout-minutes: 120 outputs: spark-case: >- - ${{ (steps.test1.outputs.spark-case == 'passed' || steps.test2.outputs.spark-case == 'passed' || - steps.test3.outputs.spark-case == 'passed') && 'success' || - (steps.test1.outputs.spark-case == 'started' || steps.test2.outputs.spark-case == 'started' || - steps.test3.outputs.spark-case == 'started') && 'failure' || '' }} + ${{ contains(steps.*.outputs.spark-case, 'passed') && 'passed' || + contains(steps.*.outputs.spark-case, 'failed') && 'failed' || + contains(steps.*.outputs.spark-case, 'started') && 'started' || + contains(steps.*.outputs.spark-case, 'setup') && 'setup' || '' }} spark-fixture: ${{ steps.spark.outcome }} env: COMPOSE_PROJECT_NAME: bitkit-spark-e2e From a80b1178324e8452c171c46840849cb73ccb4930 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 09:13:30 +0100 Subject: [PATCH 13/25] ci: report Spark app setup failures across retries --- .github/workflows/e2e-local-nightly.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index e49881b05..4f3ecf9e9 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -132,8 +132,10 @@ jobs: spark-case: >- ${{ contains(steps.*.outputs.spark-case, 'passed') && 'passed' || contains(steps.*.outputs.spark-case, 'failed') && 'failed' || - contains(steps.*.outputs.spark-case, 'started') && 'started' || - contains(steps.*.outputs.spark-case, 'setup') && 'setup' || '' }} + contains(steps.*.outputs.spark-case, 'started') && 'started' || '' }} + spark-app-setup: >- + ${{ contains(steps.*.outputs.spark-case, 'setup-failed') && 'failure' || + contains(steps.*.outputs.spark-case, 'setup') && 'interrupted' || '' }} spark-fixture: ${{ steps.spark.outcome }} env: COMPOSE_PROJECT_NAME: bitkit-spark-e2e @@ -295,6 +297,7 @@ jobs: BUILD_RESULT: ${{ needs.build-spark-ios.result }} E2E_TESTS_REF: ${{ needs.spark-images.outputs.e2e-sha || inputs.e2e_branch || 'main' }} SPARK_FIXTURE_RESULT: ${{ needs.e2e-spark.outputs.spark-fixture }} + SPARK_APP_SETUP_RESULT: ${{ needs.e2e-spark.outputs.spark-app-setup }} E2E_TESTS_RESULT: ${{ needs.e2e-spark.result }} SPARK_CASE_RESULT: ${{ needs.e2e-spark.outputs.spark-case }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} From 8508ed6b9210ca2189f0eaab3bea721631879970 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 10:49:05 +0100 Subject: [PATCH 14/25] ci: temporarily dispatch the Spark nightly from the draft branch --- .github/workflows/e2e-tests.yml | 565 ++++++++++++-------------------- 1 file changed, 206 insertions(+), 359 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 6f7e32974..443d7bce8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,43 +1,21 @@ -name: e2e-tests -run-name: >- - ${{ inputs.retarget_run && format('Retarget E2E for PR #{0}', inputs.pr) || github.event.pull_request.title || github.event.head_commit.message || github.workflow }} +name: Local E2E Nightly (iOS) on: + schedule: + - cron: "35 5 * * *" workflow_dispatch: inputs: e2e_branch: - description: "Branch of synonymdev/bitkit-e2e-tests to use (main | default-feature-branch | custom branch name)" - required: false - default: "default-feature-branch" - pr: - description: "PR number to test as merged into master" - required: false - default: "" - merge_commit: - description: "Pinned PR merge commit for retarget validation" - default: "" - head_sha: - description: "PR head verified by the retarget dispatcher" - default: "" - app_branch: - description: "PR branch for selecting matching E2E coverage" - default: "" - check_run_id: - description: "PR check owned by this retarget validation" - default: "" - retarget_run: - description: "Retarget status owner (set by e2e-retarget.yml)" - default: "" - workflow_ref: - description: "Workflow source recorded for this validation generation" - default: master - helper_ref: - description: "Recovery helper branch or tag" - default: master - # PRs stacked on another branch run no E2E until they target master; e2e-retarget.yml starts it on retarget - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - branches: [master] + description: "Ref in synonymdev/bitkit-e2e-tests" + type: string + default: main + post_to_slack: + description: "Post Local E2E Nightly summary to Slack (#bitkit-staging-nightly)" + type: boolean + default: false + +permissions: + contents: read env: TERM: xterm-256color @@ -45,413 +23,282 @@ env: GIT_LFS_SKIP_SMUDGE: "1" concurrency: - group: e2e-tests-${{ github.event.pull_request.number || inputs.pr || github.ref }} - cancel-in-progress: true + group: bitkit-local-e2e-nightly-ios + cancel-in-progress: false jobs: - detect-changes: - if: github.event.pull_request.draft == false - runs-on: ubuntu-24.04 + spark-images: + runs-on: ubuntu-24.04-arm + timeout-minutes: 80 outputs: - code: ${{ (github.event_name == 'workflow_dispatch' && !inputs.pr) || steps.filter.outputs.code == 'true' }} + e2e-sha: ${{ steps.e2e.outputs.sha }} + spark-config: ${{ steps.settings.outputs.SPARK_LOCAL_CONFIG_B64 }} + spark-chain-url: ${{ steps.settings.outputs.SPARK_LOCAL_CHAIN_URL }} + image-fingerprint: ${{ steps.settings.outputs.image-fingerprint }} steps: - uses: actions/checkout@v7 with: - ref: ${{ inputs.merge_commit || (inputs.pr && format('refs/pull/{0}/merge', inputs.pr)) || '' }} - fetch-depth: 2 - - name: Resolve tested PR merge commits - if: inputs.pr != '' - id: merge-base + repository: synonymdev/bitkit-e2e-tests + ref: ${{ inputs.e2e_branch || 'main' }} + persist-credentials: false + + - name: Record shared E2E revision + id: e2e + run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + + - name: Cache pinned Spark fixture images + id: images + uses: actions/cache@v6 + with: + path: ${{ runner.temp }}/spark-images.tar + key: spark-fixture-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('BITKIT_DOCKER_REVISION') }} + + - name: Package pinned Spark fixture images + if: steps.images.outputs.cache-hit != 'true' + run: ./scripts/local-backend spark-pack "$RUNNER_TEMP/spark-images.tar" + + - name: Generate pinned Spark app settings + id: settings run: | - echo "base=$(git rev-parse HEAD^1)" >> "$GITHUB_OUTPUT" - echo "head=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - - uses: dorny/paths-filter@v4 - # Retarget filters the exact tested merge against its first parent. - if: github.event_name == 'pull_request' || inputs.pr - id: filter + docker image load --quiet --input "$RUNNER_TEMP/spark-images.tar" + ./scripts/local-backend spark-init-env >> "$GITHUB_OUTPUT" + fingerprint="$(./scripts/local-backend spark-image-fingerprint)" + echo "image-fingerprint=$fingerprint" >> "$GITHUB_OUTPUT" + + - name: Compress the fixture archive for transfer + run: gzip -1 -c "$RUNNER_TEMP/spark-images.tar" > "$RUNNER_TEMP/spark-images.tar.gz" + + - uses: actions/upload-artifact@v7 with: - base: ${{ steps.merge-base.outputs.base || 'master' }} - ref: ${{ steps.merge-base.outputs.head || '' }} - filters: | - code: - - 'Bitkit/**' - - 'BitkitNotification/**' - - 'Bitkit.xcodeproj/**' - - 'Package.swift' - - '.github/workflows/e2e-tests.yml' - - '.github/scripts/**' - - build-local: - needs: detect-changes - # PR code must not publish dependency caches into the dispatch ref's scope. - cache-mode: read - permissions: - contents: read - packages: read - pull-requests: read - checks: write - actions: write - if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true' + name: spark-fixture-images + path: ${{ runner.temp }}/spark-images.tar.gz + if-no-files-found: error + compression-level: 0 + retention-days: 3 + + build-spark-ios: + needs: spark-images runs-on: macos-26 - + timeout-minutes: 45 steps: - - name: Checkout - uses: actions/checkout@v7 + - uses: actions/checkout@v7 with: - ref: ${{ inputs.merge_commit || (inputs.pr && format('refs/pull/{0}/merge', inputs.pr)) || '' }} + persist-credentials: false - - name: Checkout retarget reporter - if: inputs.retarget_run != '' - uses: actions/checkout@v7 - with: - ref: ${{ github.workflow_sha }} - path: retarget-ci - sparse-checkout: .github/scripts - - name: Report retarget tests running - if: inputs.retarget_run != '' - uses: actions/github-script@v9 - env: - RETARGET_CHECK_RUN_ID: ${{ inputs.check_run_id }} - RETARGET_RUN: ${{ inputs.retarget_run }} - RETARGET_HEAD_SHA: ${{ inputs.head_sha }} - RETARGET_MERGE_COMMIT: ${{ inputs.merge_commit }} - RETARGET_PR: ${{ inputs.pr }} - RETARGET_HELPER_REF: ${{ inputs.helper_ref }} + - uses: actions/checkout@v7 with: - script: | - const {reportRetargetResult} = require('./retarget-ci/.github/scripts/retarget-tests.cjs'); - await reportRetargetResult({github, context, core, name: 'e2e-status', phase: 'start'}); + repository: synonymdev/bitkit-e2e-tests + ref: ${{ needs.spark-images.outputs.e2e-sha }} + path: bitkit-e2e-tests + persist-credentials: false - name: Set up Xcode uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: "26.6" - - name: System Information - run: | - echo "=== System Information ===" - echo "macOS Version:" - sw_vers - echo "" - echo "Xcode Version:" - xcodebuild -version - - - name: Verify current PR merge checkout - if: github.event_name == 'pull_request' || inputs.pr - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr }} - run: | - [[ "$PR_NUMBER" =~ ^[0-9]+$ ]] || exit 1 - tested=$(git rev-parse HEAD) - head=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER" --jq 'select(.base.ref == "master") | .head.sha') - base=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/master" --jq '.object.sha') - expected="$base $head" - actual=$(gh api "repos/$GITHUB_REPOSITORY/commits/$tested" --jq '[.parents[].sha] | join(" ")') - if [[ ! "$expected" =~ ^[0-9a-f]{40}\ [0-9a-f]{40}$ || "$actual" != "$expected" ]]; then - echo "::error::Checked-out merge does not match the PR's current base and head" - exit 1 - fi - - name: Install xcbeautify - run: | - brew install xcbeautify + run: brew install xcbeautify - name: Swift packages uses: ./.github/actions/swift-packages - - name: Pre-start simulator - run: | - echo "⏱️ Starting simulator at $(date)" - xcrun simctl boot "iPhone 17" || true - echo "✅ Simulator started at $(date)" - - - name: Build iOS app (local) + - name: Build iOS Spark app + working-directory: bitkit-e2e-tests env: - GITHUB_ACTOR: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CHATWOOT_API: ${{ secrets.CHATWOOT_API }} - SIMULATOR_NAME: "iPhone 17" - OS_VERSION: "26.5" - run: | - echo "=== Building iOS app (local) ===" - echo "Using simulator: $SIMULATOR_NAME (iOS $OS_VERSION)" - - if xcodebuild -showsdks | grep -q "iOS Simulator"; then - echo "✅ iOS Simulator platform already installed" - else - echo "⚙️ iOS Simulator platform not found — downloading..." - xcodebuild -downloadPlatform iOS - fi - - xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \ - -scheme Bitkit \ - -configuration Debug \ - -destination "platform=iOS Simulator,name=$SIMULATOR_NAME,OS=$OS_VERSION" \ - -derivedDataPath DerivedData \ - -clonedSourcePackagesDirPath "$SOURCE_PACKAGES" \ - -disablePackageRepositoryCache \ - -disableAutomaticPackageResolution \ - -skipPackageUpdates \ - SWIFT_ACTIVE_COMPILATION_CONDITIONS='DEBUG E2E_BUILD' \ - TREZOR_BRIDGE=true \ - TREZOR_BRIDGE_URL=http://127.0.0.1:21325 \ - -allowProvisioningUpdates \ - build - - - name: Prepare app for E2E tests (local) + IOS_ROOT: ${{ github.workspace }} + IOS_SIMULATOR_ARCH: arm64 + SPARK_LOCAL_CONFIG_B64: ${{ needs.spark-images.outputs.spark-config }} + SPARK_LOCAL_CHAIN_URL: ${{ needs.spark-images.outputs.spark-chain-url }} run: | - # Copy the .app bundle to the expected location and name - mkdir -p e2e-app - cp -r DerivedData/Build/Products/Debug-iphonesimulator/Bitkit.app e2e-app/bitkit.app + test -n "$SPARK_LOCAL_CONFIG_B64" + test -n "$SPARK_LOCAL_CHAIN_URL" + ./scripts/build-ios-sim.sh + tar -C aut -czf "$RUNNER_TEMP/spark-ios-app.tar.gz" Bitkit.app - - name: Upload iOS app (local) - uses: actions/upload-artifact@v7 + - uses: actions/upload-artifact@v7 with: - name: bitkit-e2e-ios_${{ github.run_number }} - path: e2e-app/ - - e2e-branch: - needs: detect-changes - if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true' - uses: synonymdev/bitkit-e2e-tests/.github/workflows/determine-e2e-branch.yml@main - with: - app_branch: ${{ inputs.app_branch || github.head_ref || github.ref_name }} - e2e_branch_input: ${{ github.event.inputs.e2e_branch || 'default-feature-branch' }} - - e2e-tests-local: - cache-mode: read - permissions: - contents: read - packages: read - pull-requests: read - checks: write - actions: write - if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true' + name: spark-ios-app + path: ${{ runner.temp }}/spark-ios-app.tar.gz + if-no-files-found: error + compression-level: 0 + retention-days: 3 + + e2e-spark: + needs: [spark-images, build-spark-ios] runs-on: [self-hosted, macOS] - needs: [detect-changes, build-local, e2e-branch] + timeout-minutes: 120 + outputs: + spark-case: >- + ${{ contains(steps.*.outputs.spark-case, 'passed') && 'passed' || + contains(steps.*.outputs.spark-case, 'failed') && 'failed' || + contains(steps.*.outputs.spark-case, 'started') && 'started' || '' }} + spark-app-setup: >- + ${{ contains(steps.*.outputs.spark-case, 'setup-failed') && 'failure' || + contains(steps.*.outputs.spark-case, 'setup') && 'interrupted' || '' }} + spark-fixture: ${{ steps.spark.outcome }} env: - # Reuse the legacy project so reset also clears containers left after a ref switch. - COMPOSE_PROJECT_NAME: docker - # Match the legacy fixture for the iOS manual channel funding Max case. - BITCOIN_FALLBACK_FEE: "0.00001" - - strategy: - fail-fast: false - matrix: - shard: - # - { name: onboarding_backup_numberpad, grep: "@onboarding|@backup|@numberpad" } - # - { name: onchain_boost_receive_widgets, grep: "@onchain|@boost|@receive|@widgets" } - # - { name: settings, grep: "@settings" } - # - { name: security, grep: "@security" } - - { name: e2e, grep: '@ios_gate' } - - name: e2e-tests-local - ${{ matrix.shard.name }} - + COMPOSE_PROJECT_NAME: bitkit-spark-e2e steps: - - name: Checkout retarget reporter - if: inputs.retarget_run != '' - uses: actions/checkout@v7 - with: - ref: ${{ github.workflow_sha }} - path: retarget-ci - sparse-checkout: .github/scripts - - name: Report retarget tests running - if: inputs.retarget_run != '' - uses: actions/github-script@v9 - env: - RETARGET_CHECK_RUN_ID: ${{ inputs.check_run_id }} - RETARGET_RUN: ${{ inputs.retarget_run }} - RETARGET_HEAD_SHA: ${{ inputs.head_sha }} - RETARGET_MERGE_COMMIT: ${{ inputs.merge_commit }} - RETARGET_PR: ${{ inputs.pr }} - RETARGET_HELPER_REF: ${{ inputs.helper_ref }} - with: - script: | - const {reportRetargetResult} = require('./retarget-ci/.github/scripts/retarget-tests.cjs'); - await reportRetargetResult({github, context, core, name: 'e2e-status', phase: 'start'}); - - - name: Resolve E2E tests ref - id: e2e-ref - uses: synonymdev/bitkit-e2e-tests/.github/actions/resolve-e2e-ref@main - with: - selected: ${{ needs.e2e-branch.outputs.branch }} - e2e_branch_input: ${{ github.event.inputs.e2e_branch || 'default-feature-branch' }} - - - name: Clone E2E tests - uses: actions/checkout@v7 + - uses: actions/checkout@v7 with: repository: synonymdev/bitkit-e2e-tests + ref: ${{ needs.spark-images.outputs.e2e-sha }} path: bitkit-e2e-tests - ref: ${{ steps.e2e-ref.outputs.ref }} - - - name: Download iOS app - uses: actions/download-artifact@v8 - with: - name: bitkit-e2e-ios_${{ github.run_number }} - path: bitkit-e2e-tests/aut - - - name: List iOS app directory contents - run: ls -l bitkit-e2e-tests/aut + persist-credentials: false - - name: Setup Node.js - uses: actions/setup-node@v7 + - uses: actions/setup-node@v7 with: node-version: 22 + cache: npm + cache-dependency-path: bitkit-e2e-tests/package-lock.json - - name: Cache npm cache - uses: actions/cache@v6 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('bitkit-e2e-tests/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - name: Install dependencies + - name: Install Appium dependencies working-directory: bitkit-e2e-tests run: npm ci - - name: Docker info - run: | - docker --version - docker info - docker ps - docker compose version - - - name: Run regtest setup + - name: Check the local Spark images + id: local-images working-directory: bitkit-e2e-tests + env: + SPARK_IMAGE_FINGERPRINT: ${{ needs.spark-images.outputs.image-fingerprint }} run: | - if [ -x ./scripts/local-backend ]; then - ./scripts/local-backend prepare - ./scripts/local-backend down --remove-orphans -v -t 300 - ./scripts/local-backend up - ./scripts/local-backend github-env >> "$GITHUB_ENV" - else - # Older E2E refs still carry the bundled stack. - cd docker - docker compose --verbose --profile trezor down --remove-orphans -v -t 300 || true - mkdir -p lnd && chmod 777 lnd - docker compose --verbose up --force-recreate -d + if [[ "$RUNNER_ARCH" != ARM64 ]]; then + echo "::error::The Spark fixture archive requires an ARM64 Mac runner." + exit 1 fi + test -n "$SPARK_IMAGE_FINGERPRINT" + ./scripts/local-backend prepare + if actual="$(./scripts/local-backend spark-image-fingerprint 2>/dev/null)" && + [[ "$actual" == "$SPARK_IMAGE_FINGERPRINT" ]]; then + echo 'Reusing the exact pinned Spark images on this runner.' + echo 'match=true' >> "$GITHUB_OUTPUT" + fi + + - uses: actions/download-artifact@v8 + if: steps.local-images.outputs.match != 'true' + with: + name: spark-fixture-images + path: ${{ runner.temp }} - - name: Wait for electrum server + - name: Load the pinned Spark images + if: steps.local-images.outputs.match != 'true' run: | - for _ in $(seq 1 60); do - python3 -c 'import socket; s = socket.create_connection(("127.0.0.1", 60001), 10); s.sendall(b"{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"blockchain.headers.subscribe\",\"params\":[]}\n"); assert b"height" in s.recv(4096)' && exit 0 - sleep 5 - done - exit 1 + docker image load --input "$RUNNER_TEMP/spark-images.tar.gz" + rm -f "$RUNNER_TEMP/spark-images.tar.gz" - - name: Clear previous E2E artifacts + - uses: actions/download-artifact@v8 + with: + name: spark-ios-app + path: ${{ runner.temp }} + + - name: Unpack the hosted simulator build working-directory: bitkit-e2e-tests run: | - rm -rf artifacts/ - rm -rf /tmp/lock/ + mkdir -p aut + tar -C aut -xzf "$RUNNER_TEMP/spark-ios-app.tar.gz" + rm -f "$RUNNER_TEMP/spark-ios-app.tar.gz" - - name: Clear iOS Simulator environment + - name: Start pinned Spark fixture + id: spark + working-directory: bitkit-e2e-tests + env: + SPARK_IMAGE_FINGERPRINT: ${{ needs.spark-images.outputs.image-fingerprint }} + SPARK_LOCAL_CONFIG_B64: ${{ needs.spark-images.outputs.spark-config }} + SPARK_LOCAL_CHAIN_URL: ${{ needs.spark-images.outputs.spark-chain-url }} run: | - xcrun simctl shutdown all || true - xcrun simctl erase "iPhone 17" || true - defaults write com.apple.iphonesimulator DisableAllNotifications -bool true + (cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v) + ./scripts/local-backend spark-up + expected="$(printf 'SPARK_LOCAL_CONFIG_B64=%s\nSPARK_LOCAL_CHAIN_URL=%s' "$SPARK_LOCAL_CONFIG_B64" "$SPARK_LOCAL_CHAIN_URL")" + if [[ "$(./scripts/local-backend spark-env)" != "$expected" ]]; then + echo "::error::The running Spark fixture differs from the simulator build settings." + exit 1 + fi - - name: Run E2E Tests 1 (${{ matrix.shard.name }}) + - name: Run @spark_1 (attempt 1) continue-on-error: true id: test1 working-directory: bitkit-e2e-tests - run: ./ci_run_ios.sh --mochaOpts.grep '${{ matrix.shard.grep }}' + run: ./scripts/run-spark-e2e.sh ios env: RECORD_VIDEO: true ATTEMPT: 1 - - name: Run E2E Tests 2 (${{ matrix.shard.name }}) + - name: Run @spark_1 (attempt 2) continue-on-error: true if: steps.test1.outcome != 'success' id: test2 working-directory: bitkit-e2e-tests - run: ./ci_run_ios.sh --mochaOpts.grep "${{ matrix.shard.grep }}" + run: ./scripts/run-spark-e2e.sh ios env: RECORD_VIDEO: true ATTEMPT: 2 - - name: Run E2E Tests 3 (${{ matrix.shard.name }}) + - name: Run @spark_1 (attempt 3) if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success' id: test3 working-directory: bitkit-e2e-tests - run: ./ci_run_ios.sh --mochaOpts.grep "${{ matrix.shard.grep }}" + run: ./scripts/run-spark-e2e.sh ios env: RECORD_VIDEO: true ATTEMPT: 3 - - name: Upload E2E Artifacts (${{ matrix.shard.name }}) - # Preserve failed-attempt evidence even when a retry passes. - if: always() - uses: actions/upload-artifact@v7 - with: - name: e2e-artifacts_${{ matrix.shard.name }}_${{ github.run_number }} - path: bitkit-e2e-tests/artifacts/ - retention-days: 7 - - - name: Cleanup Docker containers - if: always() + - name: Collect Spark logs + if: failure() working-directory: bitkit-e2e-tests run: | - if [ -x ./scripts/local-backend ]; then - ./scripts/local-backend down --remove-orphans -v || true - else - (cd docker && docker compose --profile trezor down --remove-orphans -v) || true - fi + mkdir -p artifacts + ./scripts/local-backend spark-logs --tail 200 > artifacts/spark-docker.log 2>&1 || true - e2e-status: - if: always() && github.event.pull_request.draft == false - name: e2e-status - runs-on: ubuntu-24.04 - needs: [detect-changes, e2e-tests-local] - steps: - - name: Verify change detection succeeded - if: needs.detect-changes.result != 'success' - run: | - echo "Change detection failed or did not complete." - exit 1 + - name: Stop Spark fixture + if: always() && steps.spark.outcome != 'skipped' + working-directory: bitkit-e2e-tests + run: cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v - - name: E2E skipped - no code changes - if: needs.detect-changes.outputs.code != 'true' - run: echo "✅ E2E skipped - no code changes" + - name: Remove the imported archives + if: always() + run: rm -f "$RUNNER_TEMP/spark-images.tar.gz" "$RUNNER_TEMP/spark-ios-app.tar.gz" - - name: Verify all E2E shards succeeded - if: needs.detect-changes.outputs.code == 'true' - run: | - if [ "${{ needs.e2e-tests-local.result }}" != "success" ]; then - echo "❌ Some E2E shards failed." - exit 1 - fi - echo "✅ All E2E shards passed!" + # Preserve logs and recordings from failed attempts even when a retry passes. + - uses: actions/upload-artifact@v7 + if: always() + with: + name: spark-ios-${{ github.run_number }} + path: bitkit-e2e-tests/artifacts/ + retention-days: 7 - report-retarget-result: - name: Report retarget E2E result - if: always() && inputs.retarget_run != '' - needs: [detect-changes, build-local, e2e-branch, e2e-tests-local, e2e-status] + slack-report: + if: >- + always() && + (github.event_name == 'schedule' || + (github.event_name == 'workflow_dispatch' && inputs.post_to_slack == true)) + needs: [spark-images, build-spark-ios, e2e-spark] runs-on: ubuntu-24.04 + timeout-minutes: 5 permissions: contents: read - pull-requests: read - checks: write steps: - - uses: actions/checkout@v7 + - name: Checkout shared Slack reporter + uses: actions/checkout@v7 with: - ref: ${{ github.workflow_sha }} - path: retarget-ci - sparse-checkout: .github/scripts - - uses: actions/github-script@v9 + repository: synonymdev/bitkit-e2e-tests + ref: b7e445ad080827421f427fd26ae04b1782d8409c + persist-credentials: false + + - name: Post Slack summary + run: python3 scripts/slack_summary.py e2e-local-nightly env: - RETARGET_CHECK_RUN_ID: ${{ inputs.check_run_id }} - RETARGET_RUN: ${{ inputs.retarget_run }} - RETARGET_HEAD_SHA: ${{ inputs.head_sha }} - RETARGET_MERGE_COMMIT: ${{ inputs.merge_commit }} - RETARGET_PR: ${{ inputs.pr }} - RETARGET_HELPER_REF: ${{ inputs.helper_ref }} - TEST_RESULTS: ${{ toJSON(needs) }} - with: - script: | - const {reportRetargetResult, e2eRetargetResult} = require('./retarget-ci/.github/scripts/retarget-tests.cjs'); - const result = e2eRetargetResult(JSON.parse(process.env.TEST_RESULTS)); - await reportRetargetResult({github, context, core, name: 'e2e-status', phase: 'complete', result}); + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_STAGING }} + PLATFORM: ios + LOCAL_NIGHTLY_RESULT: >- + ${{ contains(needs.*.result, 'failure') && 'failure' || + contains(needs.*.result, 'cancelled') && 'cancelled' || needs.e2e-spark.result }} + SPARK_IMAGES_RESULT: ${{ needs.spark-images.result }} + BUILD_RESULT: ${{ needs.build-spark-ios.result }} + E2E_TESTS_REF: ${{ needs.spark-images.outputs.e2e-sha || inputs.e2e_branch || 'main' }} + SPARK_FIXTURE_RESULT: ${{ needs.e2e-spark.outputs.spark-fixture }} + SPARK_APP_SETUP_RESULT: ${{ needs.e2e-spark.outputs.spark-app-setup }} + E2E_TESTS_RESULT: ${{ needs.e2e-spark.result }} + SPARK_CASE_RESULT: ${{ needs.e2e-spark.outputs.spark-case }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + RUN_ATTEMPT: ${{ github.run_attempt }} From 968e431bbff4ff61661bf6f5526afd12f1452dbf Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 10:49:05 +0100 Subject: [PATCH 15/25] ci: restore the regular E2E workflow after Spark dispatch --- .github/workflows/e2e-tests.yml | 565 ++++++++++++++++++++------------ 1 file changed, 359 insertions(+), 206 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 443d7bce8..6f7e32974 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,21 +1,43 @@ -name: Local E2E Nightly (iOS) +name: e2e-tests +run-name: >- + ${{ inputs.retarget_run && format('Retarget E2E for PR #{0}', inputs.pr) || github.event.pull_request.title || github.event.head_commit.message || github.workflow }} on: - schedule: - - cron: "35 5 * * *" workflow_dispatch: inputs: e2e_branch: - description: "Ref in synonymdev/bitkit-e2e-tests" - type: string - default: main - post_to_slack: - description: "Post Local E2E Nightly summary to Slack (#bitkit-staging-nightly)" - type: boolean - default: false - -permissions: - contents: read + description: "Branch of synonymdev/bitkit-e2e-tests to use (main | default-feature-branch | custom branch name)" + required: false + default: "default-feature-branch" + pr: + description: "PR number to test as merged into master" + required: false + default: "" + merge_commit: + description: "Pinned PR merge commit for retarget validation" + default: "" + head_sha: + description: "PR head verified by the retarget dispatcher" + default: "" + app_branch: + description: "PR branch for selecting matching E2E coverage" + default: "" + check_run_id: + description: "PR check owned by this retarget validation" + default: "" + retarget_run: + description: "Retarget status owner (set by e2e-retarget.yml)" + default: "" + workflow_ref: + description: "Workflow source recorded for this validation generation" + default: master + helper_ref: + description: "Recovery helper branch or tag" + default: master + # PRs stacked on another branch run no E2E until they target master; e2e-retarget.yml starts it on retarget + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + branches: [master] env: TERM: xterm-256color @@ -23,282 +45,413 @@ env: GIT_LFS_SKIP_SMUDGE: "1" concurrency: - group: bitkit-local-e2e-nightly-ios - cancel-in-progress: false + group: e2e-tests-${{ github.event.pull_request.number || inputs.pr || github.ref }} + cancel-in-progress: true jobs: - spark-images: - runs-on: ubuntu-24.04-arm - timeout-minutes: 80 + detect-changes: + if: github.event.pull_request.draft == false + runs-on: ubuntu-24.04 outputs: - e2e-sha: ${{ steps.e2e.outputs.sha }} - spark-config: ${{ steps.settings.outputs.SPARK_LOCAL_CONFIG_B64 }} - spark-chain-url: ${{ steps.settings.outputs.SPARK_LOCAL_CHAIN_URL }} - image-fingerprint: ${{ steps.settings.outputs.image-fingerprint }} + code: ${{ (github.event_name == 'workflow_dispatch' && !inputs.pr) || steps.filter.outputs.code == 'true' }} steps: - uses: actions/checkout@v7 with: - repository: synonymdev/bitkit-e2e-tests - ref: ${{ inputs.e2e_branch || 'main' }} - persist-credentials: false - - - name: Record shared E2E revision - id: e2e - run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - - - name: Cache pinned Spark fixture images - id: images - uses: actions/cache@v6 - with: - path: ${{ runner.temp }}/spark-images.tar - key: spark-fixture-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('BITKIT_DOCKER_REVISION') }} - - - name: Package pinned Spark fixture images - if: steps.images.outputs.cache-hit != 'true' - run: ./scripts/local-backend spark-pack "$RUNNER_TEMP/spark-images.tar" - - - name: Generate pinned Spark app settings - id: settings + ref: ${{ inputs.merge_commit || (inputs.pr && format('refs/pull/{0}/merge', inputs.pr)) || '' }} + fetch-depth: 2 + - name: Resolve tested PR merge commits + if: inputs.pr != '' + id: merge-base run: | - docker image load --quiet --input "$RUNNER_TEMP/spark-images.tar" - ./scripts/local-backend spark-init-env >> "$GITHUB_OUTPUT" - fingerprint="$(./scripts/local-backend spark-image-fingerprint)" - echo "image-fingerprint=$fingerprint" >> "$GITHUB_OUTPUT" - - - name: Compress the fixture archive for transfer - run: gzip -1 -c "$RUNNER_TEMP/spark-images.tar" > "$RUNNER_TEMP/spark-images.tar.gz" - - - uses: actions/upload-artifact@v7 + echo "base=$(git rev-parse HEAD^1)" >> "$GITHUB_OUTPUT" + echo "head=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + - uses: dorny/paths-filter@v4 + # Retarget filters the exact tested merge against its first parent. + if: github.event_name == 'pull_request' || inputs.pr + id: filter with: - name: spark-fixture-images - path: ${{ runner.temp }}/spark-images.tar.gz - if-no-files-found: error - compression-level: 0 - retention-days: 3 - - build-spark-ios: - needs: spark-images + base: ${{ steps.merge-base.outputs.base || 'master' }} + ref: ${{ steps.merge-base.outputs.head || '' }} + filters: | + code: + - 'Bitkit/**' + - 'BitkitNotification/**' + - 'Bitkit.xcodeproj/**' + - 'Package.swift' + - '.github/workflows/e2e-tests.yml' + - '.github/scripts/**' + + build-local: + needs: detect-changes + # PR code must not publish dependency caches into the dispatch ref's scope. + cache-mode: read + permissions: + contents: read + packages: read + pull-requests: read + checks: write + actions: write + if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true' runs-on: macos-26 - timeout-minutes: 45 + steps: - - uses: actions/checkout@v7 + - name: Checkout + uses: actions/checkout@v7 with: - persist-credentials: false + ref: ${{ inputs.merge_commit || (inputs.pr && format('refs/pull/{0}/merge', inputs.pr)) || '' }} - - uses: actions/checkout@v7 + - name: Checkout retarget reporter + if: inputs.retarget_run != '' + uses: actions/checkout@v7 with: - repository: synonymdev/bitkit-e2e-tests - ref: ${{ needs.spark-images.outputs.e2e-sha }} - path: bitkit-e2e-tests - persist-credentials: false + ref: ${{ github.workflow_sha }} + path: retarget-ci + sparse-checkout: .github/scripts + - name: Report retarget tests running + if: inputs.retarget_run != '' + uses: actions/github-script@v9 + env: + RETARGET_CHECK_RUN_ID: ${{ inputs.check_run_id }} + RETARGET_RUN: ${{ inputs.retarget_run }} + RETARGET_HEAD_SHA: ${{ inputs.head_sha }} + RETARGET_MERGE_COMMIT: ${{ inputs.merge_commit }} + RETARGET_PR: ${{ inputs.pr }} + RETARGET_HELPER_REF: ${{ inputs.helper_ref }} + with: + script: | + const {reportRetargetResult} = require('./retarget-ci/.github/scripts/retarget-tests.cjs'); + await reportRetargetResult({github, context, core, name: 'e2e-status', phase: 'start'}); - name: Set up Xcode uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: "26.6" + - name: System Information + run: | + echo "=== System Information ===" + echo "macOS Version:" + sw_vers + echo "" + echo "Xcode Version:" + xcodebuild -version + + - name: Verify current PR merge checkout + if: github.event_name == 'pull_request' || inputs.pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr }} + run: | + [[ "$PR_NUMBER" =~ ^[0-9]+$ ]] || exit 1 + tested=$(git rev-parse HEAD) + head=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER" --jq 'select(.base.ref == "master") | .head.sha') + base=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/master" --jq '.object.sha') + expected="$base $head" + actual=$(gh api "repos/$GITHUB_REPOSITORY/commits/$tested" --jq '[.parents[].sha] | join(" ")') + if [[ ! "$expected" =~ ^[0-9a-f]{40}\ [0-9a-f]{40}$ || "$actual" != "$expected" ]]; then + echo "::error::Checked-out merge does not match the PR's current base and head" + exit 1 + fi + - name: Install xcbeautify - run: brew install xcbeautify + run: | + brew install xcbeautify - name: Swift packages uses: ./.github/actions/swift-packages - - name: Build iOS Spark app - working-directory: bitkit-e2e-tests + - name: Pre-start simulator + run: | + echo "⏱️ Starting simulator at $(date)" + xcrun simctl boot "iPhone 17" || true + echo "✅ Simulator started at $(date)" + + - name: Build iOS app (local) env: - IOS_ROOT: ${{ github.workspace }} - IOS_SIMULATOR_ARCH: arm64 - SPARK_LOCAL_CONFIG_B64: ${{ needs.spark-images.outputs.spark-config }} - SPARK_LOCAL_CHAIN_URL: ${{ needs.spark-images.outputs.spark-chain-url }} + GITHUB_ACTOR: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CHATWOOT_API: ${{ secrets.CHATWOOT_API }} + SIMULATOR_NAME: "iPhone 17" + OS_VERSION: "26.5" + run: | + echo "=== Building iOS app (local) ===" + echo "Using simulator: $SIMULATOR_NAME (iOS $OS_VERSION)" + + if xcodebuild -showsdks | grep -q "iOS Simulator"; then + echo "✅ iOS Simulator platform already installed" + else + echo "⚙️ iOS Simulator platform not found — downloading..." + xcodebuild -downloadPlatform iOS + fi + + xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \ + -scheme Bitkit \ + -configuration Debug \ + -destination "platform=iOS Simulator,name=$SIMULATOR_NAME,OS=$OS_VERSION" \ + -derivedDataPath DerivedData \ + -clonedSourcePackagesDirPath "$SOURCE_PACKAGES" \ + -disablePackageRepositoryCache \ + -disableAutomaticPackageResolution \ + -skipPackageUpdates \ + SWIFT_ACTIVE_COMPILATION_CONDITIONS='DEBUG E2E_BUILD' \ + TREZOR_BRIDGE=true \ + TREZOR_BRIDGE_URL=http://127.0.0.1:21325 \ + -allowProvisioningUpdates \ + build + + - name: Prepare app for E2E tests (local) run: | - test -n "$SPARK_LOCAL_CONFIG_B64" - test -n "$SPARK_LOCAL_CHAIN_URL" - ./scripts/build-ios-sim.sh - tar -C aut -czf "$RUNNER_TEMP/spark-ios-app.tar.gz" Bitkit.app + # Copy the .app bundle to the expected location and name + mkdir -p e2e-app + cp -r DerivedData/Build/Products/Debug-iphonesimulator/Bitkit.app e2e-app/bitkit.app - - uses: actions/upload-artifact@v7 + - name: Upload iOS app (local) + uses: actions/upload-artifact@v7 with: - name: spark-ios-app - path: ${{ runner.temp }}/spark-ios-app.tar.gz - if-no-files-found: error - compression-level: 0 - retention-days: 3 - - e2e-spark: - needs: [spark-images, build-spark-ios] + name: bitkit-e2e-ios_${{ github.run_number }} + path: e2e-app/ + + e2e-branch: + needs: detect-changes + if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true' + uses: synonymdev/bitkit-e2e-tests/.github/workflows/determine-e2e-branch.yml@main + with: + app_branch: ${{ inputs.app_branch || github.head_ref || github.ref_name }} + e2e_branch_input: ${{ github.event.inputs.e2e_branch || 'default-feature-branch' }} + + e2e-tests-local: + cache-mode: read + permissions: + contents: read + packages: read + pull-requests: read + checks: write + actions: write + if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true' runs-on: [self-hosted, macOS] - timeout-minutes: 120 - outputs: - spark-case: >- - ${{ contains(steps.*.outputs.spark-case, 'passed') && 'passed' || - contains(steps.*.outputs.spark-case, 'failed') && 'failed' || - contains(steps.*.outputs.spark-case, 'started') && 'started' || '' }} - spark-app-setup: >- - ${{ contains(steps.*.outputs.spark-case, 'setup-failed') && 'failure' || - contains(steps.*.outputs.spark-case, 'setup') && 'interrupted' || '' }} - spark-fixture: ${{ steps.spark.outcome }} + needs: [detect-changes, build-local, e2e-branch] env: - COMPOSE_PROJECT_NAME: bitkit-spark-e2e + # Reuse the legacy project so reset also clears containers left after a ref switch. + COMPOSE_PROJECT_NAME: docker + # Match the legacy fixture for the iOS manual channel funding Max case. + BITCOIN_FALLBACK_FEE: "0.00001" + + strategy: + fail-fast: false + matrix: + shard: + # - { name: onboarding_backup_numberpad, grep: "@onboarding|@backup|@numberpad" } + # - { name: onchain_boost_receive_widgets, grep: "@onchain|@boost|@receive|@widgets" } + # - { name: settings, grep: "@settings" } + # - { name: security, grep: "@security" } + - { name: e2e, grep: '@ios_gate' } + + name: e2e-tests-local - ${{ matrix.shard.name }} + steps: - - uses: actions/checkout@v7 + - name: Checkout retarget reporter + if: inputs.retarget_run != '' + uses: actions/checkout@v7 + with: + ref: ${{ github.workflow_sha }} + path: retarget-ci + sparse-checkout: .github/scripts + - name: Report retarget tests running + if: inputs.retarget_run != '' + uses: actions/github-script@v9 + env: + RETARGET_CHECK_RUN_ID: ${{ inputs.check_run_id }} + RETARGET_RUN: ${{ inputs.retarget_run }} + RETARGET_HEAD_SHA: ${{ inputs.head_sha }} + RETARGET_MERGE_COMMIT: ${{ inputs.merge_commit }} + RETARGET_PR: ${{ inputs.pr }} + RETARGET_HELPER_REF: ${{ inputs.helper_ref }} + with: + script: | + const {reportRetargetResult} = require('./retarget-ci/.github/scripts/retarget-tests.cjs'); + await reportRetargetResult({github, context, core, name: 'e2e-status', phase: 'start'}); + + - name: Resolve E2E tests ref + id: e2e-ref + uses: synonymdev/bitkit-e2e-tests/.github/actions/resolve-e2e-ref@main + with: + selected: ${{ needs.e2e-branch.outputs.branch }} + e2e_branch_input: ${{ github.event.inputs.e2e_branch || 'default-feature-branch' }} + + - name: Clone E2E tests + uses: actions/checkout@v7 with: repository: synonymdev/bitkit-e2e-tests - ref: ${{ needs.spark-images.outputs.e2e-sha }} path: bitkit-e2e-tests - persist-credentials: false + ref: ${{ steps.e2e-ref.outputs.ref }} + + - name: Download iOS app + uses: actions/download-artifact@v8 + with: + name: bitkit-e2e-ios_${{ github.run_number }} + path: bitkit-e2e-tests/aut + + - name: List iOS app directory contents + run: ls -l bitkit-e2e-tests/aut - - uses: actions/setup-node@v7 + - name: Setup Node.js + uses: actions/setup-node@v7 with: node-version: 22 - cache: npm - cache-dependency-path: bitkit-e2e-tests/package-lock.json - - name: Install Appium dependencies + - name: Cache npm cache + uses: actions/cache@v6 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('bitkit-e2e-tests/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies working-directory: bitkit-e2e-tests run: npm ci - - name: Check the local Spark images - id: local-images + - name: Docker info + run: | + docker --version + docker info + docker ps + docker compose version + + - name: Run regtest setup working-directory: bitkit-e2e-tests - env: - SPARK_IMAGE_FINGERPRINT: ${{ needs.spark-images.outputs.image-fingerprint }} run: | - if [[ "$RUNNER_ARCH" != ARM64 ]]; then - echo "::error::The Spark fixture archive requires an ARM64 Mac runner." - exit 1 + if [ -x ./scripts/local-backend ]; then + ./scripts/local-backend prepare + ./scripts/local-backend down --remove-orphans -v -t 300 + ./scripts/local-backend up + ./scripts/local-backend github-env >> "$GITHUB_ENV" + else + # Older E2E refs still carry the bundled stack. + cd docker + docker compose --verbose --profile trezor down --remove-orphans -v -t 300 || true + mkdir -p lnd && chmod 777 lnd + docker compose --verbose up --force-recreate -d fi - test -n "$SPARK_IMAGE_FINGERPRINT" - ./scripts/local-backend prepare - if actual="$(./scripts/local-backend spark-image-fingerprint 2>/dev/null)" && - [[ "$actual" == "$SPARK_IMAGE_FINGERPRINT" ]]; then - echo 'Reusing the exact pinned Spark images on this runner.' - echo 'match=true' >> "$GITHUB_OUTPUT" - fi - - - uses: actions/download-artifact@v8 - if: steps.local-images.outputs.match != 'true' - with: - name: spark-fixture-images - path: ${{ runner.temp }} - - name: Load the pinned Spark images - if: steps.local-images.outputs.match != 'true' + - name: Wait for electrum server run: | - docker image load --input "$RUNNER_TEMP/spark-images.tar.gz" - rm -f "$RUNNER_TEMP/spark-images.tar.gz" + for _ in $(seq 1 60); do + python3 -c 'import socket; s = socket.create_connection(("127.0.0.1", 60001), 10); s.sendall(b"{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"blockchain.headers.subscribe\",\"params\":[]}\n"); assert b"height" in s.recv(4096)' && exit 0 + sleep 5 + done + exit 1 - - uses: actions/download-artifact@v8 - with: - name: spark-ios-app - path: ${{ runner.temp }} - - - name: Unpack the hosted simulator build + - name: Clear previous E2E artifacts working-directory: bitkit-e2e-tests run: | - mkdir -p aut - tar -C aut -xzf "$RUNNER_TEMP/spark-ios-app.tar.gz" - rm -f "$RUNNER_TEMP/spark-ios-app.tar.gz" + rm -rf artifacts/ + rm -rf /tmp/lock/ - - name: Start pinned Spark fixture - id: spark - working-directory: bitkit-e2e-tests - env: - SPARK_IMAGE_FINGERPRINT: ${{ needs.spark-images.outputs.image-fingerprint }} - SPARK_LOCAL_CONFIG_B64: ${{ needs.spark-images.outputs.spark-config }} - SPARK_LOCAL_CHAIN_URL: ${{ needs.spark-images.outputs.spark-chain-url }} + - name: Clear iOS Simulator environment run: | - (cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v) - ./scripts/local-backend spark-up - expected="$(printf 'SPARK_LOCAL_CONFIG_B64=%s\nSPARK_LOCAL_CHAIN_URL=%s' "$SPARK_LOCAL_CONFIG_B64" "$SPARK_LOCAL_CHAIN_URL")" - if [[ "$(./scripts/local-backend spark-env)" != "$expected" ]]; then - echo "::error::The running Spark fixture differs from the simulator build settings." - exit 1 - fi + xcrun simctl shutdown all || true + xcrun simctl erase "iPhone 17" || true + defaults write com.apple.iphonesimulator DisableAllNotifications -bool true - - name: Run @spark_1 (attempt 1) + - name: Run E2E Tests 1 (${{ matrix.shard.name }}) continue-on-error: true id: test1 working-directory: bitkit-e2e-tests - run: ./scripts/run-spark-e2e.sh ios + run: ./ci_run_ios.sh --mochaOpts.grep '${{ matrix.shard.grep }}' env: RECORD_VIDEO: true ATTEMPT: 1 - - name: Run @spark_1 (attempt 2) + - name: Run E2E Tests 2 (${{ matrix.shard.name }}) continue-on-error: true if: steps.test1.outcome != 'success' id: test2 working-directory: bitkit-e2e-tests - run: ./scripts/run-spark-e2e.sh ios + run: ./ci_run_ios.sh --mochaOpts.grep "${{ matrix.shard.grep }}" env: RECORD_VIDEO: true ATTEMPT: 2 - - name: Run @spark_1 (attempt 3) + - name: Run E2E Tests 3 (${{ matrix.shard.name }}) if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success' id: test3 working-directory: bitkit-e2e-tests - run: ./scripts/run-spark-e2e.sh ios + run: ./ci_run_ios.sh --mochaOpts.grep "${{ matrix.shard.grep }}" env: RECORD_VIDEO: true ATTEMPT: 3 - - name: Collect Spark logs - if: failure() + - name: Upload E2E Artifacts (${{ matrix.shard.name }}) + # Preserve failed-attempt evidence even when a retry passes. + if: always() + uses: actions/upload-artifact@v7 + with: + name: e2e-artifacts_${{ matrix.shard.name }}_${{ github.run_number }} + path: bitkit-e2e-tests/artifacts/ + retention-days: 7 + + - name: Cleanup Docker containers + if: always() working-directory: bitkit-e2e-tests run: | - mkdir -p artifacts - ./scripts/local-backend spark-logs --tail 200 > artifacts/spark-docker.log 2>&1 || true + if [ -x ./scripts/local-backend ]; then + ./scripts/local-backend down --remove-orphans -v || true + else + (cd docker && docker compose --profile trezor down --remove-orphans -v) || true + fi - - name: Stop Spark fixture - if: always() && steps.spark.outcome != 'skipped' - working-directory: bitkit-e2e-tests - run: cd "$(./scripts/local-backend path)" && docker compose --profile spark down --remove-orphans -v + e2e-status: + if: always() && github.event.pull_request.draft == false + name: e2e-status + runs-on: ubuntu-24.04 + needs: [detect-changes, e2e-tests-local] + steps: + - name: Verify change detection succeeded + if: needs.detect-changes.result != 'success' + run: | + echo "Change detection failed or did not complete." + exit 1 - - name: Remove the imported archives - if: always() - run: rm -f "$RUNNER_TEMP/spark-images.tar.gz" "$RUNNER_TEMP/spark-ios-app.tar.gz" + - name: E2E skipped - no code changes + if: needs.detect-changes.outputs.code != 'true' + run: echo "✅ E2E skipped - no code changes" - # Preserve logs and recordings from failed attempts even when a retry passes. - - uses: actions/upload-artifact@v7 - if: always() - with: - name: spark-ios-${{ github.run_number }} - path: bitkit-e2e-tests/artifacts/ - retention-days: 7 + - name: Verify all E2E shards succeeded + if: needs.detect-changes.outputs.code == 'true' + run: | + if [ "${{ needs.e2e-tests-local.result }}" != "success" ]; then + echo "❌ Some E2E shards failed." + exit 1 + fi + echo "✅ All E2E shards passed!" - slack-report: - if: >- - always() && - (github.event_name == 'schedule' || - (github.event_name == 'workflow_dispatch' && inputs.post_to_slack == true)) - needs: [spark-images, build-spark-ios, e2e-spark] + report-retarget-result: + name: Report retarget E2E result + if: always() && inputs.retarget_run != '' + needs: [detect-changes, build-local, e2e-branch, e2e-tests-local, e2e-status] runs-on: ubuntu-24.04 - timeout-minutes: 5 permissions: contents: read + pull-requests: read + checks: write steps: - - name: Checkout shared Slack reporter - uses: actions/checkout@v7 + - uses: actions/checkout@v7 with: - repository: synonymdev/bitkit-e2e-tests - ref: b7e445ad080827421f427fd26ae04b1782d8409c - persist-credentials: false - - - name: Post Slack summary - run: python3 scripts/slack_summary.py e2e-local-nightly + ref: ${{ github.workflow_sha }} + path: retarget-ci + sparse-checkout: .github/scripts + - uses: actions/github-script@v9 env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_STAGING }} - PLATFORM: ios - LOCAL_NIGHTLY_RESULT: >- - ${{ contains(needs.*.result, 'failure') && 'failure' || - contains(needs.*.result, 'cancelled') && 'cancelled' || needs.e2e-spark.result }} - SPARK_IMAGES_RESULT: ${{ needs.spark-images.result }} - BUILD_RESULT: ${{ needs.build-spark-ios.result }} - E2E_TESTS_REF: ${{ needs.spark-images.outputs.e2e-sha || inputs.e2e_branch || 'main' }} - SPARK_FIXTURE_RESULT: ${{ needs.e2e-spark.outputs.spark-fixture }} - SPARK_APP_SETUP_RESULT: ${{ needs.e2e-spark.outputs.spark-app-setup }} - E2E_TESTS_RESULT: ${{ needs.e2e-spark.result }} - SPARK_CASE_RESULT: ${{ needs.e2e-spark.outputs.spark-case }} - RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - RUN_ATTEMPT: ${{ github.run_attempt }} + RETARGET_CHECK_RUN_ID: ${{ inputs.check_run_id }} + RETARGET_RUN: ${{ inputs.retarget_run }} + RETARGET_HEAD_SHA: ${{ inputs.head_sha }} + RETARGET_MERGE_COMMIT: ${{ inputs.merge_commit }} + RETARGET_PR: ${{ inputs.pr }} + RETARGET_HELPER_REF: ${{ inputs.helper_ref }} + TEST_RESULTS: ${{ toJSON(needs) }} + with: + script: | + const {reportRetargetResult, e2eRetargetResult} = require('./retarget-ci/.github/scripts/retarget-tests.cjs'); + const result = e2eRetargetResult(JSON.parse(process.env.TEST_RESULTS)); + await reportRetargetResult({github, context, core, name: 'e2e-status', phase: 'complete', result}); From e94140e211618a5f922e2a374a2f006e7340388e Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 11:47:04 +0100 Subject: [PATCH 16/25] ci: report local nightly results by job --- .github/workflows/e2e-local-nightly.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index 4f3ecf9e9..25c7c8d3b 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -128,15 +128,6 @@ jobs: needs: [spark-images, build-spark-ios] runs-on: [self-hosted, macOS] timeout-minutes: 120 - outputs: - spark-case: >- - ${{ contains(steps.*.outputs.spark-case, 'passed') && 'passed' || - contains(steps.*.outputs.spark-case, 'failed') && 'failed' || - contains(steps.*.outputs.spark-case, 'started') && 'started' || '' }} - spark-app-setup: >- - ${{ contains(steps.*.outputs.spark-case, 'setup-failed') && 'failure' || - contains(steps.*.outputs.spark-case, 'setup') && 'interrupted' || '' }} - spark-fixture: ${{ steps.spark.outcome }} env: COMPOSE_PROJECT_NAME: bitkit-spark-e2e steps: @@ -296,9 +287,6 @@ jobs: SPARK_IMAGES_RESULT: ${{ needs.spark-images.result }} BUILD_RESULT: ${{ needs.build-spark-ios.result }} E2E_TESTS_REF: ${{ needs.spark-images.outputs.e2e-sha || inputs.e2e_branch || 'main' }} - SPARK_FIXTURE_RESULT: ${{ needs.e2e-spark.outputs.spark-fixture }} - SPARK_APP_SETUP_RESULT: ${{ needs.e2e-spark.outputs.spark-app-setup }} E2E_TESTS_RESULT: ${{ needs.e2e-spark.result }} - SPARK_CASE_RESULT: ${{ needs.e2e-spark.outputs.spark-case }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} RUN_ATTEMPT: ${{ github.run_attempt }} From deb25d30be2bc8deea4f2a6b1ef3182a2cbf63e3 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 12:02:49 +0100 Subject: [PATCH 17/25] ci: use reusable E2E retry step names --- .github/workflows/e2e-local-nightly.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index 25c7c8d3b..b566a4bbc 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -206,7 +206,7 @@ jobs: exit 1 fi - - name: Run @spark_1 (attempt 1) + - name: Run E2E tests (attempt 1) continue-on-error: true id: test1 working-directory: bitkit-e2e-tests @@ -215,7 +215,7 @@ jobs: RECORD_VIDEO: true ATTEMPT: 1 - - name: Run @spark_1 (attempt 2) + - name: Run E2E tests (attempt 2) continue-on-error: true if: steps.test1.outcome != 'success' id: test2 @@ -225,7 +225,7 @@ jobs: RECORD_VIDEO: true ATTEMPT: 2 - - name: Run @spark_1 (attempt 3) + - name: Run E2E tests (attempt 3) if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success' id: test3 working-directory: bitkit-e2e-tests From 5291501090d28ce29c4a51b00d7b5ddefce01567 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 12:18:51 +0100 Subject: [PATCH 18/25] fix: share the local Spark chain across wallet operations --- Bitkit/Constants/Env.swift | 13 +++++++++---- Bitkit/Managers/SparkManager.swift | 16 +++++++--------- .../SparkExit/SparkExitBroadcaster.swift | 2 +- BitkitTests/SparkConfigTests.swift | 11 ++++++++++- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Bitkit/Constants/Env.swift b/Bitkit/Constants/Env.swift index 06065c69a..e20b3e75e 100644 --- a/Bitkit/Constants/Env.swift +++ b/Bitkit/Constants/Env.swift @@ -227,12 +227,17 @@ enum Env { } /// Esplora REST API Spark reads the chain from and broadcasts through, in place of the SDK's default - /// (mempool.space with blockstream as fallback on mainnet); nil keeps the default. On regtest a debug or E2E build - /// can point Spark at Bitkit's own chain with `SPARK_CHAIN_SERVICE_URL`, so a Savings deposit reaches it. - static func sparkChainServiceUrl(for network: LDKNode.Network) -> String? { + /// (mempool.space with blockstream as fallback on mainnet); nil keeps the default. A local E2E build uses its + /// pinned regtest fixture for both deposits and exits. + static func sparkChainServiceUrl( + for network: LDKNode.Network, + localRegtestURL: String? = localSparkSettings.chainURL, + configuredURL: String? = configValue("SPARK_CHAIN_SERVICE_URL") + ) -> String? { switch network { case .bitcoin: "https://bitkit.to/electrs" - default: configValue("SPARK_CHAIN_SERVICE_URL") + case .regtest: localRegtestURL ?? configuredURL + default: configuredURL } } diff --git a/Bitkit/Managers/SparkManager.swift b/Bitkit/Managers/SparkManager.swift index fec9e4fac..85af63489 100644 --- a/Bitkit/Managers/SparkManager.swift +++ b/Bitkit/Managers/SparkManager.swift @@ -452,16 +452,14 @@ final class SparkManager: ChannelFreeLightningRail { } let passphrase = try Keychain.loadString(key: .bip39Passphrase(index: walletIndex)) var config = Self.sdkConfig(network: network, apiKey: Env.breezApiKey, isExiting: isExiting) - let localChainURL = try Self.configureLocalSpark(&config) + let chainAPI = try Self.configureLocalSpark(&config) let storageDir = Env.sparkStorage(walletIndex: walletIndex) try FileManager.default.createDirectory(at: storageDir, withIntermediateDirectories: true) // What `BreezSdkSpark.connect` builds, plus our own chain service where Env names one. let builder = SdkBuilder(config: config, seed: .mnemonic(mnemonic: mnemonic, passphrase: passphrase)) await builder.withDefaultStorage(storageDir: storageDir.path) - if let localChainURL { - await builder.withRestChainService(url: localChainURL, apiType: .mempoolSpace, credentials: nil) - } else if let chainServiceUrl = Env.sparkChainServiceUrl(for: Env.network) { - await builder.withRestChainService(url: chainServiceUrl, apiType: .esplora, credentials: nil) + if let chainServiceUrl = Env.sparkChainServiceUrl(for: Env.network) { + await builder.withRestChainService(url: chainServiceUrl, apiType: chainAPI, credentials: nil) } syncedThisRun = false let connected = try await builder.build() @@ -478,15 +476,15 @@ final class SparkManager: ChannelFreeLightningRail { Self.notifyExitStateChanged() } - private nonisolated static func configureLocalSpark(_ config: inout BreezSdkSpark.Config) throws -> String? { + private nonisolated static func configureLocalSpark(_ config: inout BreezSdkSpark.Config) throws -> ChainApiType { let settings = Env.localSparkSettings if settings.configBase64 == nil, settings.chainURL == nil { - return nil + return .esplora } guard let encoded = settings.configBase64, let data = Data(base64Encoded: encoded), let json = String(data: data, encoding: .utf8), - let chainURL = settings.chainURL + settings.chainURL != nil else { throw NSError(domain: "LocalSparkConfiguration", code: 1, userInfo: [ NSLocalizedDescriptionKey: "Local Spark requires a valid SPARK_LOCAL_CONFIG_B64 and SPARK_LOCAL_CHAIN_URL", @@ -495,7 +493,7 @@ final class SparkManager: ChannelFreeLightningRail { config.sparkConfig = try parseSparkConfig(json: json) // The pinned regtest operators require anchored refunds. config.watchtowerFeeLadderEnabled = false - return chainURL + return .mempoolSpace } /// The SDK config Bitkit connects with. diff --git a/Bitkit/Services/SparkExit/SparkExitBroadcaster.swift b/Bitkit/Services/SparkExit/SparkExitBroadcaster.swift index bc5ae86b6..57951f18b 100644 --- a/Bitkit/Services/SparkExit/SparkExitBroadcaster.swift +++ b/Bitkit/Services/SparkExit/SparkExitBroadcaster.swift @@ -149,7 +149,7 @@ struct EsploraSparkExitChain: SparkExitChain { /// On mainnet the chain service Spark connects with (`Env.sparkChainServiceUrl`) answers every read and takes /// broadcasts first, on its `/txs/package` (no `/v1`); the SDK's default hosts stay as broadcast fallbacks. On - /// regtest the chain service Spark connects with, `regtestChainServiceUrl` (`SPARK_CHAIN_SERVICE_URL`), does both, + /// regtest the configured chain service (including the local E2E fixture) does both, /// else the SDK's default host (breez spark-sdk `default_rest_chain_services`). static func network( _ network: BreezSdkSpark.Network, diff --git a/BitkitTests/SparkConfigTests.swift b/BitkitTests/SparkConfigTests.swift index d153d0ac6..a6915ef50 100644 --- a/BitkitTests/SparkConfigTests.swift +++ b/BitkitTests/SparkConfigTests.swift @@ -24,6 +24,15 @@ final class SparkConfigTests: XCTestCase { func testChainServiceIsBitkitElectrsOnMainnetOnly() { XCTAssertEqual(Env.sparkChainServiceUrl(for: .bitcoin), "https://bitkit.to/electrs") - XCTAssertNil(Env.sparkChainServiceUrl(for: .regtest)) + XCTAssertNil(Env.sparkChainServiceUrl(for: .regtest, localRegtestURL: nil, configuredURL: nil)) + } + + func testLocalChainServiceTakesPrecedenceOnlyOnRegtest() { + let local = "http://127.0.0.1:23090/api" + let configured = "https://example.com/electrs" + XCTAssertEqual(Env.sparkChainServiceUrl(for: .regtest, localRegtestURL: local, configuredURL: configured), local) + XCTAssertEqual(Env.sparkChainServiceUrl(for: .regtest, localRegtestURL: nil, configuredURL: configured), configured) + XCTAssertEqual(Env.sparkChainServiceUrl(for: .bitcoin, localRegtestURL: local, configuredURL: configured), "https://bitkit.to/electrs") + XCTAssertEqual(Env.sparkChainServiceUrl(for: .signet, localRegtestURL: local, configuredURL: configured), configured) } } From e939dbd7048d04e9951530f5dac2e57e2a2b45d4 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 13:08:05 +0100 Subject: [PATCH 19/25] ci: isolate the Spark image cache and keep retry diagnostics --- .github/workflows/e2e-local-nightly.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index b566a4bbc..f498908c5 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -44,11 +44,15 @@ jobs: - name: Record shared E2E revision id: e2e - run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + run: | + echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + if [[ "$(git symbolic-ref --quiet HEAD)" == refs/heads/main ]]; then + echo 'save-cache=true' >> "$GITHUB_OUTPUT" + fi - - name: Cache pinned Spark fixture images + - name: Restore pinned Spark fixture images id: images - uses: actions/cache@v6 + uses: actions/cache/restore@v6 with: path: ${{ runner.temp }}/spark-images.tar key: spark-fixture-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('BITKIT_DOCKER_REVISION') }} @@ -65,6 +69,14 @@ jobs: fingerprint="$(./scripts/local-backend spark-image-fingerprint)" echo "image-fingerprint=$fingerprint" >> "$GITHUB_OUTPUT" + - name: Save pinned Spark fixture images + if: steps.images.outputs.cache-hit != 'true' && steps.e2e.outputs.save-cache == 'true' + continue-on-error: true + uses: actions/cache/save@v6 + with: + path: ${{ runner.temp }}/spark-images.tar + key: ${{ steps.images.outputs.cache-primary-key }} + - name: Compress the fixture archive for transfer run: gzip -1 -c "$RUNNER_TEMP/spark-images.tar" > "$RUNNER_TEMP/spark-images.tar.gz" @@ -235,7 +247,7 @@ jobs: ATTEMPT: 3 - name: Collect Spark logs - if: failure() + if: failure() || steps.test1.outcome == 'failure' working-directory: bitkit-e2e-tests run: | mkdir -p artifacts From 8f026be98cfc8fa20224f69114bf1f0d5941775e Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 13:27:03 +0100 Subject: [PATCH 20/25] fix: guard local Spark funding against custom Electrum servers --- Bitkit/Constants/Env.swift | 17 ++++++++++++++- Bitkit/Managers/SparkManager.swift | 13 +++++++++++- Bitkit/Services/LightningService.swift | 25 +++++++++++++++++------ Bitkit/ViewModels/TransferViewModel.swift | 4 +--- BitkitTests/SparkConfigTests.swift | 14 +++++++++++++ 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/Bitkit/Constants/Env.swift b/Bitkit/Constants/Env.swift index e20b3e75e..3b848e994 100644 --- a/Bitkit/Constants/Env.swift +++ b/Bitkit/Constants/Env.swift @@ -243,11 +243,26 @@ enum Env { static var electrumServerUrl: String { if isE2E, e2eBackend == "local" { - return "tcp://\(e2eLocalHost):60001" + return localElectrumServerUrl(host: e2eLocalHost) } return electrumServerUrl(for: network) } + /// The pinned fixture's Spark REST and Savings Electrum endpoints serve the same regtest. + static func sharesLocalSparkChain( + sparkURL: String, + nodeElectrumURL: String?, + hardwareElectrumURL: String, + fixtureHost: String = e2eLocalHost + ) -> Bool { + let electrumURL = localElectrumServerUrl(host: fixtureHost) + return sparkURL == "http://\(fixtureHost):23090/api" && nodeElectrumURL == electrumURL && hardwareElectrumURL == electrumURL + } + + private static func localElectrumServerUrl(host: String) -> String { + "tcp://\(host):60001" + } + /// Whether a Paykit payment may route through a Pubky Swaps provider when no balance reaches the contact's /// endpoints. Regtest debug builds with `PUBKY_SWAPS_ROUTES=true` only. static var isPubkySwapsRouteEnabled: Bool { diff --git a/Bitkit/Managers/SparkManager.swift b/Bitkit/Managers/SparkManager.swift index 85af63489..a147eb664 100644 --- a/Bitkit/Managers/SparkManager.swift +++ b/Bitkit/Managers/SparkManager.swift @@ -143,7 +143,18 @@ final class SparkManager: ChannelFreeLightningRail { /// Whether savings or a hardware wallet can fund Spark: its deposit goes out on Bitkit's chain, which Spark must read. var canFundFromChain: Bool { - isReady && Self.readsBitkitChain(network: Env.network, chainServiceUrl: Env.sparkChainServiceUrl(for: Env.network)) + isReady && readsSavingsChain + } + + var readsSavingsChain: Bool { + if let fixtureURL = Env.localSparkSettings.chainURL { + return Env.sharesLocalSparkChain( + sparkURL: fixtureURL, + nodeElectrumURL: LightningService.shared.activeElectrumServerUrl, + hardwareElectrumURL: OnChainHwService.getElectrumUrl() + ) + } + return Self.readsBitkitChain(network: Env.network, chainServiceUrl: Env.sparkChainServiceUrl(for: Env.network)) } /// On mainnet both read Bitcoin; Spark's default regtest is its own chain, so a regtest deposit reaches Spark only diff --git a/Bitkit/Services/LightningService.swift b/Bitkit/Services/LightningService.swift index 95f2b79ef..ef5e1e1c4 100644 --- a/Bitkit/Services/LightningService.swift +++ b/Bitkit/Services/LightningService.swift @@ -106,7 +106,19 @@ protocol NodeLifecycleService: AnyObject { class LightningService: NodeLifecycleService { private static let watchOnlyAccountHighestPreRevealedAddressIndex: UInt32 = 999 - private var node: Node? + private var configuredNode: (node: Node, electrumServerUrl: String)? + private var node: Node? { + setupLock.withLock { configuredNode?.node } + } + + var activeElectrumServerUrl: String? { + setupLock.withLock { configuredNode?.electrumServerUrl } + } + + private func releaseNode() { + setupLock.withLock { configuredNode = nil } + } + private let beforeNodeStopLock = NSLock() private var beforeNodeStopAction: (() async -> Void)? /// Runs before the node stops, while its wallet can still release what was prepared on it. @@ -207,7 +219,7 @@ class LightningService: NodeLifecycleService { ) async throws { // Guard against concurrent setup calls let shouldProceed: Bool = setupLock.withLock { - guard !isSettingUp && node == nil else { + guard !isSettingUp && configuredNode == nil else { Logger.debug("Node already setting up or already set up, skipping") return false } @@ -295,12 +307,13 @@ class LightningService: NodeLifecycleService { } try await ServiceQueue.background(.ldk) { - self.node = try builder.buildWithVssStore( + let node = try builder.buildWithVssStore( vssUrl: vssUrl, storeId: storeId, lnurlAuthServerUrl: lnurlAuthServerUrl, fixedHeaders: [:] ) + self.setupLock.withLock { self.configuredNode = (node, resolvedElectrumServerUrl) } } shouldReleaseLightningLock = false @@ -321,7 +334,7 @@ class LightningService: NodeLifecycleService { } catch { Logger.debug("Node was already stopped or failed to stop: \(error)") // Clear the node reference anyway - node = nil + releaseNode() try? StateLocker.unlock(.lightning) } } @@ -356,7 +369,7 @@ class LightningService: NodeLifecycleService { try await stop() } catch { Logger.error("Failed to stop node during recovery: \(error)") - node = nil + releaseNode() try? StateLocker.unlock(.lightning) } } @@ -438,7 +451,7 @@ class LightningService: NodeLifecycleService { try await ServiceQueue.background(.ldk) { try Self.stopReleasingFinishedNode(node.stop) } - self.node = nil + releaseNode() if clearEventCallback { self.clearEventCallback() diff --git a/Bitkit/ViewModels/TransferViewModel.swift b/Bitkit/ViewModels/TransferViewModel.swift index bfef8b1a5..f9cbffd00 100644 --- a/Bitkit/ViewModels/TransferViewModel.swift +++ b/Bitkit/ViewModels/TransferViewModel.swift @@ -56,9 +56,7 @@ class TransferViewModel: ObservableObject { /// Sends Spark's balance to the address, refusing above the shown fee; tests replace it. var withdrawSpark: @MainActor (String, UInt64) async throws -> Void = { try await SparkManager.shared.withdrawAll(to: $0, maxFeeSats: $1) } /// Whether Spark reads Savings' chain, so its withdrawal reaches Savings; tests replace it. - var sparkReadsSavingsChain: @MainActor () -> Bool = { - SparkManager.readsBitkitChain(network: Env.network, chainServiceUrl: Env.sparkChainServiceUrl(for: Env.network)) - } + var sparkReadsSavingsChain: @MainActor () -> Bool = { SparkManager.shared.readsSavingsChain } /// How long the confirm screen waits for Spark's withdrawal fee before offering to retry; a full-balance quote can /// take minutes. diff --git a/BitkitTests/SparkConfigTests.swift b/BitkitTests/SparkConfigTests.swift index a6915ef50..d8b4f62fd 100644 --- a/BitkitTests/SparkConfigTests.swift +++ b/BitkitTests/SparkConfigTests.swift @@ -35,4 +35,18 @@ final class SparkConfigTests: XCTestCase { XCTAssertEqual(Env.sparkChainServiceUrl(for: .bitcoin, localRegtestURL: local, configuredURL: configured), "https://bitkit.to/electrs") XCTAssertEqual(Env.sparkChainServiceUrl(for: .signet, localRegtestURL: local, configuredURL: configured), configured) } + + func testLocalSparkSharesSavingsOnlyOnTheFixtureElectrumEndpoint() { + let spark = "http://127.0.0.1:23090/api" + let electrum = "tcp://127.0.0.1:60001" + func shares(_ sparkURL: String, _ node: String?, _ hardware: String) -> Bool { + Env.sharesLocalSparkChain(sparkURL: sparkURL, nodeElectrumURL: node, hardwareElectrumURL: hardware, fixtureHost: "127.0.0.1") + } + XCTAssertTrue(shares(spark, electrum, electrum)) + XCTAssertFalse(shares(spark, nil, electrum)) + XCTAssertFalse(shares(spark, "tcp://regtest.example:60001", electrum)) + XCTAssertFalse(shares(spark, electrum, "tcp://regtest.example:60001")) + XCTAssertFalse(shares(spark, "tcp://127.0.0.1:60002", electrum)) + XCTAssertFalse(shares("http://127.0.0.1:23091/api", electrum, electrum)) + } } From fe94c4a7c349b080ec5eaa988ed0332d8d55c5c5 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 15:30:45 +0100 Subject: [PATCH 21/25] ci: share the iOS regtest Compose project --- .github/workflows/e2e-local-nightly.yml | 3 ++- .github/workflows/e2e-tests.yml | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index f498908c5..027c991c2 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -141,7 +141,8 @@ jobs: runs-on: [self-hosted, macOS] timeout-minutes: 120 env: - COMPOSE_PROJECT_NAME: bitkit-spark-e2e + # The PR suite uses the same fixed Bitcoin and Electrum ports on this Mac. + COMPOSE_PROJECT_NAME: docker steps: - uses: actions/checkout@v7 with: diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 6f7e32974..ee2624841 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -323,7 +323,8 @@ jobs: run: | if [ -x ./scripts/local-backend ]; then ./scripts/local-backend prepare - ./scripts/local-backend down --remove-orphans -v -t 300 + # Include services left by an interrupted Spark nightly on this Mac. + COMPOSE_PROFILES=spark ./scripts/local-backend down --remove-orphans -v -t 300 ./scripts/local-backend up ./scripts/local-backend github-env >> "$GITHUB_ENV" else @@ -396,7 +397,7 @@ jobs: working-directory: bitkit-e2e-tests run: | if [ -x ./scripts/local-backend ]; then - ./scripts/local-backend down --remove-orphans -v || true + COMPOSE_PROFILES=spark ./scripts/local-backend down --remove-orphans -v || true else (cd docker && docker compose --profile trezor down --remove-orphans -v) || true fi From 0b5f8c69e20a0b3576175a07d2b8a6588b792f6d Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 20 Nov 2026 17:49:38 +0100 Subject: [PATCH 22/25] ci: retain iOS Spark logs before each retry --- .github/workflows/e2e-local-nightly.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index 027c991c2..e7e5070b5 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -228,6 +228,14 @@ jobs: RECORD_VIDEO: true ATTEMPT: 1 + - name: Collect Spark logs after attempt 1 + if: steps.test1.outcome == 'failure' + continue-on-error: true + working-directory: bitkit-e2e-tests + run: | + mkdir -p artifacts/attempt-1 + ./scripts/local-backend spark-logs --tail 200 > artifacts/attempt-1/spark-docker.log 2>&1 + - name: Run E2E tests (attempt 2) continue-on-error: true if: steps.test1.outcome != 'success' @@ -238,6 +246,14 @@ jobs: RECORD_VIDEO: true ATTEMPT: 2 + - name: Collect Spark logs after attempt 2 + if: steps.test2.outcome == 'failure' + continue-on-error: true + working-directory: bitkit-e2e-tests + run: | + mkdir -p artifacts/attempt-2 + ./scripts/local-backend spark-logs --tail 200 > artifacts/attempt-2/spark-docker.log 2>&1 + - name: Run E2E tests (attempt 3) if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success' id: test3 @@ -248,7 +264,7 @@ jobs: ATTEMPT: 3 - name: Collect Spark logs - if: failure() || steps.test1.outcome == 'failure' + if: failure() working-directory: bitkit-e2e-tests run: | mkdir -p artifacts From 2ad8013d58bf4fda3b10215e413a96c578c2159d Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Mon, 23 Nov 2026 12:05:41 +0100 Subject: [PATCH 23/25] Run self-hosted iOS E2E on iPhone 17 Pro --- .github/workflows/e2e-local-nightly.yml | 2 ++ .github/workflows/e2e-tests.yml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index e7e5070b5..660fcffc0 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -141,6 +141,8 @@ jobs: runs-on: [self-hosted, macOS] timeout-minutes: 120 env: + SIMULATOR_NAME: "iPhone 17 Pro" + SIMULATOR_OS_VERSION: "26.0.1" # The PR suite uses the same fixed Bitcoin and Electrum ports on this Mac. COMPOSE_PROJECT_NAME: docker steps: diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index ee2624841..dad4d0ce8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -231,6 +231,8 @@ jobs: runs-on: [self-hosted, macOS] needs: [detect-changes, build-local, e2e-branch] env: + SIMULATOR_NAME: "iPhone 17 Pro" + SIMULATOR_OS_VERSION: "26.0.1" # Reuse the legacy project so reset also clears containers left after a ref switch. COMPOSE_PROJECT_NAME: docker # Match the legacy fixture for the iOS manual channel funding Max case. @@ -352,7 +354,7 @@ jobs: - name: Clear iOS Simulator environment run: | xcrun simctl shutdown all || true - xcrun simctl erase "iPhone 17" || true + xcrun simctl erase "$SIMULATOR_NAME" || true defaults write com.apple.iphonesimulator DisableAllNotifications -bool true - name: Run E2E Tests 1 (${{ matrix.shard.name }}) From 763a19a2cb053d04869048f057c3eb99eaf56e70 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Mon, 23 Nov 2026 13:56:26 +0100 Subject: [PATCH 24/25] ci: run self-hosted iOS E2E on iOS 27.2 --- .github/workflows/e2e-local-nightly.yml | 4 ++-- .github/workflows/e2e-tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-local-nightly.yml b/.github/workflows/e2e-local-nightly.yml index 660fcffc0..c6bb7e443 100644 --- a/.github/workflows/e2e-local-nightly.yml +++ b/.github/workflows/e2e-local-nightly.yml @@ -141,8 +141,8 @@ jobs: runs-on: [self-hosted, macOS] timeout-minutes: 120 env: - SIMULATOR_NAME: "iPhone 17 Pro" - SIMULATOR_OS_VERSION: "26.0.1" + SIMULATOR_NAME: "iPhone 17" + SIMULATOR_OS_VERSION: "27.2" # The PR suite uses the same fixed Bitcoin and Electrum ports on this Mac. COMPOSE_PROJECT_NAME: docker steps: diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index dad4d0ce8..4ba1b1182 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -231,8 +231,8 @@ jobs: runs-on: [self-hosted, macOS] needs: [detect-changes, build-local, e2e-branch] env: - SIMULATOR_NAME: "iPhone 17 Pro" - SIMULATOR_OS_VERSION: "26.0.1" + SIMULATOR_NAME: "iPhone 17" + SIMULATOR_OS_VERSION: "27.2" # Reuse the legacy project so reset also clears containers left after a ref switch. COMPOSE_PROJECT_NAME: docker # Match the legacy fixture for the iOS manual channel funding Max case. From ee4dcdc5ce15b70046ba408dec1d0e54beab0993 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Tue, 24 Nov 2026 07:29:04 +0100 Subject: [PATCH 25/25] ci: rerun the native iOS PR checks