@@ -25,6 +25,7 @@ name: Check, Lint, Build
2525
2626env :
2727 CARGO_TERM_COLOR : always
28+ ELECTRS_VERSION : v3.2.0
2829
2930jobs :
3031 check-lint :
4445 - name : Rust Cache
4546 uses : Swatinem/rust-cache@v2.9.1
4647 with :
48+ cache-all-crates : true
4749 cache-bin : false
48- shared-key : x86_64-unknown-linux-gnu
50+ prefix-key : " v0-rust-nightly"
51+ shared-key : debug-x86_64-unknown-linux-gnu
4952
5053 - name : Rustfmt
5154 run : cargo fmt --all -- --check
@@ -74,10 +77,38 @@ jobs:
7477 (github.event_name == 'workflow_dispatch' && inputs.cargo_deny_check == 'auto' && (steps.changed-files.outputs.cargo_lock == 'true' || steps.changed-files.outputs.deny_toml == 'true'))
7578 uses : EmbarkStudios/cargo-deny-action@v2
7679
80+ cache-electrs :
81+ name : Build electrs if not cached
82+ runs-on : ubuntu-latest
83+ steps :
84+ - name : Check cache
85+ id : check-cache
86+ uses : actions/cache/restore@v6
87+ with :
88+ lookup-only : true
89+ path : ${{ runner.temp }}/electrs/target/release/electrs
90+ key : electrs-${{ env.ELECTRS_VERSION }}
91+
92+ - name : Build electrs
93+ if : steps.check-cache.outputs.cache-hit != 'true'
94+ run : |
95+ git clone --branch ${{ env.ELECTRS_VERSION }} --depth 1 https://github.com/mempool/electrs.git ${{ runner.temp }}/electrs
96+ pushd ${{ runner.temp }}/electrs
97+ cargo build --locked --release
98+ popd
99+
100+ - name : Save cache
101+ if : steps.check-cache.outputs.cache-hit != 'true'
102+ uses : actions/cache/save@v6
103+ with :
104+ path : ${{ runner.temp }}/electrs/target/release/electrs
105+ key : electrs-${{ env.ELECTRS_VERSION }}
106+
107+
77108 integration-test :
78109 name : Integration test
79110 runs-on : ubuntu-latest
80- needs : [check-lint]
111+ needs : [cache-electrs, check-lint]
81112 steps :
82113 - name : Download latest bitcoin-patched
83114 run : |
@@ -111,40 +142,30 @@ jobs:
111142 chmod +x bip300301-enforcer
112143 popd
113144
114- - name : Checkout electrs
115- run : |
116- pushd ..
117- git clone https://github.com/mempool/electrs.git
118- popd
119-
120- - name : Install latest nightly toolchain
121- uses : dtolnay/rust-toolchain@master
145+ - name : Restore electrs from cache
146+ uses : actions/cache/restore@v6
122147 with :
123- toolchain : nightly
124- target : x86_64-pc-windows-gnu
125-
126- - name : Rust Cache (electrs)
127- uses : Swatinem/rust-cache@v2.9.1
128- with :
129- cache-bin : false
130- prefix-key : " v0-rust-electrs"
131- workspaces : ../electrs -> target
132-
133- - name : Install electrs
134- run : |
135- pushd ../electrs
136- cargo build --locked --release
137- popd
148+ fail-on-cache-miss : true
149+ path : ${{ runner.temp }}/electrs/target/release/electrs
150+ key : electrs-${{ env.ELECTRS_VERSION }}
138151
139152 - uses : actions/checkout@v6
140153 with :
141154 submodules : " recursive"
142155
156+ - name : Install latest nightly toolchain
157+ uses : dtolnay/rust-toolchain@master
158+ with :
159+ toolchain : nightly
160+
143161 - name : Rust Cache
144162 uses : Swatinem/rust-cache@v2.9.1
145163 with :
164+ cache-all-crates : true
146165 cache-bin : false
147- shared-key : x86_64-unknown-linux-gnu
166+ prefix-key : " v0-rust-nightly"
167+ save-if : false
168+ shared-key : debug-x86_64-unknown-linux-gnu
148169
149170 - name : Build (debug)
150171 run : cargo build
@@ -156,7 +177,7 @@ jobs:
156177 export BITCOIND='../bitcoin-patched-bins/bitcoind'
157178 export BITCOIND_UNPATCHED='../bitcoin-unpatched-bins/bitcoind'
158179 export BITCOIN_CLI='../bitcoin-patched-bins/bitcoin-cli'
159- export ELECTRS='.. /electrs/target/release/electrs'
180+ export ELECTRS='${{ runner.temp }} /electrs/target/release/electrs'
160181 export THUNDER_APP='target/debug/thunder_app'
161182 cargo run --example integration_tests
162183
@@ -187,6 +208,10 @@ jobs:
187208 contents : write
188209 timeout-minutes : 20
189210 steps :
211+ - name : Install windows-specific deps
212+ run : sudo apt install mingw-w64
213+ if : ${{ matrix.name == 'x86_64-pc-windows-gnu' }}
214+
190215 - uses : actions/checkout@v6
191216 with :
192217 submodules : recursive
@@ -200,12 +225,10 @@ jobs:
200225 - name : Rust Cache
201226 uses : Swatinem/rust-cache@v2.9.1
202227 with :
228+ cache-all-crates : true
203229 cache-bin : false
204- key : ${{ matrix.name }}
205-
206- - name : Install windows-specific deps
207- run : sudo apt install mingw-w64
208- if : ${{ matrix.name == 'x86_64-pc-windows-gnu' }}
230+ prefix-key : " v0-rust-nightly"
231+ shared-key : ${{ matrix.name }}
209232
210233 - name : Test
211234 run : cargo test --tests
0 commit comments