Skip to content

Commit be732ce

Browse files
committed
improve ci speed by using matrix to parallel jobs
1 parent 4efb5b3 commit be732ce

File tree

1 file changed

+93
-79
lines changed

1 file changed

+93
-79
lines changed

.github/workflows/build.yml

Lines changed: 93 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,67 @@ env:
2020
CXX_x86_64-unknown-linux-gnu: clang-18
2121

2222
jobs:
23-
test:
24-
name: Build+Test
23+
build-test:
24+
name: Build+Test (${{ matrix.group }})
2525
runs-on: ubuntu-24.04
26+
strategy:
27+
fail-fast: true
28+
matrix:
29+
include:
30+
- group: stable-tests-all
31+
needs_nightly: false
32+
needs_sgx: false
33+
needs_musl: false
34+
commands: |
35+
cargo test --verbose --locked --all --exclude sgxs-loaders --exclude async-usercalls && [ "$(echo $(nm -D target/debug/sgx-detect|grep __vdso_sgx_enter_enclave))" = "w __vdso_sgx_enter_enclave" ]
36+
- group: stable-tests-separate
37+
needs_nightly: false
38+
needs_sgx: false
39+
needs_musl: false
40+
commands: |
41+
cargo test --verbose --locked -p dcap-artifact-retrieval --features rustls-tls
42+
cargo test --verbose --locked -p dcap-ql --features link
43+
cargo test --verbose --locked -p dcap-ql --features verify
44+
cargo test --verbose --locked -p ias --features mbedtls
45+
cargo test --verbose --locked -p ias --features client,mbedtls
46+
cargo test --locked -p nitro-attestation-verify --no-run && faketime '2021-09-10 11:00:00 GMT' cargo test --locked -p nitro-attestation-verify --lib
47+
- group: nightly-sgx
48+
needs_nightly: true
49+
needs_sgx: true
50+
needs_musl: false
51+
commands: |
52+
cargo +nightly test --verbose --locked -p async-usercalls --target x86_64-fortanix-unknown-sgx --no-run
53+
cargo +nightly test --verbose --locked -p dcap-artifact-retrieval --target x86_64-fortanix-unknown-sgx --no-default-features --no-run
54+
cargo +nightly build --verbose --locked -p aesm-client --target=x86_64-fortanix-unknown-sgx
55+
cargo +nightly build --verbose --locked -p aesm-client --target=x86_64-fortanix-unknown-sgx --features sgx-isa/sgxstd
56+
cargo +nightly test --verbose --locked -p sgx-isa --features sgxstd --target x86_64-fortanix-unknown-sgx --no-run
57+
cargo +nightly test --verbose --locked -p pcs --target x86_64-fortanix-unknown-sgx --no-run
58+
cargo +nightly test --verbose --locked -p pcs --features verify
59+
cargo +nightly test -p insecure-time --features estimate_crystal_clock_freq
60+
cargo +nightly build -p insecure-time --features estimate_crystal_clock_freq --target x86_64-fortanix-unknown-sgx
61+
cargo build --verbose --locked -p em-app -p get-certificate --target=x86_64-fortanix-unknown-sgx
62+
- group: musl-builds
63+
needs_nightly: false
64+
needs_sgx: false
65+
needs_musl: true
66+
commands: |
67+
mkdir -p /tmp/muslinclude
68+
ln -sf /usr/include/x86_64-linux-gnu/openssl /tmp/muslinclude/openssl
69+
PKG_CONFIG_ALLOW_CROSS=1 CFLAGS=-I/tmp/muslinclude CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=true cargo build --locked -p fortanix-sgx-tools --target x86_64-unknown-linux-musl
70+
cargo build --verbose --locked -p em-app -p get-certificate --target=x86_64-unknown-linux-musl
71+
- group: docs
72+
needs_nightly: true
73+
needs_sgx: true
74+
needs_musl: false
75+
commands: |
76+
./doc/generate-api-docs.sh
77+
- group: examples
78+
needs_nightly: false
79+
needs_sgx: false
80+
needs_musl: false
81+
commands: |
82+
cd ./examples/mem-alloc-test && cargo run
83+
cd ../mem-correctness-test && cargo run
2684
2785
env:
2886
CMAKE_POLICY_VERSION_MINIMUM: 3.5
@@ -50,85 +108,41 @@ jobs:
50108
sudo apt-get update -y
51109
sudo apt-get install -y faketime protobuf-compiler libsgx-dcap-ql-dev clang-18 musl-tools gcc-multilib
52110
53-
- name: Setup Rust toolchain
111+
- name: Setup Rust toolchains and targets
54112
run: |
55-
rustup target add x86_64-fortanix-unknown-sgx x86_64-unknown-linux-musl
56-
rustup toolchain add nightly
57-
rustup target add x86_64-fortanix-unknown-sgx --toolchain nightly
58-
rustup update
59-
60-
- name: Cargo test --all --exclude sgxs-loaders
61-
run: cargo test --verbose --locked --all --exclude sgxs-loaders --exclude async-usercalls && [ "$(echo $(nm -D target/debug/sgx-detect|grep __vdso_sgx_enter_enclave))" = "w __vdso_sgx_enter_enclave" ]
62-
63-
- name: cargo test -p async-usercalls --target x86_64-fortanix-unknown-sgx --no-run
64-
run: cargo +nightly test --verbose --locked -p async-usercalls --target x86_64-fortanix-unknown-sgx --no-run
65-
66-
- name: Nightly test -p dcap-artifact-retrieval --target x86_64-fortanix-unknown-sgx --no-default-features --no-run
67-
run: cargo +nightly test --verbose --locked -p dcap-artifact-retrieval --target x86_64-fortanix-unknown-sgx --no-default-features --no-run
68-
69-
- name: Cargo test -p dcap-artifact-retrieval --features rustls-tls
70-
run: cargo test --verbose --locked -p dcap-artifact-retrieval --features rustls-tls
71-
72-
- name: Cargo test -p dcap-ql --features link
73-
run: cargo test --verbose --locked -p dcap-ql --features link
74-
75-
- name: Cargo test -p dcap-ql --features verify
76-
run: cargo test --verbose --locked -p dcap-ql --features verify
77-
78-
- name: Cargo test -p ias --features mbedtls
79-
run: cargo test --verbose --locked -p ias --features mbedtls
80-
81-
- name: Cargo test -p ias --features client,mbedtls
82-
run: cargo test --verbose --locked -p ias --features client,mbedtls
83-
84-
# uses backtrace, which still requires nightly on SGX
85-
- name: Nightly build -p aesm-client --target=x86_64-fortanix-unknown-sgx
86-
run: cargo +nightly build --verbose --locked -p aesm-client --target=x86_64-fortanix-unknown-sgx
87-
88-
# uses sgxstd feature
89-
- name: Nightly build -p aesm-client --target=x86_64-fortanix-unknown-sgx --features sgx-isa/sgxstd
90-
run: cargo +nightly build --verbose --locked -p aesm-client --target=x86_64-fortanix-unknown-sgx --features sgx-isa/sgxstd
91-
92-
- name: Nightly test -p sgx-isa --features sgxstd --target x86_64-fortanix-unknown-sgx --no-run
93-
run: cargo +nightly test --verbose --locked -p sgx-isa --features sgxstd --target x86_64-fortanix-unknown-sgx --no-run
94-
95-
- name: Nightly test -p pcs --target x86_64-fortanix-unknown-sgx
96-
run: cargo +nightly test --verbose --locked -p pcs --target x86_64-fortanix-unknown-sgx --no-run
97-
98-
- name: Nightly test -p pcs --features verify
99-
run: cargo +nightly test --verbose --locked -p pcs --features verify
100-
101-
# Unfortunately running `faketime '2021-09-10 11:00:00 GMT' cargo test -p nitro-attestation-verify` causes a segmentation
102-
# fault while compiling. We only execute `faketime` during the tests
103-
#- run: cargo test --locked -p nitro-attestation-verify --no-run && faketime '2021-09-08 11:00:00 GMT' cargo test --locked -p nitro-attestation-verify --lib
113+
rustup toolchain install stable --profile minimal
114+
if [ "${{ matrix.needs_nightly }}" = "true" ]; then
115+
rustup toolchain install nightly --profile minimal
116+
fi
117+
if [ "${{ matrix.needs_sgx }}" = "true" ]; then
118+
rustup target add x86_64-fortanix-unknown-sgx
119+
if [ "${{ matrix.needs_nightly }}" = "true" ]; then
120+
rustup target add x86_64-fortanix-unknown-sgx --toolchain nightly
121+
fi
122+
fi
123+
if [ "${{ matrix.needs_musl }}" = "true" ]; then
124+
rustup target add x86_64-unknown-linux-musl
125+
fi
104126
105-
- name: Cargo test nitro-attestation-verify with faketime
106-
run: cargo test --locked -p nitro-attestation-verify --no-run && faketime '2021-09-10 11:00:00 GMT' cargo test --locked -p nitro-attestation-verify --lib
127+
- uses: Swatinem/rust-cache@v2
128+
with:
129+
shared-key: ${{ matrix.group }}
130+
cache-all-crates: true
107131

