Skip to content

Commit 5b72753

Browse files
committed
Factor out native Cargo CI
Remove a bunch of unnecessary CI runs and bring them in line with the pattern we're using for native Bazel builds and Nix builds.
1 parent ab0f1ac commit 5b72753

10 files changed

+160
-96
lines changed

.github/workflows/image.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ jobs:
1717
packages: write
1818
id-token: write
1919
steps:
20+
2021
- name: Checkout
21-
uses: >- # v3.5.3
22-
actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
22+
uses: >- # v4.1.1
23+
actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
2324
2425
- name: Install Nix
2526
uses: >- # v7
2627
DeterminateSystems/nix-installer-action@5620eb4af6b562c53e4d4628c0b6e4f9d9ae8612
2728
with:
2829
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
2931
- name: Cache Nix derivations
3032
uses: >- # Custom commit, last pinned at 2023-11-17.
3133
DeterminateSystems/magic-nix-cache-action@a04e6275a6bea232cd04fc6f3cbf20d4cb02a3e1
34+
3235
- name: Test image
3336
run: |
3437
nix run .#local-image-test

.github/workflows/main.yml

-48
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,6 @@ on:
88
branches: [ main ]
99

1010
jobs:
11-
windows-cargo-tests:
12-
# The type of runner that the job will run on.
13-
runs-on: windows-latest
14-
steps:
15-
- uses: actions/[email protected]
16-
with:
17-
fetch-depth: 0
18-
- name: Compile on windows
19-
run: cargo build --all
20-
- name: Test on windows
21-
run: cargo test --all
22-
cargo-tests:
23-
# The type of runner that the job will run on.
24-
runs-on: ubuntu-22.04
25-
strategy:
26-
matrix:
27-
# Which OS versions we will test on.
28-
os_version: [ 20.04, 22.04 ]
29-
steps:
30-
- uses: actions/[email protected]
31-
with:
32-
fetch-depth: 0
33-
34-
- uses: docker/setup-buildx-action@v2
35-
- uses: docker/build-push-action@v4
36-
with:
37-
context: .
38-
file: ./deployment-examples/docker-compose/Dockerfile
39-
build-args: |
40-
OS_VERSION=${{ matrix.os_version }}
41-
load: true # This brings the build into `docker images` from buildx.
42-
tags: trace_machina/native-link:dependencies
43-
target: dependencies
44-
45-
- name: Create container for cargo
46-
run: |
47-
docker run --name=native-link-cargo trace_machina/native-link:dependencies bash -c ' \
48-
DEBIAN_FRONTEND=noninteractive apt-get install -y curl libssl-dev gcc pkg-config python3 && \
49-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=1.70.0 \
50-
' && \
51-
docker commit native-link-cargo trace_machina/native-link:cargo
52-
- name: Compile & test with cargo
53-
run: |
54-
docker run --rm -w /root/native-link -v $PWD:/root/native-link trace_machina/native-link:cargo bash -c ' \
55-
. /root/.cargo/env && \
56-
cargo build --all && \
57-
cargo test --all \
58-
'
5911
docker-compose-compiles-native-link:
6012
# The type of runner that the job will run on.
6113
runs-on: ubuntu-22.04

.github/workflows/unit-test.yaml renamed to .github/workflows/native-bazel.yaml

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Unit Tests
2+
name: Bazel Native
33

44
on:
55
push:
@@ -14,14 +14,17 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os: [ubuntu-20.04, ubuntu-22.04, windows-2022]
17+
os: [macos-13, ubuntu-22.04, windows-2022]
1818
name: ${{ matrix.os }}
1919
runs-on: ${{ matrix.os }}
2020
steps:
21-
- uses: >- # v4.1.1
21+
22+
- name: Checkout
23+
uses: >- # v4.1.1
2224
actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
2325
24-
- uses: >- # Custom commit at 2023-10-23
26+
- name: Setup Bazelisk
27+
uses: >- # Custom commit at 2023-10-23
2528
bazelbuild/setup-bazelisk@5bc144ec07bd24eaa9b5c3e8c9af4006b033b629
2629
2730
- name: Determine Bazel cache mountpoint
@@ -42,18 +45,19 @@ jobs:
4245
actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
4346
with:
4447
path: ${{ steps.bazel-cache.outputs.mountpoint }}
45-
key: ${{ matrix.os }}-bazel-unit-test
48+
key: ${{ matrix.os }}-bazel-
4649

4750
- name: Run Bazel tests
4851
run: |
4952
if [ "$RUNNER_OS" == "Linux" ] || [ "$RUNNER_OS" == "macOS" ]; then
50-
bazel test //...
53+
bazel test //... --verbose_failures
5154
elif [ "$RUNNER_OS" == "Windows" ]; then
5255
bazel \
5356
--output_user_root=${{ steps.bazel-cache.outputs.mountpoint }} \
5457
test \
5558
--config=windows \
56-
//...
59+
//... \
60+
--verbose_failures
5761
else
5862
echo "Unknown runner OS: $RUNNER_OS"
5963
exit 1

