YAML · 2184 bytes Raw Blame History
1 name: CI
2
3 on:
4 push:
5 branches: [ main, develop ]
6 pull_request:
7 branches: [ main, develop ]
8
9 env:
10 CARGO_TERM_COLOR: always
11 RUST_BACKTRACE: 1
12
13 jobs:
14 test:
15 name: Test Suite
16 runs-on: ubuntu-latest
17 strategy:
18 matrix:
19 rust: [stable, beta]
20
21 steps:
22 - uses: actions/checkout@v4
23
24 - name: Install Rust
25 uses: dtolnay/rust-toolchain@master
26 with:
27 toolchain: ${{ matrix.rust }}
28 components: rustfmt, clippy
29
30 - name: Install system dependencies
31 run: |
32 sudo apt-get update
33 sudo apt-get install -y pkg-config libssl-dev protobuf-compiler
34
35 - name: Cache cargo registry
36 uses: actions/cache@v3
37 with:
38 path: ~/.cargo/registry
39 key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
40
41 - name: Cache cargo index
42 uses: actions/cache@v3
43 with:
44 path: ~/.cargo/git
45 key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
46
47 - name: Cache cargo build
48 uses: actions/cache@v3
49 with:
50 path: target
51 key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
52
53 - name: Check formatting
54 run: cargo fmt --all -- --check
55
56 - name: Run clippy
57 run: cargo clippy --all-targets --all-features -- -D warnings
58
59 - name: Run tests
60 run: cargo test --verbose
61
62 - name: Build release
63 run: cargo build --release --verbose
64
65 security:
66 name: Security Audit
67 runs-on: ubuntu-latest
68 steps:
69 - uses: actions/checkout@v4
70 - uses: dtolnay/rust-toolchain@stable
71 - name: Security Audit
72 run: |
73 cargo install cargo-audit
74 cargo audit
75
76 docker:
77 name: Docker Build
78 runs-on: ubuntu-latest
79 needs: test
80 steps:
81 - uses: actions/checkout@v4
82
83 - name: Set up Docker Buildx
84 uses: docker/setup-buildx-action@v3
85
86 - name: Build Docker image
87 uses: docker/build-push-action@v5
88 with:
89 context: .
90 file: ./Dockerfile
91 push: false
92 tags: zephyrfs-node:test
93 cache-from: type=gha
94 cache-to: type=gha,mode=max