108-
- name: Build fortanix-sgx-tools for x86_64-unknown-linux-musl
109-
# NOTE: Skipping linking with the glibc version of OpenSSL to produce a musl based binary. It is unlikely that this would produce a working binary anyway.
132+
- name: Run matrix commands
110133
run: |
111-
mkdir -p /tmp/muslinclude
112-
ln -sf /usr/include/x86_64-linux-gnu/openssl /tmp/muslinclude/openssl
113-
PKG_CONFIG_ALLOW_CROSS=1 CFLAGS=-I/tmp/muslinclude CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=true cargo build --locked -p fortanix-sgx-tools --target x86_64-unknown-linux-musl
114-
115-
- name: Build em-app, get-certificate for x86_64-unknown-linux-musl
116-
run: cargo build --verbose --locked -p em-app -p get-certificate --target=x86_64-unknown-linux-musl
117-
118-
- name: Build em-app, get-certificate for x86_64-fortanix-unknown-sgx
119-
run: cargo build --verbose --locked -p em-app -p get-certificate --target=x86_64-fortanix-unknown-sgx
120-
121-
- name: insecure-time test
122-
run: cargo +nightly test -p insecure-time --features estimate_crystal_clock_freq
123-
124-
- name: insecure-time build for SGX platform
125-
run: cargo +nightly build -p insecure-time --features estimate_crystal_clock_freq --target x86_64-fortanix-unknown-sgx
134+
${{ matrix.commands }}
126135
127-
- name: Generate API docs
128-
run: ./doc/generate-api-docs.sh
129-
130-
- name: Run memory allocator stress test
131-
run: cd ./examples/mem-alloc-test && cargo run
132-
133-
- name: snmalloc correntness test
134-
run: cd ./examples/mem-correctness-test && cargo run
136+
build-test-summary:
137+
name: Build+Test
138+
runs-on: ubuntu-24.04
139+
needs: [build-test]
140+
if: ${{ always() }}
141+
steps:
142+
- name: Summarize Build+Test matrix
143+
run: |
144+
if [ "${{ needs.build-test.result }}" != "success" ]; then
145+
echo "Build+Test matrix failed"
146+
exit 1
147+
fi
148+
echo "Build+Test matrix succeeded"

0 commit comments

Comments
 (0)