Skip to content

Commit 11dc375

Browse files
authored
Merge pull request #24 from ZORDxDD/main
ci: add GitHub Actions CI for fmt, clippy, build and tests
2 parents 8f5f97f + 1dfc882 commit 11dc375

File tree

4 files changed

+133
-2
lines changed

4 files changed

+133
-2
lines changed

.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CI — fmt, clippy, build, test
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
env:
10+
CARGO_CACHE_PATH: ~/.cargo/registry
11+
CARGO_GIT_PATH: ~/.cargo/git
12+
TARGET_DIR: target
13+
14+
jobs:
15+
# Fast checks that run in parallel (no build artifacts needed)
16+
checks:
17+
name: fmt + clippy
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Initialize git submodules
23+
run: git submodule update --init --recursive
24+
25+
- name: Cache cargo
26+
uses: actions/cache@v4
27+
with:
28+
path: |
29+
${{ env.CARGO_CACHE_PATH }}
30+
${{ env.CARGO_GIT_PATH }}
31+
key: ${{ runner.os }}-cargo-checks-${{ hashFiles('**/Cargo.lock', 'envoy-data-plane-api/build.rs') }}
32+
33+
- name: Install protoc
34+
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
35+
36+
- name: Setup Rust
37+
uses: actions-rs/toolchain@v1
38+
with:
39+
toolchain: stable
40+
components: rustfmt, clippy
41+
profile: minimal
42+
43+
- name: Check formatting
44+
run: cargo fmt --all -- --check
45+
46+
- name: Run clippy (fail on warnings)
47+
run: cargo clippy --all-targets --all-features -- -D warnings
48+
49+
# Build and test that share artifacts
50+
build-and-test:
51+
name: build + test
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Initialize git submodules
57+
run: git submodule update --init --recursive
58+
59+
- name: Cache cargo
60+
uses: actions/cache@v4
61+
with:
62+
path: |
63+
${{ env.CARGO_CACHE_PATH }}
64+
${{ env.CARGO_GIT_PATH }}
65+
${{ env.TARGET_DIR }}
66+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock', 'envoy-data-plane-api/build.rs') }}
67+
68+
- name: Install protoc
69+
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
70+
71+
- name: Setup Rust
72+
uses: actions-rs/toolchain@v1
73+
with:
74+
toolchain: stable
75+
profile: minimal
76+
77+
- name: Build (release)
78+
run: cargo build --workspace --release --locked
79+
80+
- name: Run tests
81+
run: cargo test --workspace --release --locked

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.PHONY: fmt fmt-check lint build test ci ci-parallel init
2+
3+
fmt:
4+
cargo fmt --all
5+
6+
fmt-check:
7+
cargo fmt --all -- --check
8+
9+
lint:
10+
cargo clippy --all-targets --all-features -- -D warnings
11+
12+
build:
13+
cargo build --workspace --release --locked
14+
15+
test:
16+
cargo test --workspace --release --locked
17+
18+
# Sequential CI (keep for local/dev reproducibility)
19+
ci: init
20+
cargo fmt --all -- --check
21+
cargo clippy --all-targets --all-features -- -D warnings
22+
cargo build --workspace --release --locked
23+
cargo test --workspace --release --locked
24+
25+
# Parallel CI: run fmt-check, lint and build concurrently; if build succeeds, run tests.
26+
ci-parallel: init
27+
@echo "Starting parallel CI: fmt-check, lint, build"
28+
@bash -ec '\
29+
set -o pipefail; \
30+
cargo fmt --all -- --check & pid_fmt=$$!; \
31+
cargo clippy --all-targets --all-features -- -D warnings & pid_clippy=$$!; \
32+
cargo build --workspace --release --locked & pid_build=$$!; \
33+
wait $$pid_fmt; rc_fmt=$$?; \
34+
wait $$pid_clippy; rc_clippy=$$?; \
35+
wait $$pid_build; rc_build=$$?; \
36+
if [ $$rc_fmt -ne 0 ]; then echo ">>> fmt-check failed (exit $$rc_fmt)"; fi; \
37+
if [ $$rc_clippy -ne 0 ]; then echo ">>> clippy failed (exit $$rc_clippy)"; fi; \
38+
if [ $$rc_build -ne 0 ]; then echo ">>> build failed (exit $$rc_build)"; fi; \
39+
# Fail fast if any of the three failed (so PR check fails with non-zero code) \
40+
if [ $$rc_fmt -ne 0 ] || [ $$rc_clippy -ne 0 ] || [ $$rc_build -ne 0 ]; then exit 1; fi; \
41+
# If we reach here, build succeeded, so run tests \
42+
cargo test --workspace --release --locked; \
43+
'
44+
45+
init:
46+
@echo "Initializing git submodules..."
47+
@git submodule update --init --recursive

orion-configuration/src/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ impl Config {
5757
let runtime = self.runtime.update_from_env_and_options(opt);
5858
let max_cpus = num_cpus::get();
5959
if runtime.num_cpus() > max_cpus {
60-
tracing::warn!(max_cpus, ORION_GATEWAY_CORES = runtime.num_cpus(), "Requested more cores than available CPUs");
60+
tracing::warn!(
61+
max_cpus,
62+
ORION_GATEWAY_CORES = runtime.num_cpus(),
63+
"Requested more cores than available CPUs"
64+
);
6165
}
6266
if runtime.num_runtimes() > runtime.num_cpus() {
6367
tracing::warn!(

orion-proxy/tests/configs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ fn check_config_file(file_path: &str) -> Result<(), orion_error::Error> {
3232
with_current_dir(&d, || get_listeners_and_clusters(bootstrap).map(|_| ()))
3333
}
3434

35-
3635
#[traced_test]
3736
#[test]
3837
fn bootstrap_demo_static() -> Result<(), orion_error::Error> {

0 commit comments

Comments
 (0)