Skip to content

Commit 3c5b4b9

Browse files
authored
Merge pull request #2 from LayerTwo-Labs/2026-07-09-backport-thunder-0.16.1
Backport Thunder 0.16.1
2 parents 03c3bb7 + d233306 commit 3c5b4b9

19 files changed

Lines changed: 603 additions & 153 deletions

.github/workflows/check_lint_build.yaml

Lines changed: 99 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,25 @@ on:
77
tags:
88
- '*'
99
workflow_dispatch:
10+
inputs:
11+
base_branch:
12+
description: "Base branch to diff against (only used when cargo_deny_check=auto)"
13+
type: string
14+
default: master
15+
cargo_deny_check:
16+
description: "Run or skip the `cargo deny` step"
17+
type: choice
18+
options:
19+
- auto
20+
- force-run
21+
- force-skip
22+
default: auto
1023

1124
name: Check, Lint, Build
1225

1326
env:
1427
CARGO_TERM_COLOR: always
28+
ELECTRS_VERSION: v3.2.0
1529

1630
jobs:
1731
check-lint:
@@ -28,27 +42,83 @@ jobs:
2842
toolchain: nightly
2943
components: rustfmt, clippy
3044

31-
- name: Rust Cache
45+
- name: Restore Rust cache
46+
id: restore-rust-cache
47+
uses: Swatinem/rust-cache@v2.9.1
48+
with:
49+
cache-all-crates: "true"
50+
prefix-key: "v0-rust-nightly"
51+
save-if: "false"
52+
shared-key: release-x86_64-unknown-linux-gnu
53+
54+
- name: Save Rust cache
55+
if: steps.restore-rust-cache.outputs.cache-hit != 'true'
3256
uses: Swatinem/rust-cache@v2.9.1
3357
with:
34-
shared-key: x86_64-unknown-linux-gnu
58+
cache-all-crates: "true"
59+
lookup-only: "true"
60+
prefix-key: "v0-rust-nightly"
61+
shared-key: release-x86_64-unknown-linux-gnu
3562

3663
- name: Rustfmt
3764
run: cargo fmt --all -- --check
3865

3966
- name: Cargo check
40-
run: cargo check --all-targets --all-features
67+
run: cargo check --release --all-targets --all-features
4168

4269
- name: Clippy
43-
run: cargo clippy --all-targets --all-features
70+
run: cargo clippy --release --all-targets --all-features
4471

72+
- name: Check changed files
73+
id: changed-files
74+
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.cargo_deny_check == 'auto')
75+
uses: dorny/paths-filter@v4
76+
with:
77+
filters: |
78+
cargo_lock:
79+
- 'Cargo.lock'
80+
deny_toml:
81+
- 'deny.toml'
82+
4583
- name: Deny
84+
if: >-
85+
(github.event_name == 'pull_request' && (steps.changed-files.outputs.cargo_lock == 'true' || steps.changed-files.outputs.deny_toml == 'true')) ||
86+
(github.event_name == 'workflow_dispatch' && inputs.cargo_deny_check == 'force-run') ||
87+
(github.event_name == 'workflow_dispatch' && inputs.cargo_deny_check == 'auto' && (steps.changed-files.outputs.cargo_lock == 'true' || steps.changed-files.outputs.deny_toml == 'true'))
4688
uses: EmbarkStudios/cargo-deny-action@v2
4789

90+
cache-electrs:
91+
name: Build electrs if not cached
92+
runs-on: ubuntu-latest
93+
steps:
94+
- name: Check cache
95+
id: check-cache
96+
uses: actions/cache/restore@v6
97+
with:
98+
lookup-only: true
99+
path: ${{ runner.temp }}/electrs/target/release/electrs
100+
key: electrs-${{ env.ELECTRS_VERSION }}
101+
102+
- name: Build electrs
103+
if: steps.check-cache.outputs.cache-hit != 'true'
104+
run: |
105+
git clone --branch ${{ env.ELECTRS_VERSION }} --depth 1 https://github.com/mempool/electrs.git ${{ runner.temp }}/electrs
106+
pushd ${{ runner.temp }}/electrs
107+
cargo build --locked --release
108+
popd
109+
110+
- name: Save cache
111+
if: steps.check-cache.outputs.cache-hit != 'true'
112+
uses: actions/cache/save@v6
113+
with:
114+
path: ${{ runner.temp }}/electrs/target/release/electrs
115+
key: electrs-${{ env.ELECTRS_VERSION }}
116+
117+
48118
integration-test:
49119
name: Integration test
50120
runs-on: ubuntu-latest
51-
needs: [check-lint]
121+
needs: [cache-electrs, check-lint]
52122
steps:
53123
- name: Download latest bitcoin-patched
54124
run: |
@@ -82,41 +152,31 @@ jobs:
82152
chmod +x bip300301-enforcer
83153
popd
84154
85-
- name: Checkout electrs
86-
run: |
87-
pushd ..
88-
git clone https://github.com/mempool/electrs.git
89-
popd
90-
91-
- name: Install latest nightly toolchain
92-
uses: dtolnay/rust-toolchain@master
93-
with:
94-
toolchain: nightly
95-
target: x86_64-pc-windows-gnu
96-
97-
- name: Rust Cache (electrs)
98-
uses: Swatinem/rust-cache@v2.9.1
155+
- name: Restore electrs from cache
156+
uses: actions/cache/restore@v6
99157
with:
100-
prefix-key: "v0-rust-electrs"
101-
workspaces: ../electrs -> target
102-
103-
- name: Install electrs
104-
run: |
105-
pushd ../electrs
106-
cargo build --locked --release
107-
popd
158+
fail-on-cache-miss: true
159+
path: ${{ runner.temp }}/electrs/target/release/electrs
160+
key: electrs-${{ env.ELECTRS_VERSION }}
108161