.github/workflows/native-cargo.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: Cargo Native
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
permissions: read-all
11+
12+
jobs:
13+
cargo-native:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [macos-13, ubuntu-22.04, windows-2022]
18+
toolchain: [stable, beta, nightly]
19+
name: ${{ matrix.os }} / ${{ matrix.toolchain }}
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
23+
- name: Checkout
24+
uses: >- # v4.1.1
25+
actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
26+
27+
- name: Set up Rust toolchain
28+
run: >
29+
rustup update ${{ matrix.toolchain }}
30+
&& rustup default ${{ matrix.toolchain }}
31+
shell: bash
32+
33+
- name: Set up Cargo cache
34+
uses: >- # v3.3.2
35+
actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
36+
with:
37+
path: |
38+
~/.cargo/bin/
39+
~/.cargo/registry/index/
40+
~/.cargo/registry/cache/
41+
~/.cargo/git/db/
42+
target/
43+
key: ${{ runner.os }}-cargo-native-${{ hashFiles('**/Cargo.lock') }}
44+
restore-keys: ${{ runner.os }}-cargo-
45+
46+
- name: Build on ${{ runner.os }}
47+
run: cargo build --all
48+
49+
- name: Test on ${{ runner.os }}
50+
run: cargo test --all

.github/workflows/nix.yaml

+40-28
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,59 @@ permissions: read-all
1111

1212
jobs:
1313
nix-bazel:
14-
runs-on: ubuntu-22.04
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [macos-13, ubuntu-22.04]
18+
name: Bazel Dev / ${{ matrix.os }}
19+
runs-on: ${{ matrix.os }}
1520
steps:
21+
1622
- name: Checkout
17-
uses: actions/[email protected]
18-
with:
19-
fetch-depth: 0
23+
uses: >- # v4.1.1
24+
actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
25+
2026
- name: Install Nix
21-
uses: cachix/install-nix-action@v22
22-
with:
23-
nix_path: nixpkgs=channel:nixos-unstable
24-
- name: Mount Nix cache
25-
uses: actions/[email protected]
26-
with:
27-
key: ${{ runner.os }}-nix
28-
path: ~/nix
27+
uses: >- #v7
28+
DeterminateSystems/nix-installer-action@5620eb4af6b562c53e4d4628c0b6e4f9d9ae8612
29+
30+
- name: Cache Nix derivations
31+
uses: >- # Custom commit, last pinned at 2023-11-17.
32+
DeterminateSystems/magic-nix-cache-action@a04e6275a6bea232cd04fc6f3cbf20d4cb02a3e1
33+
2934
- name: Mount bazel cache
30-
uses: actions/cache@v3
35+
uses: >- # v3.3.2
36+
actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
3137
with:
3238
path: "~/.cache/bazel"
3339
key: ${{ runner.os }}-bazel-nix
40+
3441
- name: Invoke Bazel build in Nix shell
3542
run: >
36-
nix --store ~/nix develop --impure --command
37-
bash -c "bazel test ..."
43+
nix develop --impure --command
44+
bash -c "bazel test ... --verbose_failures"
45+
3846
nix-cargo:
39-
runs-on: ubuntu-22.04
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
os: [macos-13, ubuntu-22.04]
51+
name: Cargo Dev / ${{ matrix.os }}
52+
runs-on: ${{ matrix.os }}
4053
steps:
4154
- name: Checkout
42-
uses: actions/[email protected]
43-
with:
44-
fetch-depth: 0
55+
uses: >- # v4.1.1
56+
actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
57+
4558
- name: Install Nix
46-
uses: cachix/install-nix-action@v22
47-
with:
48-
nix_path: nixpkgs=channel:nixos-unstable
49-
- name: Mount Nix cache
50-
uses: actions/[email protected]
51-
with:
52-
key: ${{ runner.os }}-nix
53-
path: ~/nix
59+
uses: >- #v7
60+
DeterminateSystems/nix-installer-action@5620eb4af6b562c53e4d4628c0b6e4f9d9ae8612
61+
62+
- name: Cache Nix derivations
63+
uses: >- # Custom commit, last pinned at 2023-11-17.
64+
DeterminateSystems/magic-nix-cache-action@a04e6275a6bea232cd04fc6f3cbf20d4cb02a3e1
65+
5466
- name: Invoke Cargo build in Nix shell
5567
run: >
56-
nix --store ~/nix develop --impure --command
68+
nix develop --impure --command
5769
bash -c "cargo test --all"

0 commit comments

Comments
 (0)