|
1 |
| -on: [pull_request] |
| 1 | +name: Continuous Integration |
2 | 2 |
|
3 |
| -name: Continuous integration |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, master ] |
| 8 | + workflow_dispatch: # Manual trigger |
| 9 | + |
| 10 | +env: |
| 11 | + CARGO_TERM_COLOR: always |
| 12 | + REDIS_URI: redis://localhost:6379 |
4 | 13 |
|
5 | 14 | jobs:
|
6 | 15 | check:
|
7 | 16 | name: Check
|
8 | 17 | runs-on: ubuntu-latest
|
9 | 18 | steps:
|
10 |
| - - uses: actions/checkout@v2 |
11 |
| - - uses: actions-rs/toolchain@v1 |
12 |
| - with: |
13 |
| - profile: minimal |
14 |
| - toolchain: stable |
15 |
| - override: true |
16 |
| - - uses: actions-rs/cargo@v1 |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + - uses: dtolnay/rust-toolchain@stable |
| 21 | + - uses: actions/cache@v3 |
17 | 22 | with:
|
18 |
| - command: check |
| 23 | + path: | |
| 24 | + ~/.cargo/bin/ |
| 25 | + ~/.cargo/registry/index/ |
| 26 | + ~/.cargo/registry/cache/ |
| 27 | + ~/.cargo/git/db/ |
| 28 | + target/ |
| 29 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 30 | + restore-keys: | |
| 31 | + ${{ runner.os }}-cargo- |
| 32 | + |
| 33 | + - name: Cargo check |
| 34 | + run: cargo check --all-features --workspace |
19 | 35 |
|
20 | 36 | test:
|
21 | 37 | name: Test Suite
|
22 | 38 | runs-on: ubuntu-latest
|
| 39 | + services: |
| 40 | + redis: |
| 41 | + image: redis |
| 42 | + ports: |
| 43 | + - 6379:6379 |
| 44 | + options: >- |
| 45 | + --health-cmd "redis-cli ping" |
| 46 | + --health-interval 10s |
| 47 | + --health-timeout 5s |
| 48 | + --health-retries 5 |
| 49 | +
|
23 | 50 | steps:
|
24 |
| - - uses: actions/checkout@v2 |
25 |
| - - uses: actions-rs/toolchain@v1 |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + - uses: dtolnay/rust-toolchain@stable |
| 53 | + - uses: actions/cache@v3 |
26 | 54 | with:
|
27 |
| - profile: minimal |
28 |
| - toolchain: stable |
29 |
| - override: true |
30 |
| - - uses: actions-rs/cargo@v1 |
31 |
| - with: |
32 |
| - command: test |
33 |
| - args: --lib |
| 55 | + path: | |
| 56 | + ~/.cargo/bin/ |
| 57 | + ~/.cargo/registry/index/ |
| 58 | + ~/.cargo/registry/cache/ |
| 59 | + ~/.cargo/git/db/ |
| 60 | + target/ |
| 61 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 62 | + |
| 63 | + - name: Run unit tests |
| 64 | + run: cargo test --lib --all-features --workspace |
| 65 | + |
| 66 | + - name: Run integration tests |
| 67 | + run: cargo test --test '*' --all-features --workspace |
| 68 | + |
| 69 | + - name: Run doc tests |
| 70 | + run: cargo test --doc --all-features --workspace |
34 | 71 |
|
35 | 72 | fmt:
|
36 |
| - name: Rustfmt |
| 73 | + name: Formatting |
37 | 74 | runs-on: ubuntu-latest
|
38 | 75 | steps:
|
39 |
| - - uses: actions/checkout@v2 |
40 |
| - - uses: actions-rs/toolchain@v1 |
41 |
| - with: |
42 |
| - profile: minimal |
43 |
| - toolchain: stable |
44 |
| - override: true |
45 |
| - - run: rustup component add rustfmt |
46 |
| - - uses: actions-rs/cargo@v1 |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + - uses: dtolnay/rust-toolchain@stable |
47 | 78 | with:
|
48 |
| - command: fmt |
49 |
| - args: --all -- --check |
| 79 | + components: rustfmt |
| 80 | + - name: Check formatting |
| 81 | + run: cargo fmt --all -- --check |
50 | 82 |
|
51 | 83 | clippy:
|
52 | 84 | name: Clippy
|
53 | 85 | runs-on: ubuntu-latest
|
54 | 86 | steps:
|
55 |
| - - uses: actions/checkout@v2 |
56 |
| - - uses: actions-rs/toolchain@v1 |
| 87 | + - uses: actions/checkout@v4 |
| 88 | + - uses: dtolnay/rust-toolchain@stable |
| 89 | + with: |
| 90 | + components: clippy |
| 91 | + - uses: actions/cache@v3 |
| 92 | + with: |
| 93 | + path: | |
| 94 | + ~/.cargo/bin/ |
| 95 | + ~/.cargo/registry/index/ |
| 96 | + ~/.cargo/registry/cache/ |
| 97 | + ~/.cargo/git/db/ |
| 98 | + target/ |
| 99 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 100 | + |
| 101 | + - name: Clippy check |
| 102 | + run: cargo clippy --all-features --workspace -- -D warnings |
| 103 | + |
| 104 | + security-audit: |
| 105 | + name: Security Audit |
| 106 | + runs-on: ubuntu-latest |
| 107 | + steps: |
| 108 | + - uses: actions/checkout@v4 |
| 109 | + - name: Install cargo-audit |
| 110 | + run: cargo install cargo-audit |
| 111 | + - name: Run security audit |
| 112 | + run: cargo audit |
| 113 | + |
| 114 | + cross-platform: |
| 115 | + name: Cross-platform tests |
| 116 | + needs: [check, test] # Only run if initial tests pass |
| 117 | + strategy: |
| 118 | + matrix: |
| 119 | + os: [windows-latest, macos-latest] |
| 120 | + runs-on: ${{ matrix.os }} |
| 121 | + steps: |
| 122 | + - uses: actions/checkout@v4 |
| 123 | + - uses: dtolnay/rust-toolchain@stable |
| 124 | + - uses: actions/cache@v3 |
| 125 | + with: |
| 126 | + path: | |
| 127 | + ~/.cargo/bin/ |
| 128 | + ~/.cargo/registry/index/ |
| 129 | + ~/.cargo/registry/cache/ |
| 130 | + ~/.cargo/git/db/ |
| 131 | + target/ |
| 132 | + key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 133 | + |
| 134 | + - name: Run tests |
| 135 | + run: cargo test --lib --all-features --workspace |
| 136 | + |
| 137 | + docs: |
| 138 | + name: Documentation |
| 139 | + runs-on: ubuntu-latest |
| 140 | + steps: |
| 141 | + - uses: actions/checkout@v4 |
| 142 | + - uses: dtolnay/rust-toolchain@stable |
| 143 | + - name: Check documentation |
| 144 | + env: |
| 145 | + RUSTDOCFLAGS: "-D warnings" |
| 146 | + run: cargo doc --no-deps --all-features --workspace |
| 147 | + |
| 148 | + coverage: |
| 149 | + name: Code coverage |
| 150 | + runs-on: ubuntu-latest |
| 151 | + services: |
| 152 | + redis: |
| 153 | + image: redis |
| 154 | + ports: |
| 155 | + - 6379:6379 |
| 156 | + steps: |
| 157 | + - uses: actions/checkout@v4 |
| 158 | + |
| 159 | + - uses: dtolnay/rust-toolchain@stable |
57 | 160 | with:
|
58 |
| - profile: minimal |
59 |
| - toolchain: stable |
60 |
| - override: true |
61 |
| - - run: rustup component add clippy |
62 |
| - - uses: actions-rs/cargo@v1 |
| 161 | + components: llvm-tools-preview |
| 162 | + |
| 163 | + - name: Install cargo-llvm-cov |
| 164 | + uses: taiki-e/install-action@cargo-llvm-cov |
| 165 | + |
| 166 | + - name: Generate code coverage |
| 167 | + run: cargo llvm-cov --workspace --lcov --output-path lcov.info |
| 168 | + |
| 169 | + - name: Upload coverage to Codecov |
| 170 | + uses: codecov/codecov-action@v3 |
63 | 171 | with:
|
64 |
| - command: clippy |
65 |
| - args: -- -D warnings |
| 172 | + files: lcov.info |
| 173 | + fail_ci_if_error: true |
0 commit comments