Skip to content

Commit 1f86c9a

Browse files
rust: update cluster management examples to use new API
1 parent e419c78 commit 1f86c9a

20 files changed

Lines changed: 1474 additions & 864 deletions

.github/workflows/rust-cm-integ-tests.yml

Lines changed: 73 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,26 @@ on:
2020
type: string
2121

2222
jobs:
23+
format:
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 5
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Rust
32+
run: rustup update
33+
34+
- name: Check formatting
35+
working-directory: ./rust/cluster_management
36+
run: |
37+
rustup component add rustfmt
38+
cargo fmt -- --check
39+
2340
test:
2441
runs-on: ubuntu-latest
25-
timeout-minutes: 15
42+
timeout-minutes: 30
2643
permissions:
2744
id-token: write
2845
contents: read
@@ -32,19 +49,58 @@ jobs:
3249
pull-requests: write
3350

3451
steps:
35-
- name: Checkout code
36-
uses: actions/checkout@v4
37-
38-
- name: Set up Rust
39-
run: rustup update
40-
41-
- name: Configure AWS Credentials
42-
uses: aws-actions/configure-aws-credentials@v4
43-
with:
44-
role-to-assume: ${{ secrets.RUST_IAM_ROLE }}
45-
aws-region: us-east-1
46-
47-
- name: Configure and run integration for cluster management
48-
working-directory: ./rust/cluster_management
49-
run: |
50-
cargo test
52+
- name: Checkout code
53+
uses: actions/checkout@v4
54+
55+
- name: Set up Rust
56+
run: rustup update
57+
58+
- name: Configure AWS Credentials
59+
uses: aws-actions/configure-aws-credentials@v4
60+
with:
61+
role-to-assume: ${{ secrets.RUST_IAM_ROLE }}
62+
aws-region: us-east-1
63+
64+
- name: Configure and run integration for cluster management
65+
working-directory: ./rust/cluster_management
66+
run: |
67+
cargo test -- --nocapture
68+
69+
# This job ensures all example binaries remain independently executable. The examples serve dual purposes; they are
70+
# standalone binaries with main entry points for customers, and library functions for our unit tests. We need to
71+
# verify the standalone functionality remains intact through future changes. Each binary should fail gracefully when
72+
# environment variables are missing, which confirms they can be built and executed as an independent entry point.
73+
run-binaries:
74+
runs-on: ubuntu-latest
75+
timeout-minutes: 5
76+
77+
steps:
78+
- name: Checkout code
79+
uses: actions/checkout@v4
80+
81+
- name: Set up Rust
82+
run: rustup update
83+
84+
- name: Build and run all binaries
85+
working-directory: ./rust/cluster_management
86+
run: |
87+
# Get all binary names.
88+
binaries=$(find src/bin -name "*.rs" | sed 's|src/bin/||' | sed 's|\.rs$||')
89+
90+
# Test each binary
91+
for bin in $binaries; do
92+
echo "Testing binary: $bin"
93+
94+
# Run the binary and capture its output
95+
output=$(cargo run --bin $bin 2>&1) || true
96+
97+
# Check if the output contains the expected error message about environment variables
98+
if echo "$output" | grep -q "env variable \`CLUSTER_REGION\` should be set"; then
99+
echo "Binary correctly reported missing CLUSTER_REGION environment variable"
100+
else
101+
echo "Binary did not produce the expected error message about missing environment variables"
102+
echo "Actual output was:"
103+
echo "$output"
104+
exit 1
105+
fi
106+
done

0 commit comments

Comments
 (0)