]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Enable caching for `bitcoind`/`electrs` in CI
authorElias Rohrer <dev@tnull.de>
Thu, 1 Aug 2024 15:47:45 +0000 (10:47 -0500)
committerElias Rohrer <dev@tnull.de>
Tue, 13 Aug 2024 13:02:46 +0000 (15:02 +0200)
.github/workflows/build.yml
ci/ci-tests.sh

index d6d910656ace11dc8b4cfe33abb8c90b3dc38655..d15932b5cdbddc9b0ba56efd6009ba6f591a14d1 100644 (file)
@@ -41,6 +41,29 @@ jobs:
       - name: Set RUSTFLAGS to deny warnings
         if: "matrix.toolchain == '1.63.0'"
         run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
+      - name: Enable caching for bitcoind
+        id: cache-bitcoind
+        uses: actions/cache@v4
+        with:
+          path: bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
+          key: bitcoind-${{ runner.os }}-${{ runner.arch }}
+      - name: Enable caching for electrs
+        id: cache-electrs
+        uses: actions/cache@v4
+        with:
+          path: bin/electrs-${{ runner.os }}-${{ runner.arch }}
+          key: electrs-${{ runner.os }}-${{ runner.arch }}
+      - name: Download bitcoind/electrs
+        if: "matrix.platform != 'windows-latest' && (steps.cache-bitcoind.outputs.cache-hit != 'true' || steps.cache-electrs.outputs.cache-hit != 'true')"
+        run: |
+            source ./contrib/download_bitcoind_electrs.sh
+            mkdir bin
+            mv "$BITCOIND_EXE" bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
+            mv "$ELECTRS_EXE" bin/electrs-${{ runner.os }}-${{ runner.arch }}
+      - name: Set bitcoind/electrs environment variables
+        run: |
+            echo "BITCOIND_EXE=$( pwd )/bin/bitcoind-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
+            echo "ELECTRS_EXE=$( pwd )/bin/electrs-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
       - name: Run CI script
         shell: bash # Default on Winblows is powershell
         run: CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh
index bc5b74d38cacdb872459d3d0e9f5909cfeb9f952..74bf427d6139d13efd5abdb87d500a80160b21b1 100755 (executable)
@@ -3,7 +3,6 @@ set -eox pipefail
 
 RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
 HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
-CONTRIB_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )/../contrib" && pwd )
 
 # Some crates require pinning to meet our MSRV even for our downstream users,
 # which we do here.
@@ -45,20 +44,22 @@ cargo check --verbose --color always --features rpc-client,rest-client,tokio
 popd
 
 if [[ "$HOST_PLATFORM" != *windows* ]]; then
-       echo -e "\n\nBuilding and testing Transaction Sync Clients with features"
-       pushd lightning-transaction-sync
-
-       source "$CONTRIB_DIR/download_bitcoind_electrs.sh"
-
-       cargo test --verbose --color always --features esplora-blocking
-       cargo check --verbose --color always --features esplora-blocking
-       cargo test --verbose --color always --features esplora-async
-       cargo check --verbose --color always --features esplora-async
-       cargo test --verbose --color always --features esplora-async-https
-       cargo check --verbose --color always --features esplora-async-https
-       cargo test --verbose --color always --features electrum
-       cargo check --verbose --color always --features electrum
-       popd
+       if [ -z "$BITCOIND_EXE" ] || [ -z "$ELECTRS_EXE" ]; then
+               echo -e "\n\nSkipping testing Transaction Sync Clients due to BITCOIND_EXE or ELECTRS_EXE being unset."
+       else
+               echo -e "\n\nBuilding and testing Transaction Sync Clients with features"
+               pushd lightning-transaction-sync
+
+               cargo test --verbose --color always --features esplora-blocking
+               cargo check --verbose --color always --features esplora-blocking
+               cargo test --verbose --color always --features esplora-async
+               cargo check --verbose --color always --features esplora-async
+               cargo test --verbose --color always --features esplora-async-https
+               cargo check --verbose --color always --features esplora-async-https
+               cargo test --verbose --color always --features electrum
+               cargo check --verbose --color always --features electrum
+               popd
+       fi
 fi
 
 echo -e "\n\nTest futures builds"