Skip to content

Commit de9c193

Browse files
authored
Namespace runners (#4988)
This switches our CI to work on runners provided by namespace.so. It's a little larger and more involved than I wanted because namespace's caching system works differently than github's, and requires support for out-of-tree builds. On the other hand, the resulting configuration is simpler overall, and apparently everyone wanted out-of-tree builds anyways, and the runners seem to be faster and cheaper than github's runners. So I'm proposing we give it a try!
2 parents b1bd05e + 068193d commit de9c193

File tree

16 files changed

+215
-169
lines changed

16 files changed

+215
-169
lines changed

.github/workflows/build.yml

Lines changed: 99 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,31 @@ jobs:
1818

1919
complete:
2020
if: always()
21-
needs: [fmt, cargo-deny, rust-check-git-rev-deps, build]
22-
runs-on: ubuntu-22.04
21+
needs: [fmt, cargo-deny, rust-check-git-rev-deps, build-linux, build-mac]
22+
runs-on:
23+
- namespace-profile-jammy-1-stellar-core
24+
- nscloud-cache-exp-do-not-commit
2325
steps:
2426
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
2527
run: exit 1
2628

2729
fmt:
28-
runs-on: ubuntu-22.04
30+
runs-on:
31+
- namespace-profile-jammy-1-stellar-core
32+
- nscloud-cache-exp-do-not-commit
2933
steps:
30-
- uses: actions/checkout@v4
31-
- run: rustup component add rustfmt
32-
- run: rustup update
33-
- run: cargo fmt --all --check
34+
- uses: namespacelabs/nscloud-checkout-action@v7
35+
with:
36+
fetch-depth: 1
37+
submodules: recursive
38+
- run: rustup component add rustfmt
39+
- run: rustup update
40+
- run: cargo fmt --all --check
3441

3542
cargo-deny:
36-
runs-on: ubuntu-22.04
43+
runs-on:
44+
- namespace-profile-jammy-1-stellar-core
45+
- nscloud-cache-exp-do-not-commit
3746
strategy:
3847
matrix:
3948
checks:
@@ -42,27 +51,31 @@ jobs:
4251
# Prevent sudden announcement of a new advisory from failing ci:
4352
continue-on-error: ${{ matrix.checks == 'advisories' }}
4453
steps:
45-
- uses: actions/checkout@v4
46-
- uses: EmbarkStudios/cargo-deny-action@8d73959fce1cdc8989f23fdf03bec6ae6a6576ef
47-
with:
48-
command: check ${{ matrix.checks }}
49-
# leave arguments empty so we don't test --all-features
50-
# which will see conflicting env versions
51-
arguments:
54+
- uses: namespacelabs/nscloud-checkout-action@v7
55+
with:
56+
fetch-depth: 1
57+
submodules: recursive
58+
- uses: EmbarkStudios/cargo-deny-action@8d73959fce1cdc8989f23fdf03bec6ae6a6576ef
59+
with:
60+
command: check ${{ matrix.checks }}
61+
# leave arguments empty so we don't test --all-features
62+
# which will see conflicting env versions
63+
arguments:
5264

5365
rust-check-git-rev-deps:
54-
runs-on: ubuntu-22.04
66+
runs-on:
67+
- namespace-profile-jammy-1-stellar-core
68+
- nscloud-cache-exp-do-not-commit
5569
steps:
56-
- uses: actions/checkout@v4
57-
- uses: stellar/actions/rust-check-git-rev-deps@main
58-
59-
build:
60-
runs-on: ubuntu-jammy-16-cores-amd64
61-
env:
62-
CACHED_PATHS: |
63-
~/.ccache
64-
~/.cargo
65-
target
70+
- uses: namespacelabs/nscloud-checkout-action@v7
71+
with:
72+
fetch-depth: 1
73+
submodules: recursive
74+
- uses: stellar/actions/rust-check-git-rev-deps@main
75+
76+
build-linux:
77+
runs-on:
78+
- namespace-profile-jammy-32-stellar-core;overrides.cache-tag=config-${{ matrix.toolchain }}-${{ matrix.protocol }}
6679
strategy:
6780
fail-fast: false
6881
matrix:
@@ -75,66 +88,32 @@ jobs:
7588
# using leading to random crashes: https://reviews.llvm.org/D148280
7689
run: sudo sysctl vm.mmap_rnd_bits=28
7790

78-
# We start with as cheap as possible a cache probe to see if we have an exact hit on this
79-
# git commit ID (for a given OS/toolchain/protocol). If so we can skip all subsequent
80-
# steps: we already tested this exact SHA.
81-
#
82-
# Unfortunately due to the way github actions control flow works, we have to repeat the
83-
# step 'if' condition in each step, and cannot actually "exit early" and skip the job.
84-
# There are a lot of duplicate bug reports filed on this aspect of github actions, don't
85-
# bother filing another.
86-
- name: Probe Cache
87-
id: cache
88-
uses: actions/cache/restore@v4
91+
- name: Checkout with Namespace Git mirrors cache
92+
uses: namespacelabs/nscloud-checkout-action@v7
8993
with:
90-
path: ${{ env.CACHED_PATHS }}
91-
key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.protocol }}-${{ github.sha }}
92-
lookup-only: true
93-
94-
# When we have a cache miss on the exact commit SHA, we restore from the prefix without it.
95-
# This will restore the most-recently-written cache (github does this date ordering itself).
96-
- name: Restore Cache
97-
if: steps.cache.outputs.cache-hit != 'true'
98-
uses: actions/cache/restore@v4
99-
with:
100-
path: ${{ env.CACHED_PATHS }}
101-
key: ${{ steps.cache.outputs.cache-primary-key }}
102-
restore-keys: |
103-
${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.protocol }}
94+
fetch-depth: 1
95+
submodules: recursive
10496

