|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + pull_request: |
| 7 | + workflow_call: |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + RUST_BACKTRACE: 1 |
| 12 | + DATABASE_URL: postgres://postgres:postgres@localhost/postgres |
| 13 | + SQLX_OFFLINE: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + name: Test Suite |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + services: |
| 20 | + postgres: |
| 21 | + image: ghcr.io/pgmq/pg18-pgmq:v1.7.0 |
| 22 | + env: |
| 23 | + POSTGRES_PASSWORD: postgres |
| 24 | + ports: |
| 25 | + - 5432:5432 |
| 26 | + options: >- |
| 27 | + --health-cmd="pg_isready -U postgres" |
| 28 | + --health-interval=10s |
| 29 | + --health-timeout=5s |
| 30 | + --health-retries=5 |
| 31 | + strategy: |
| 32 | + matrix: |
| 33 | + os: [ubuntu-latest] |
| 34 | + rust: [stable, beta] |
| 35 | + include: |
| 36 | + - os: ubuntu-latest |
| 37 | + rust: nightly |
| 38 | + steps: |
| 39 | + - name: Checkout sources |
| 40 | + uses: actions/checkout@v6 |
| 41 | + |
| 42 | + - name: Install Rust toolchain |
| 43 | + uses: dtolnay/rust-toolchain@master |
| 44 | + with: |
| 45 | + toolchain: ${{ matrix.rust }} |
| 46 | + |
| 47 | + - name: Cache cargo registry |
| 48 | + uses: actions/cache@v5 |
| 49 | + with: |
| 50 | + path: | |
| 51 | + ~/.cargo/registry |
| 52 | + ~/.cargo/git |
| 53 | + target |
| 54 | + key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} |
| 55 | + restore-keys: | |
| 56 | + ${{ runner.os }}-cargo-${{ matrix.rust }}- |
| 57 | + ${{ runner.os }}-cargo- |
| 58 | +
|
| 59 | + - name: Run cargo test with all features |
| 60 | + run: cargo test --all-features --verbose -- --test-threads=1 |
| 61 | + |
| 62 | + fmt: |
| 63 | + name: Rustfmt |
| 64 | + runs-on: ubuntu-latest |
| 65 | + steps: |
| 66 | + - name: Checkout sources |
| 67 | + uses: actions/checkout@v6 |
| 68 | + |
| 69 | + - name: Install Rust toolchain |
| 70 | + uses: dtolnay/rust-toolchain@stable |
| 71 | + with: |
| 72 | + components: rustfmt |
| 73 | + |
| 74 | + - name: Run cargo fmt |
| 75 | + run: cargo fmt --all -- --check |
| 76 | + |
| 77 | + clippy: |
| 78 | + name: Clippy |
| 79 | + runs-on: ubuntu-latest |
| 80 | + steps: |
| 81 | + - name: Checkout sources |
| 82 | + uses: actions/checkout@v6 |
| 83 | + |
| 84 | + - name: Install Rust toolchain |
| 85 | + uses: dtolnay/rust-toolchain@stable |
| 86 | + with: |
| 87 | + components: clippy |
| 88 | + |
| 89 | + - name: Cache cargo registry |
| 90 | + uses: actions/cache@v5 |
| 91 | + with: |
| 92 | + path: | |
| 93 | + ~/.cargo/registry |
| 94 | + ~/.cargo/git |
| 95 | + target |
| 96 | + key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }} |
| 97 | + |
| 98 | + - name: Run cargo clippy |
| 99 | + run: cargo clippy --all-targets --all-features |
| 100 | + |
| 101 | + docs: |
| 102 | + name: Documentation |
| 103 | + runs-on: ubuntu-latest |
| 104 | + steps: |
| 105 | + - name: Checkout sources |
| 106 | + uses: actions/checkout@v6 |
| 107 | + |
| 108 | + - name: Install Rust toolchain |
| 109 | + uses: dtolnay/rust-toolchain@nightly |
| 110 | + |
| 111 | + - name: Cache cargo registry |
| 112 | + uses: actions/cache@v5 |
| 113 | + with: |
| 114 | + path: | |
| 115 | + ~/.cargo/registry |
| 116 | + ~/.cargo/git |
| 117 | + target |
| 118 | + key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }} |
| 119 | + |
| 120 | + - name: Build documentation |
| 121 | + run: cargo doc --all-features --no-deps --document-private-items |
| 122 | + env: |
| 123 | + RUSTDOCFLAGS: "-Dwarnings" |
| 124 | + |
| 125 | + unused-deps: |
| 126 | + name: Unused Dependencies |
| 127 | + runs-on: ubuntu-latest |
| 128 | + steps: |
| 129 | + - name: Checkout sources |
| 130 | + uses: actions/checkout@v6 |
| 131 | + |
| 132 | + - name: Install Rust nightly toolchain |
| 133 | + uses: dtolnay/rust-toolchain@nightly |
| 134 | + |
| 135 | + - name: Install cargo-udeps |
| 136 | + uses: taiki-e/install-action@cargo-udeps |
| 137 | + |
| 138 | + - name: Check for unused dependencies |
| 139 | + run: cargo +nightly udeps --all-targets --all-features |
0 commit comments