|
| 1 | +name: Rust Core Library CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ develop, master ] |
| 6 | + paths: |
| 7 | + - 'rust/**' |
| 8 | + - '.github/workflows/rust-core.yml' |
| 9 | + pull_request: |
| 10 | + branches: [ develop, master ] |
| 11 | + paths: |
| 12 | + - 'rust/**' |
| 13 | + |
| 14 | +env: |
| 15 | + CARGO_TERM_COLOR: always |
| 16 | + RUST_BACKTRACE: 1 |
| 17 | + |
| 18 | +jobs: |
| 19 | + test: |
| 20 | + name: Test on ${{ matrix.os }} |
| 21 | + runs-on: ${{ matrix.os }} |
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 26 | + rust: [stable, beta] |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v3 |
| 30 | + |
| 31 | + - name: Install Rust |
| 32 | + uses: dtolnay/rust-toolchain@master |
| 33 | + with: |
| 34 | + toolchain: ${{ matrix.rust }} |
| 35 | + components: rustfmt, clippy |
| 36 | + |
| 37 | + - name: Cache cargo registry |
| 38 | + uses: actions/cache@v3 |
| 39 | + with: |
| 40 | + path: ~/.cargo/registry |
| 41 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 42 | + |
| 43 | + - name: Cache cargo index |
| 44 | + uses: actions/cache@v3 |
| 45 | + with: |
| 46 | + path: ~/.cargo/git |
| 47 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 48 | + |
| 49 | + - name: Cache cargo build |
| 50 | + uses: actions/cache@v3 |
| 51 | + with: |
| 52 | + path: rust/target |
| 53 | + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} |
| 54 | + |
| 55 | + - name: Check formatting |
| 56 | + run: cargo fmt --all -- --check |
| 57 | + working-directory: rust |
| 58 | + |
| 59 | + - name: Run clippy |
| 60 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 61 | + working-directory: rust |
| 62 | + |
| 63 | + - name: Build |
| 64 | + run: cargo build --verbose |
| 65 | + working-directory: rust |
| 66 | + |
| 67 | + - name: Run tests |
| 68 | + run: cargo test --verbose |
| 69 | + working-directory: rust |
| 70 | + |
| 71 | + - name: Build release |
| 72 | + run: cargo build --release --verbose |
| 73 | + working-directory: rust |
| 74 | + |
| 75 | + - name: Run release tests |
| 76 | + run: cargo test --release --verbose |
| 77 | + working-directory: rust |
| 78 | + |
| 79 | + bench: |
| 80 | + name: Benchmarks |
| 81 | + runs-on: ubuntu-latest |
| 82 | + |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v3 |
| 85 | + |
| 86 | + - name: Install Rust |
| 87 | + uses: dtolnay/rust-toolchain@stable |
| 88 | + |
| 89 | + - name: Cache cargo |
| 90 | + uses: actions/cache@v3 |
| 91 | + with: |
| 92 | + path: | |
| 93 | + ~/.cargo/registry |
| 94 | + ~/.cargo/git |
| 95 | + rust/target |
| 96 | + key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }} |
| 97 | + |
| 98 | + - name: Run benchmarks |
| 99 | + run: cargo bench --no-fail-fast |
| 100 | + working-directory: rust |
| 101 | + |
| 102 | + doc: |
| 103 | + name: Documentation |
| 104 | + runs-on: ubuntu-latest |
| 105 | + |
| 106 | + steps: |
| 107 | + - uses: actions/checkout@v3 |
| 108 | + |
| 109 | + - name: Install Rust |
| 110 | + uses: dtolnay/rust-toolchain@stable |
| 111 | + |
| 112 | + - name: Build documentation |
| 113 | + run: cargo doc --no-deps --all-features |
| 114 | + working-directory: rust |
| 115 | + |
| 116 | + - name: Check documentation |
| 117 | + run: cargo doc --no-deps --all-features --document-private-items |
| 118 | + working-directory: rust |
| 119 | + env: |
| 120 | + RUSTDOCFLAGS: -D warnings |
| 121 | + |
| 122 | + integration: |
| 123 | + name: CMake Integration Test |
| 124 | + runs-on: ${{ matrix.os }} |
| 125 | + strategy: |
| 126 | + fail-fast: false |
| 127 | + matrix: |
| 128 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 129 | + |
| 130 | + steps: |
| 131 | + - uses: actions/checkout@v3 |
| 132 | + |
| 133 | + - name: Install Rust |
| 134 | + uses: dtolnay/rust-toolchain@stable |
| 135 | + |
| 136 | + - name: Install CMake (Ubuntu) |
| 137 | + if: matrix.os == 'ubuntu-latest' |
| 138 | + run: sudo apt-get update && sudo apt-get install -y cmake |
| 139 | + |
| 140 | + - name: Install CMake (macOS) |
| 141 | + if: matrix.os == 'macos-latest' |
| 142 | + run: brew install cmake |
| 143 | + |
| 144 | + - name: Configure CMake |
| 145 | + run: cmake -S rust -B rust/build |
| 146 | + |
| 147 | + - name: Build with CMake |
| 148 | + run: cmake --build rust/build --config Release |
| 149 | + |
| 150 | + security: |
| 151 | + name: Security Audit |
| 152 | + runs-on: ubuntu-latest |
| 153 | + |
| 154 | + steps: |
| 155 | + - uses: actions/checkout@v3 |
| 156 | + |
| 157 | + - name: Install Rust |
| 158 | + uses: dtolnay/rust-toolchain@stable |
| 159 | + |
| 160 | + - name: Install cargo-audit |
| 161 | + run: cargo install cargo-audit |
| 162 | + |
| 163 | + - name: Run security audit |
| 164 | + run: cargo audit |
| 165 | + working-directory: rust |
| 166 | + |
| 167 | + coverage: |
| 168 | + name: Code Coverage |
| 169 | + runs-on: ubuntu-latest |
| 170 | + |
| 171 | + steps: |
| 172 | + - uses: actions/checkout@v3 |
| 173 | + |
| 174 | + - name: Install Rust |
| 175 | + uses: dtolnay/rust-toolchain@stable |
| 176 | + with: |
| 177 | + components: llvm-tools-preview |
| 178 | + |
| 179 | + - name: Install cargo-llvm-cov |
| 180 | + run: cargo install cargo-llvm-cov |
| 181 | + |
| 182 | + - name: Generate coverage |
| 183 | + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info |
| 184 | + working-directory: rust |
| 185 | + |
| 186 | + - name: Upload coverage to Codecov |
| 187 | + uses: codecov/codecov-action@v3 |
| 188 | + with: |
| 189 | + files: rust/lcov.info |
| 190 | + flags: rust-core |
| 191 | + fail_ci_if_error: false |
0 commit comments