105-
- uses: actions/checkout@v4
106-
if: steps.cache.outputs.cache-hit != 'true'
97+
- name: Configure Namespace cache volume
98+
uses: namespacelabs/nscloud-cache-action@v1
10799
with:
108-
fetch-depth: 200
109-
submodules: true
110-
- name: install core packages
111-
if: steps.cache.outputs.cache-hit != 'true'
112-
run: |
113-
sudo apt-get update
114-
sudo apt-get -y install --no-install-recommends apt-utils dialog git iproute2 procps lsb-release
115-
- name: install tool chain
116-
if: steps.cache.outputs.cache-hit != 'true'
117-
run: |
118-
sudo apt-get -y install libstdc++-10-dev clang-format-12 ccache lldb
119-
if test "${{ matrix.toolchain }}" = "gcc" ; then
120-
sudo apt-get -y install cpp-10 gcc-10 g++-10
121-
else
122-
sudo apt-get -y install clang-12 llvm-12
123-
fi
100+
path: |
101+
~/.cargo
102+
build-${{matrix.toolchain}}-${{matrix.protocol}}
103+
104+
- name: install rustup
105+
run: ./install-rust.sh
106+
124107
- name: install rustup components
125-
if: steps.cache.outputs.cache-hit != 'true'
126108
run: rustup component add rustfmt
109+
127110
- name: install cargo-cache
128-
if: steps.cache.outputs.cache-hit != 'true'
129111
run: cargo install --locked cargo-cache --version 0.8.3
112+
130113
- name: install cargo-sweep
131-
if: steps.cache.outputs.cache-hit != 'true'
132114
run: cargo install --locked cargo-sweep --version 0.7.0
133-
- name: install dependencies
134-
if: steps.cache.outputs.cache-hit != 'true'
135-
run: sudo apt-get -y install postgresql git build-essential pkg-config autoconf automake libtool bison flex libpq-dev parallel libunwind-dev sed perl
115+
136116
- name: Build
137-
if: steps.cache.outputs.cache-hit != 'true'
138117
run: |
139118
if test "${{ matrix.toolchain }}" = "gcc" ; then
140119
export CC='gcc'
@@ -144,26 +123,52 @@ jobs:
144123
export CXX='clang++'
145124
fi
146125
echo Build with $CC and $CXX
147-
echo "Running first scenario"
148126
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }}
149127
150-
# We only _save_ to the cache when we had a cache miss and are running on master.
151-
- name: Save cache after first build
152-
uses: actions/cache/save@v4
153-
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.ref_name == 'master' }}
128+
build-mac:
129+
runs-on:
130+
- namespace-profile-macos-sequoia;overrides.cache-tag=config-macos-sequoia
131+
steps:
132+
133+
- name: Checkout with Namespace Git mirrors cache
134+
uses: namespacelabs/nscloud-checkout-action@v7
135+
with:
136+
fetch-depth: 1
137+
submodules: recursive
138+
139+
- name: Configure Namespace cache volume
140+
uses: namespacelabs/nscloud-cache-action@v1
154141
with:
155-
path: ${{ env.CACHED_PATHS }}
156-
key: ${{ steps.cache.outputs.cache-primary-key }}
142+
path: |
143+
~/.cargo
144+
build-clang-current
157145
158-
- name: Build for check-test-tx-meta scenario
159-
if: steps.cache.outputs.cache-hit != 'true'
146+
- name: install prerequisites and uninstall brew rust, add rustup
160147
run: |
161-
if test "${{ matrix.toolchain }}" = "gcc" ; then
162-
export CC='gcc'
163-
export CXX='g++'
164-
else
165-
export CC='clang'
166-
export CXX='clang++'
167-
fi
168-
echo "Running second scenario with --check-test-tx-meta flag"
169-
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }} --check-test-tx-meta
148+
brew install libsodium libtool autoconf automake pkg-config libpq openssl parallel ccache bison gnu-sed perl coreutils
149+
brew uninstall rust rustup
150+
brew install rustup
151+
152+
- name: install rustup components
153+
run: |
154+
rustup-init -y
155+
rustup component add rustfmt rustc cargo clippy rust-src rust-std
156+
157+
- name: install cargo-cache
158+
run: |
159+
cargo install --locked cargo-cache --version 0.8.3
160+
161+
- name: install cargo-sweep
162+
run: |
163+
cargo install --locked cargo-sweep --version 0.7.0
164+
165+
- name: Build
166+
run: |
167+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix)/opt/libpq/lib/pkgconfig"
168+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix)/opt/openssl@3/lib/pkgconfig"
169+
export PATH="$(brew --prefix bison)/bin:$PATH"
170+
export CC='clang'
171+
export CXX='clang++'
172+
export CLANG_VERSION=none
173+
export SKIP_FORMAT_CHECK=1
174+
./ci-build.sh --disable-postgres --protocol current

0 commit comments

Comments
 (0)