Skip to content

Commit b5a6748

Browse files
committed
merge various jobs into single static-checks to save costs
1 parent 4d723d6 commit b5a6748

File tree

1 file changed

+66
-41
lines changed

1 file changed

+66
-41
lines changed

.github/workflows/build.yml

Lines changed: 66 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,60 +18,85 @@ jobs:
1818

1919
complete:
2020
if: always()
21-
needs: [fmt, cargo-deny, rust-check-git-rev-deps, build-linux, build-mac]
21+
needs: [static-checks, build-linux, build-mac]
2222
runs-on:
2323
- namespace-profile-noble-24-04-stellar-core-x64-small
24-
- nscloud-cache-exp-do-not-commit
2524
steps:
2625
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
2726
run: exit 1
2827

29-
fmt:
28+
static-checks:
3029
runs-on:
31-
- namespace-profile-noble-24-04-stellar-core-x64-small
32-
- nscloud-cache-exp-do-not-commit
30+
- namespace-profile-noble-24-04-stellar-core-x64-small;overrides.cache-tag=config-static-checks
3331
steps:
3432
- uses: namespacelabs/nscloud-checkout-action@v7
3533
with:
3634
fetch-depth: 1
3735
submodules: recursive
38-
- run: rustup component add rustfmt
39-
- run: rustup update
40-
- run: cargo fmt --all --check
4136

42-
cargo-deny:
43-
runs-on:
44-
- namespace-profile-noble-24-04-stellar-core-x64-small
45-
- nscloud-cache-exp-do-not-commit
46-
strategy:
47-
matrix:
48-
checks:
49-
- advisories
50-
- bans licenses sources
51-
# Prevent sudden announcement of a new advisory from failing ci:
52-
continue-on-error: ${{ matrix.checks == 'advisories' }}
53-
steps:
54-
- uses: namespacelabs/nscloud-checkout-action@v7
37+
- name: Configure Namespace cache volume
38+
uses: namespacelabs/nscloud-cache-action@v1
5539
with:
56-
fetch-depth: 1
57-
submodules: recursive
58-
- uses: EmbarkStudios/cargo-deny-action@8d73959fce1cdc8989f23fdf03bec6ae6a6576ef
40+
path: |
41+
~/.cargo
42+
build-static-checks
43+
44+
- name: Check if commit already tested
45+
id: check-last-tested-commit
46+
run: |
47+
LAST_TESTED_COMMIT_SHA_FILE="build-static-checks/.last-tested-commit-sha"
48+
if [ -f "$LAST_TESTED_COMMIT_SHA_FILE" ] && [ "$(cat "$LAST_TESTED_COMMIT_SHA_FILE")" = "${{ github.sha }}" ]; then
49+
echo "Commit ${{ github.sha }} already tested successfully, skipping build"
50+
echo "skip=true" >> $GITHUB_OUTPUT
51+
else
52+
echo "skip=false" >> $GITHUB_OUTPUT
53+
fi
54+
55+
- name: Install rustup
56+
if: steps.check-last-tested-commit.outputs.skip != 'true'
57+
run: ./install-rust.sh
58+
59+
- name: Update rustup
60+
if: steps.check-last-tested-commit.outputs.skip != 'true'
61+
run: rustup update
62+
63+
- name: Install rustfmt
64+
if: steps.check-last-tested-commit.outputs.skip != 'true'
65+
run: rustup component add rustfmt
66+
67+
- name: Check git rev deps
68+
if: steps.check-last-tested-commit.outputs.skip != 'true'
69+
uses: stellar/actions/rust-check-git-rev-deps@main
70+
71+
- name: Check formatting
72+
if: steps.check-last-tested-commit.outputs.skip != 'true'
73+
run: cargo fmt --all --check
74+
75+
- name: Check cargo-deny advisories
76+
if: steps.check-last-tested-commit.outputs.skip != 'true'
77+
# Prevent sudden announcement of a new advisory from failing ci:
78+
continue-on-error: true
79+
uses: EmbarkStudios/cargo-deny-action@8d73959fce1cdc8989f23fdf03bec6ae6a6576ef
5980
with:
60-
command: check ${{ matrix.checks }}
81+
command: check advisories
6182
# leave arguments empty so we don't test --all-features
6283
# which will see conflicting env versions
6384
arguments:
6485

