Skip to content

Commit 28077a0

Browse files
committed
ci: add deps caching
1 parent 92bfdcc commit 28077a0

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

.github/actions/deps/action.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: deps
2+
description: 'Build and cache dependencies'
3+
inputs:
4+
deps-script-path:
5+
description: 'Path of deps.sh script'
6+
required: true
7+
default: './deps.sh'
8+
deps-bundle-path:
9+
description: 'Path of deps-bundle.sh script'
10+
required: true
11+
default: './scripts/deps-bundle.sh'
12+
outputs: {}
13+
runs:
14+
using: composite
15+
steps:
16+
- id: deps-sh-hash
17+
shell: bash
18+
run: sha256sum '${{ inputs.deps-script-path }}' | awk '{print "HASH=" $1}' >> "$GITHUB_OUTPUT"
19+
20+
# TODO: Remove runner.name from cache key once both boxes are on RHEL9
21+
- id: deps-sh-cache
22+
uses: actions/cache@v4
23+
with:
24+
path: deps-bundle.tar.zst
25+
key: ${{ runner.os }}-${{ runner.name }}-deps-sh-${{ steps.deps-sh-hash.outputs.HASH }}
26+
27+
- name: Install dependencies from cache
28+
shell: bash
29+
run: tar -Izstd -xvf deps-bundle.tar.zst
30+
if: steps.deps-sh-cache.outputs.cache-hit == 'true'
31+
32+
- name: Install dependencies from scratch
33+
shell: bash
34+
run: |
35+
'${{ inputs.deps-script-path }}'
36+
'${{ inputs.deps-bundle-path }}'
37+
38+
if: steps.deps-sh-cache.outputs.cache-hit != 'true'

.github/workflows/build-common.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@ jobs:
2020
- uses: actions/checkout@v4
2121
with:
2222
submodules: recursive
23+
2324
# TODO: change back to stable once rust releases the coverage fix
2425
# - uses: dtolnay/[email protected]
2526
- uses: actions-rs/toolchain@v1
2627
with:
2728
toolchain: nightly-2025-10-30
2829
override: true
2930
components: "clippy, rustfmt"
31+
3032
- uses: Swatinem/rust-cache@v2
3133
with:
3234
cache-all-crates: true # we do this because we have a crapload of crates used for testing/CI
3335

34-
- name: Install dependencies
35-
run: ./deps.sh
36+
- uses: ./.github/actions/deps
3637

3738
- name: Check lints and clippy
3839
run: |
@@ -87,19 +88,20 @@ jobs:
8788
- uses: actions/checkout@v4
8889
with:
8990
submodules: recursive
91+
9092
# TODO: change back to stable once rust releases the coverage fix
9193
# - uses: dtolnay/[email protected]
9294
- uses: actions-rs/toolchain@v1
9395
with:
9496
toolchain: nightly-2025-10-30
9597
override: true
9698
components: "clippy, rustfmt"
99+
97100
- uses: Swatinem/rust-cache@v2
98101
with:
99102
cache-all-crates: true # we do this because we have a crapload of crates used for testing/CI
100103

101-
- name: Install dependencies
102-
run: ./deps.sh
104+
- uses: ./.github/actions/deps
103105

104106
- name: check out test-vectors (persistent)
105107
run: |

scripts/deps-bundle.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# deps-bundle.sh pack a redistributable bundle of build dependencies.
6+
#
7+
# This offers an alternative to building dependencies from source,
8+
# such that only a recent compiler and linker is required (and no other
9+
# tools like perl or bison). Also requires the Zstandard compression
10+
# tool and GNU tar.
11+
#
12+
# To start, first create the a dependency prefix at ./opt using deps.sh.
13+
# Then, run this script to create deps-bundle.tar.zst which contains
14+
# only static libraries and binaries.
15+
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/..
16+
rm -f deps-bundle.tar.zst
17+
tar -Izstd -cf deps-bundle.tar.zst ./opt/{bin,lib}
18+
echo "[+] Created deps-bundle.tar.zst"

0 commit comments

Comments
 (0)