|
| 1 | +# Copyright 2023 SECO Mind Srl |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +name: check |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | +on: |
| 8 | + workflow_call: |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | +defaults: |
| 12 | + run: |
| 13 | + working-directory: rust |
| 14 | +jobs: |
| 15 | + fmt: |
| 16 | + name: stable / fmt |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout sources |
| 20 | + uses: actions/checkout@v4 |
| 21 | + - name: Install toolchain |
| 22 | + uses: dtolnay/rust-toolchain@stable |
| 23 | + with: |
| 24 | + components: rustfmt |
| 25 | + - name: Check formatting |
| 26 | + run: cargo fmt --check |
| 27 | + clippy: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + name: ${{ matrix.toolchain }} / clippy |
| 30 | + permissions: |
| 31 | + contents: read |
| 32 | + checks: write |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: |
| 36 | + toolchain: [ stable, beta ] |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + # Download proto artifact |
| 40 | + - uses: actions/download-artifact@v3 |
| 41 | + id: download-proto |
| 42 | + with: |
| 43 | + name: rust-proto |
| 44 | + - name: Move proto to src |
| 45 | + run: | |
| 46 | + mv -v '${{steps.download-proto.outputs.download-path}}/edgehog.device.forwarder.rs' \ |
| 47 | + edgehog-device-forwarder-proto/src/proto.rs |
| 48 | + ## |
| 49 | + - name: Install ${{ matrix.toolchain }} |
| 50 | + uses: dtolnay/rust-toolchain@master |
| 51 | + with: |
| 52 | + toolchain: ${{ matrix.toolchain }} |
| 53 | + components: clippy |
| 54 | + - name: cargo clippy |
| 55 | + uses: actions-rs/clippy-check@v1 |
| 56 | + with: |
| 57 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + args: --manifest-path rust/Cargo.toml --all-targets --all-features -- -D warnings |
| 59 | + doc: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + name: nightly / doc |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v4 |
| 64 | + - name: Install nightly |
| 65 | + uses: dtolnay/rust-toolchain@nightly |
| 66 | + # Download proto artifact |
| 67 | + - uses: actions/download-artifact@v3 |
| 68 | + id: download-proto |
| 69 | + with: |
| 70 | + name: rust-proto |
| 71 | + - name: Move proto to src |
| 72 | + run: | |
| 73 | + mv -v ${{steps.download-proto.outputs.download-path}}/edgehog.device.forwarder.rs \ |
| 74 | + edgehog-device-forwarder-proto/src/proto.rs |
| 75 | + ## |
| 76 | + - name: cargo doc |
| 77 | + run: cargo doc --no-deps --all-features |
| 78 | + env: |
| 79 | + RUSTDOCFLAGS: --cfg docsrs -D warnings |
| 80 | + hack: |
| 81 | + runs-on: ubuntu-latest |
| 82 | + name: ubuntu / stable / features |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v4 |
| 85 | + - name: Install stable |
| 86 | + uses: dtolnay/rust-toolchain@stable |
| 87 | + - name: cargo install cargo-hack |
| 88 | + uses: taiki-e/install-action@cargo-hack |
| 89 | + # Download proto artifact |
| 90 | + - uses: actions/download-artifact@v3 |
| 91 | + id: download-proto |
| 92 | + with: |
| 93 | + name: rust-proto |
| 94 | + - name: Move proto to src |
| 95 | + run: | |
| 96 | + mv -v '${{steps.download-proto.outputs.download-path}}/edgehog.device.forwarder.rs' \ |
| 97 | + edgehog-device-forwarder-proto/src/proto.rs |
| 98 | + # intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4 |
| 99 | + - name: cargo hack |
| 100 | + run: cargo hack --feature-powerset check |
| 101 | + minimal-versions: |
| 102 | + runs-on: ubuntu-latest |
| 103 | + name: ubuntu / nightly / minimal-versions |
| 104 | + steps: |
| 105 | + - uses: actions/checkout@v4 |
| 106 | + - name: Install nightly |
| 107 | + uses: dtolnay/rust-toolchain@nightly |
| 108 | + - name: cargo install cargo-hack |
| 109 | + uses: taiki-e/install-action@cargo-hack |
| 110 | + - name: remove dev-deps |
| 111 | + run: cargo hack --remove-dev-deps |
| 112 | + - name: update to minimal deps |
| 113 | + run: cargo update -Z direct-minimal-versions |
| 114 | + # Download proto artifact |
| 115 | + - uses: actions/download-artifact@v3 |
| 116 | + id: download-proto |
| 117 | + with: |
| 118 | + name: rust-proto |
| 119 | + - name: Move proto to src |
| 120 | + run: | |
| 121 | + mv -v '${{steps.download-proto.outputs.download-path}}/edgehog.device.forwarder.rs' \ |
| 122 | + edgehog-device-forwarder-proto/src/proto.rs |
| 123 | + ## |
| 124 | + - name: cargo check |
| 125 | + run: cargo check --all-features |
| 126 | + env: |
| 127 | + RUSTDOCFLAGS: -D warnings |
| 128 | + msrv: |
| 129 | + runs-on: ubuntu-latest |
| 130 | + # we use a matrix here just because env can't be used in job names |
| 131 | + # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability |
| 132 | + strategy: |
| 133 | + matrix: |
| 134 | + msrv: [ 1.66.1 ] |
| 135 | + name: ubuntu / ${{ matrix.msrv }} |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v4 |
| 138 | + - name: Install ${{ matrix.msrv }} |
| 139 | + uses: dtolnay/rust-toolchain@master |
| 140 | + with: |
| 141 | + toolchain: ${{ matrix.msrv }} |
| 142 | + # Download proto artifact |
| 143 | + - uses: actions/download-artifact@v3 |
| 144 | + id: download-proto |
| 145 | + with: |
| 146 | + name: rust-proto |
| 147 | + - name: Move proto to src |
| 148 | + run: | |
| 149 | + mv -v '${{steps.download-proto.outputs.download-path}}/edgehog.device.forwarder.rs' \ |
| 150 | + edgehog-device-forwarder-proto/src/proto.rs |
| 151 | + ## |
| 152 | + - name: cargo +${{ matrix.msrv }} check |
| 153 | + run: cargo check --all-features --package edgehog-device-forwarder-proto |
0 commit comments