Skip to content

Commit f2b5747

Browse files
committed
feat: added multi step pipe for code linting
1 parent 6b8e9ca commit f2b5747

1 file changed

Lines changed: 77 additions & 13 deletions

File tree

Lines changed: 77 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,89 @@
1-
name: Build & Test Draco
1+
name: Rust CI/CD Pipeline
22

33
on:
44
push:
5+
pull_request:
6+
types: [opened, reopened]
7+
8+
env:
9+
RUST_BACKTRACE: 1
510

611
jobs:
7-
draco:
12+
# Job 1: Format Check
13+
format:
14+
name: Format Check
815
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v5
19+
20+
- name: Install Rust toolchain
21+
uses: dtolnay/rust-toolchain@stable
22+
with:
23+
components: rustfmt
924

10-
defaults:
11-
run:
12-
shell: bash
25+
- name: Check formatting
26+
run: cargo fmt --all -- --check
1327

28+
# Job 2: Lint Check
29+
lint:
30+
name: Lint Check
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v5
35+
36+
- name: Install Rust toolchain
37+
uses: dtolnay/rust-toolchain@stable
38+
with:
39+
components: clippy
40+
41+
- name: Cache cargo registry
42+
uses: actions/cache@v4
43+
with:
44+
path: |
45+
~/.cargo/registry
46+
~/.cargo/git
47+
target
48+
key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
49+
restore-keys: |
50+
${{ runner.os }}-cargo-
51+
52+
- name: Run clippy
53+
run: cargo clippy --all-targets --all-features
54+
55+
# Job 3: Build
56+
build:
57+
name: Build
58+
needs: [ lint, format ]
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v5
63+
64+
- name: Install Rust toolchain
65+
uses: dtolnay/rust-toolchain@stable
66+
67+
- name: Cache cargo registry
68+
uses: actions/cache@v4
69+
with:
70+
path: |
71+
~/.cargo/registry
72+
~/.cargo/git
73+
target
74+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
75+
restore-keys: |
76+
${{ runner.os }}-cargo-
77+
78+
- name: Build project
79+
run: cargo build --verbose --all-features
80+
81+
test:
82+
name: Test
83+
needs: build
84+
runs-on: ubuntu-latest
1485
steps:
15-
- uses: actions/checkout@v5
16-
- name: Setup rust
17-
run: rustup update --no-self-update stable
18-
- name: Build crate
19-
run: PATH=${{ runner.temp }}/proto/bin:$PATH cargo build
20-
env:
21-
RUST_BACKTRACE: 'full'
2286
- name: Run Tests
23-
run: PATH=${{ runner.temp }}/proto/bin:$PATH cargo test
87+
run: PATH=${{ runner.temp }}/proto/bin:$PATH cargo test
2488
env:
2589
RUST_BACKTRACE: 'full'

0 commit comments

Comments
 (0)