65-
rust-check-git-rev-deps:
66-
runs-on:
67-
- namespace-profile-noble-24-04-stellar-core-x64-small
68-
- nscloud-cache-exp-do-not-commit
69-
steps:
70-
- uses: namespacelabs/nscloud-checkout-action@v7
86+
- name: Check cargo-deny bans licenses sources
87+
if: steps.check-last-tested-commit.outputs.skip != 'true'
88+
uses: EmbarkStudios/cargo-deny-action@8d73959fce1cdc8989f23fdf03bec6ae6a6576ef
7189
with:
72-
fetch-depth: 1
73-
submodules: recursive
74-
- uses: stellar/actions/rust-check-git-rev-deps@main
90+
command: check bans licenses sources
91+
# leave arguments empty so we don't test --all-features
92+
# which will see conflicting env versions
93+
arguments:
94+
95+
- name: Record successful test commit
96+
if: ${{ success() && steps.check-last-tested-commit.outputs.skip != 'true' }}
97+
run: |
98+
mkdir -p build-static-checks
99+
echo "${{ github.sha }}" > "build-static-checks/.last-tested-commit-sha"
75100
76101
build-linux:
77102
runs-on:
@@ -83,7 +108,7 @@ jobs:
83108
protocol: ["current", "next"]
84109
steps:
85110
- name: Fix kernel mmap rnd bits
86-
# Asan in llvm provided in some ubuntus is incompatible with
111+
# Asan in llvm provided in some ubuntu versions is incompatible with
87112
# high-entropy ASLR in much newer kernels that GitHub runners are
88113
# using leading to random crashes: https://reviews.llvm.org/D148280
89114
run: sudo sysctl vm.mmap_rnd_bits=28
@@ -112,11 +137,11 @@ jobs:
112137
echo "skip=false" >> $GITHUB_OUTPUT
113138
fi
114139
115-
- name: install rustup
140+
- name: Install rustup
116141
if: steps.check-last-tested-commit.outputs.skip != 'true'
117142
run: ./install-rust.sh
118143

119-
- name: install rustup components
144+
- name: Install rustup components
120145
if: steps.check-last-tested-commit.outputs.skip != 'true'
121146
run: rustup component add rustfmt
122147

@@ -164,7 +189,7 @@ jobs:
164189
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }}
165190
166191
- name: Record successful test commit
167-
if: steps.check-last-tested-commit.outputs.skip != 'true'
192+
if: ${{ success() && steps.check-last-tested-commit.outputs.skip != 'true' }}
168193
run: |
169194
echo "${{ github.sha }}" > "build-${{matrix.toolchain}}-${{matrix.protocol}}/.last-tested-commit-sha"
170195
@@ -197,14 +222,14 @@ jobs:
197222
echo "skip=false" >> $GITHUB_OUTPUT
198223
fi
199224
200-
- name: install prerequisites and uninstall brew rust, add rustup
225+
- name: Install prerequisites and uninstall brew rust, add rustup
201226
if: steps.check-last-tested-commit.outputs.skip != 'true'
202227
run: |
203228
brew install libsodium libtool autoconf automake pkg-config libpq openssl parallel ccache bison gnu-sed perl coreutils
204229
brew uninstall rust rustup
205230
brew install rustup
206231
207-
- name: install rustup components
232+
- name: Install rustup components
208233
if: steps.check-last-tested-commit.outputs.skip != 'true'
209234
run: |
210235
rustup-init -y
@@ -251,6 +276,6 @@ jobs:
251276
./ci-build.sh --disable-postgres --protocol current
252277
253278
- name: Record successful test commit
254-
if: steps.check-last-tested-commit.outputs.skip != 'true'
279+
if: ${{ success() && steps.check-last-tested-commit.outputs.skip != 'true' }}
255280
run: |
256281
echo "${{ github.sha }}" > "build-clang-current/.last-tested-commit-sha"

0 commit comments

Comments
 (0)