Skip to content

Commit ba00942

Browse files
committed
Wire up namespace and sccache for main CI path (ignoring publish-dry-run)
1 parent f4d7b32 commit ba00942

2 files changed

Lines changed: 106 additions & 26 deletions

File tree

.github/workflows/rust.yml

Lines changed: 59 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,42 @@ jobs:
1818
# changes to dependency specifications?
1919
# needs: [fmt, cackle, cargo-deny, check-git-rev-deps, build-and-test, publish-dry-run]
2020
needs: [fmt, cackle, cargo-deny, check-git-rev-deps, semver-checks, build-and-test]
21-
runs-on: ubuntu-latest
21+
runs-on:
22+
- namespace-profile-noble-24-04-stellar-core-x64-small
2223
steps:
2324
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
2425
run: exit 1
2526

2627
fmt:
27-
runs-on: ubuntu-latest
28+
runs-on:
29+
- namespace-profile-noble-24-04-stellar-core-x64-small
30+
permissions:
31+
contents: read
32+
id-token: write
2833
steps:
29-
- uses: actions/checkout@v3
34+
- uses: namespacelabs/nscloud-setup@v0
35+
- uses: namespacelabs/nscloud-checkout-action@v7
3036
- run: rustup update
3137
- run: cargo fmt --all --check
3238

3339
cackle:
34-
runs-on: ubuntu-latest
40+
runs-on:
41+
- namespace-profile-noble-24-04-stellar-core-x64-small
42+
permissions:
43+
contents: read
44+
id-token: write
3545
steps:
36-
- uses: actions/checkout@v3
46+
- uses: namespacelabs/nscloud-setup@v0
47+
- uses: namespacelabs/nscloud-checkout-action@v7
3748
- uses: cackle-rs/cackle-action@997327f77e59d9cda7b0b6217f0fbdbd3f3ca904
3849
- run: cargo acl -n run
3950

4051
cargo-deny:
41-
runs-on: ubuntu-latest
52+
runs-on:
53+
- namespace-profile-noble-24-04-stellar-core-x64-small
54+
permissions:
55+
contents: read
56+
id-token: write
4257
strategy:
4358
matrix:
4459
checks:
@@ -47,24 +62,35 @@ jobs:
4762
# Prevent sudden announcement of a new advisory from failing ci:
4863
continue-on-error: ${{ matrix.checks == 'advisories' }}
4964
steps:
50-
- uses: actions/checkout@v3
65+
- uses: namespacelabs/nscloud-setup@v0
66+
- uses: namespacelabs/nscloud-checkout-action@v7
5167
- uses: EmbarkStudios/cargo-deny-action@76cd80eb775d7bbbd2d80292136d74d39e1b4918
5268
with:
5369
command: check ${{ matrix.checks }}
5470

5571
check-git-rev-deps:
56-
runs-on: ubuntu-latest
72+
runs-on:
73+
- namespace-profile-noble-24-04-stellar-core-x64-small
74+
permissions:
75+
contents: read
76+
id-token: write
5777
steps:
58-
- uses: actions/checkout@v3
78+
- uses: namespacelabs/nscloud-setup@v0
79+
- uses: namespacelabs/nscloud-checkout-action@v7
5980
- uses: stellar/actions/rust-check-git-rev-deps@main
6081

6182
semver-checks:
6283
# When a PR enters the merge queue, the event context changes from pull_request to merge_group,
6384
# so github.event.pull_request becomes null/empty, so we don't do this check in the merge queue.
6485
if: "!contains( github.event.pull_request.labels.*.name, 'skip-semver-checks') && github.event_name != 'merge_group'"
65-
runs-on: ubuntu-latest
86+
runs-on:
87+
- namespace-profile-noble-24-04-stellar-core-x64-small
88+
permissions:
89+
contents: read
90+
id-token: write
6691
steps:
67-
- uses: actions/checkout@v3
92+
- uses: namespacelabs/nscloud-setup@v0
93+
- uses: namespacelabs/nscloud-checkout-action@v7
6894
- run: rustup update
6995
- uses: stellar/binaries@v52
7096
with:
@@ -73,37 +99,41 @@ jobs:
7399
- run: cargo semver-checks --exclude soroban-simulation
74100

