|
| 1 | +--- |
| 2 | +name: Stackable Build Pipeline |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - staging |
| 9 | + - trying |
| 10 | + - "renovate/**" |
| 11 | + tags: |
| 12 | + - "*" |
| 13 | + pull_request: |
| 14 | + merge_group: |
| 15 | + |
| 16 | +env: |
| 17 | + CARGO_TERM_COLOR: always |
| 18 | + CARGO_INCREMENTAL: "0" |
| 19 | + CARGO_PROFILE_DEV_DEBUG: "0" |
| 20 | + RUST_TOOLCHAIN_VERSION: "1.82.0" |
| 21 | + RUSTFLAGS: "-D warnings" |
| 22 | + RUSTDOCFLAGS: "-D warnings" |
| 23 | + RUST_LOG: "info" |
| 24 | + |
| 25 | +jobs: |
| 26 | + # Identify unused dependencies |
| 27 | + run_udeps: |
| 28 | + name: Run Cargo Udeps |
| 29 | + runs-on: ubuntu-latest |
| 30 | + env: |
| 31 | + RUSTC_BOOTSTRAP: 1 |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 |
| 34 | + - uses: dtolnay/rust-toolchain@master |
| 35 | + with: |
| 36 | + toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 37 | + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 |
| 38 | + with: |
| 39 | + key: udeps |
| 40 | + - run: cargo install --locked [email protected] |
| 41 | + - run: cargo udeps --all-targets --all-features |
| 42 | + |
| 43 | + run_cargodeny: |
| 44 | + name: Run Cargo Deny |
| 45 | + runs-on: ubuntu-latest |
| 46 | + strategy: |
| 47 | + matrix: |
| 48 | + checks: |
| 49 | + - advisories |
| 50 | + - bans licenses sources |
| 51 | + |
| 52 | + # Prevent sudden announcement of a new advisory from failing ci: |
| 53 | + continue-on-error: ${{ matrix.checks == 'advisories' }} |
| 54 | + |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 |
| 57 | + - uses: EmbarkStudios/cargo-deny-action@e2f4ede4a4e60ea15ff31bc0647485d80c66cfba # v2.0.4 |
| 58 | + with: |
| 59 | + command: check ${{ matrix.checks }} |
| 60 | + |
| 61 | + run_rustfmt: |
| 62 | + name: Run Rustfmt |
| 63 | + runs-on: ubuntu-latest |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 |
| 66 | + - uses: dtolnay/rust-toolchain@master |
| 67 | + with: |
| 68 | + toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 69 | + components: rustfmt |
| 70 | + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 |
| 71 | + with: |
| 72 | + key: fmt |
| 73 | + - run: cargo fmt --all -- --check |
| 74 | + |
| 75 | + run_clippy: |
| 76 | + name: Run Clippy |
| 77 | + runs-on: ubuntu-latest |
| 78 | + steps: |
| 79 | + - name: Install host dependencies |
| 80 | + run: | |
| 81 | + sudo apt-get update |
| 82 | + sudo apt-get install protobuf-compiler krb5-user libkrb5-dev libclang-dev liblzma-dev libssl-dev pkg-config |
| 83 | + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 |
| 84 | + with: |
| 85 | + submodules: recursive |
| 86 | + - uses: dtolnay/rust-toolchain@master |
| 87 | + with: |
| 88 | + toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 89 | + components: clippy |
| 90 | + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 |
| 91 | + with: |
| 92 | + key: clippy |
| 93 | + - name: Run clippy action to produce annotations |
| 94 | + # NOTE (@Techassi): This action might get a new release soon, because it |
| 95 | + # currently uses Node 16, which is deprecated in the next few months by |
| 96 | + # GitHub. See https://github.com/giraffate/clippy-action/pull/87 |
| 97 | + uses: giraffate/clippy-action@13b9d32482f25d29ead141b79e7e04e7900281e0 # v1.0.1 |
| 98 | + env: |
| 99 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + if: env.GITHUB_TOKEN != null && github.event.pull_request.draft == false |
| 101 | + with: |
| 102 | + clippy_flags: --all-targets -- -D warnings |
| 103 | + reporter: "github-pr-review" |
| 104 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 105 | + - name: Run clippy manually without annotations |
| 106 | + env: |
| 107 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + if: env.GITHUB_TOKEN == null |
| 109 | + run: cargo clippy --color never -q --all-targets -- -D warnings |
| 110 | + |
| 111 | + run_rustdoc: |
| 112 | + name: Run RustDoc |
| 113 | + runs-on: ubuntu-latest |
| 114 | + steps: |
| 115 | + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 |
| 116 | + - uses: dtolnay/rust-toolchain@master |
| 117 | + with: |
| 118 | + toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 119 | + components: rustfmt |
| 120 | + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 |
| 121 | + with: |
| 122 | + key: doc |
| 123 | + - run: cargo doc --document-private-items |
| 124 | + |
| 125 | + run_tests: |
| 126 | + name: Run Cargo Tests |
| 127 | + needs: |
| 128 | + - run_clippy |
| 129 | + - run_rustfmt |
| 130 | + - run_rustdoc |
| 131 | + runs-on: ubuntu-latest |
| 132 | + steps: |
| 133 | + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 |
| 134 | + - uses: dtolnay/rust-toolchain@master |
| 135 | + with: |
| 136 | + toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 137 | + # rust-src is required for trybuild stderr output comparison to work |
| 138 | + # for our cases. |
| 139 | + # See: https://github.com/dtolnay/trybuild/issues/236#issuecomment-1620950759 |
| 140 | + components: rust-src |
| 141 | + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 |
| 142 | + with: |
| 143 | + key: test |
| 144 | + - run: cargo test --all-features |
| 145 | + |
| 146 | + tests_passed: |
| 147 | + name: All tests passed |
| 148 | + needs: |
| 149 | + - run_udeps |
| 150 | + - run_tests |
| 151 | + runs-on: ubuntu-latest |
| 152 | + steps: |
| 153 | + - name: log |
| 154 | + run: echo All tests have passed! |
0 commit comments