109162
- uses: actions/checkout@v6
110163
with:
111164
submodules: "recursive"
112165

166+
- name: Install latest nightly toolchain
167+
uses: dtolnay/rust-toolchain@master
168+
with:
169+
toolchain: nightly
170+
113171
- name: Rust Cache
114172
uses: Swatinem/rust-cache@v2.9.1
115173
with:
116-
shared-key: x86_64-unknown-linux-gnu
174+
cache-all-crates: "true"
175+
prefix-key: "v0-rust-nightly"
176+
shared-key: release-x86_64-unknown-linux-gnu
117177

118178
- name: Build (release)
119-
run: cargo build --release
179+
run: cargo build --release --bin photon_app --example integration_tests
120180

121181
- name: Run integration tests
122182
id: runIntegrationTests
@@ -125,9 +185,9 @@ jobs:
125185
export BITCOIND='../bitcoin-patched-bins/bitcoind'
126186
export BITCOIND_UNPATCHED='../bitcoin-unpatched-bins/bitcoind'
127187
export BITCOIN_CLI='../bitcoin-patched-bins/bitcoin-cli'
128-
export ELECTRS='../electrs/target/release/electrs'
188+
export ELECTRS='${{ runner.temp }}/electrs/target/release/electrs'
129189
export PHOTON_APP='target/release/photon_app'
130-
cargo run --release --example integration_tests
190+
target/release/examples/integration_tests
131191
132192
test-build-release:
133193
strategy:
@@ -156,6 +216,10 @@ jobs:
156216
contents: write
157217
timeout-minutes: 20
158218
steps:
219+
- name: Install windows-specific deps
220+
run: sudo apt install mingw-w64
221+
if: ${{ matrix.name == 'x86_64-pc-windows-gnu' }}
222+
159223
- uses: actions/checkout@v6
160224
with:
161225
submodules: recursive
@@ -169,11 +233,9 @@ jobs:
169233
- name: Rust Cache
170234
uses: Swatinem/rust-cache@v2.9.1
171235
with:
172-
key: ${{ matrix.name }}
173-
174-
- name: Install windows-specific deps
175-
run: sudo apt install mingw-w64
176-
if: ${{ matrix.name == 'x86_64-pc-windows-gnu' }}
236+
cache-all-crates: "true"
237+
prefix-key: "v0-rust-nightly"
238+
shared-key: ${{ matrix.name }}
177239

178240
- name: Test
179241
run: cargo test --tests
@@ -294,4 +356,4 @@ jobs:
294356
password: ${{ secrets.RELEASES_SERVER_PW }}
295357
port: 22
296358
source: 'L2-S99-Photon-latest-*.zip'
297-
target: '/var/www/html/'
359+
target: '/var/www/html/'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Evict GitHub actions caches for closed/merged PR branches
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
workflow_dispatch:
7+
8+
jobs:
9+
cleanup:
10+
permissions:
11+
actions: write
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Cleanup
15+
env:
16+
GH_TOKEN: ${{ github.token }}
17+
GH_REPO: ${{ github.repository }}
18+
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
19+
run: |
20+
echo "Fetching list of cache keys"
21+
BRANCH_CACHE_KEYS=$(gh cache list --ref $BRANCH --json id --jq '.[].id')
22+
23+
## Setting this to not fail the workflow while deleting cache keys.
24+
set +e
25+
echo "Deleting caches..."
26+
for CACHE_KEY in $BRANCH_CACHE_KEYS
27+
do
28+
echo "Deleting cache ${CACHE_KEY}"
29+
gh cache delete $CACHE_KEY
30+
done
31+
echo "Done"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Evict stale nightly Rust caches
2+
on:
3+
schedule:
4+
# every 12 hours
5+
- cron: "0 */12 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
cleanup:
10+
permissions:
11+
actions: write
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Delete nightly Rust caches older than 48h
15+
env:
16+
GH_TOKEN: ${{ github.token }}
17+
REPO: ${{ github.repository }}
18+
run: |
19+
CUTOFF=$(date -u -d '48 hours ago' +%s)
20+
21+
CACHE_IDS=$(gh cache list --repo "$REPO" --limit 500 \
22+
--json id,key,createdAt |
23+
jq -r --argjson cutoff "$CUTOFF" \
24+
'.[] | select(.key | startswith("v0-rust-nightly"))
25+
| select((.createdAt | sub("\\.[0-9]+"; "") | fromdateiso8601) < $cutoff)
26+
| .id')
27+
28+
for CACHE_ID in $CACHE_IDS; do
29+
echo "Deleting cache $CACHE_ID"
30+
gh cache delete "$CACHE_ID" --repo "$REPO"
31+
done

0 commit comments

Comments
 (0)