75101
build-and-test:
102+
runs-on:
103+
- namespace-profile-noble-24-04-stellar-core-x64-large;overrides.cache-tag=config-${{ matrix.rust }}-${{ matrix.sys.target }}
104+
permissions:
105+
contents: read
106+
id-token: write
76107
strategy:
77108
matrix:
78109
rust: [msrv, latest]
79110
test-protocol: [26]
80111
sys:
81-
- os: ubuntu-latest
82-
target: wasm32-unknown-unknown
112+
- target: wasm32-unknown-unknown
83113
guest-only: false
84114
test: false
85-
- os: ubuntu-latest
86-
target: wasm32v1-none
115+
- target: wasm32v1-none
87116
guest-only: true
88117
test: false
89-
- os: ubuntu-latest-16-cores
90-
target: x86_64-unknown-linux-gnu
118+
- target: x86_64-unknown-linux-gnu
91119
guest-only: false
92120
test: true
93121
# TODO: Re-enable these builds if we see value in doing so.
94-
# - os: macos-latest
95-
# target: x86_64-apple-darwin
122+
# - target: x86_64-apple-darwin
96123
# test: true
97-
# - os: macos-latest
98-
# target: aarch64-apple-darwin
124+
# - target: aarch64-apple-darwin
99125
# test: false
100-
# - os: windows-latest
101-
# target: x86_64-pc-windows-msvc
126+
# - target: x86_64-pc-windows-msvc
102127
# test: true
103-
runs-on: ${{ matrix.sys.os }}
104128
steps:
105-
- uses: actions/checkout@v3
106-
- uses: stellar/actions/rust-cache@main
129+
- uses: namespacelabs/nscloud-setup@v0
130+
- uses: namespacelabs/nscloud-checkout-action@v7
131+
- uses: stellar/binaries@v52
132+
with:
133+
name: sccache
134+
version: 0.14.0
135+
- name: Configure sccache with Namespace cache
136+
run: source setup-sccache.sh
107137
- name: Use the minimum supported Rust version
108138
if: matrix.rust == 'msrv'
109139
run: |
@@ -125,6 +155,9 @@ jobs:
125155
run: cargo hack --each-feature test --profile test-opt --locked --target ${{ matrix.sys.target }}
126156
env:
127157
TEST_PROTOCOL: ${{ matrix.test-protocol }}
158+
- name: Show sccache stats
159+
if: always()
160+
run: sccache -s
128161

129162
publish-dry-run:
130163
if: github.event_name == 'push' || startsWith(github.head_ref, 'release/')

setup-sccache.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
# Setup sccache with Namespace remote cache.
3+
#
4+
# This script is designed to be _sourced_ (not executed) so that
5+
# environment variables are set in the caller's shell:
6+
#
7+
# source setup-sccache.sh
8+
#
9+
# It works in both CI (GitHub Actions) and local development.
10+
# Prerequisites: sccache and nsc must be on PATH.
11+
12+
set -e
13+
14+
# Check prerequisites
15+
for cmd in sccache nsc; do
16+
if ! command -v "$cmd" >/dev/null 2>&1; then
17+
echo "error: $cmd not found on PATH" >&2
18+
return 1 2>/dev/null || exit 1
19+
fi
20+
done
21+
22+
# Get credentials from Namespace cache
23+
eval "$(nsc cache sccache setup --cache_name stellar)"
24+
25+
# Export so the sccache daemon (and child processes) inherit them
26+
export SCCACHE_WEBDAV_ENDPOINT
27+
export SCCACHE_WEBDAV_KEY_PREFIX
28+
export SCCACHE_WEBDAV_TOKEN
29+
export SCCACHE_IDLE_TIMEOUT=0
30+
export RUSTC_WRAPPER=sccache
31+
32+
# In GitHub Actions, propagate to subsequent steps and mask the token
33+
if [ -n "$GITHUB_ENV" ]; then
34+
echo "::add-mask::$SCCACHE_WEBDAV_TOKEN"
35+
echo "SCCACHE_WEBDAV_ENDPOINT=$SCCACHE_WEBDAV_ENDPOINT" >> "$GITHUB_ENV"
36+
echo "SCCACHE_WEBDAV_KEY_PREFIX=$SCCACHE_WEBDAV_KEY_PREFIX" >> "$GITHUB_ENV"
37+
echo "SCCACHE_WEBDAV_TOKEN=$SCCACHE_WEBDAV_TOKEN" >> "$GITHUB_ENV"
38+
echo "SCCACHE_IDLE_TIMEOUT=0" >> "$GITHUB_ENV"
39+
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
40+
fi
41+
42+
# (Re)start the sccache daemon with the correct environment
43+
sccache --stop-server 2>/dev/null || true
44+
sccache --start-server
45+
46+
echo "sccache configured with Namespace remote cache:"
47+
sccache -s

0 commit comments

Comments
 (0)