|
| 1 | +# Inspired by https://github.com/rust-analyzer/rust-analyzer/blob/master/.github/workflows/ci.yaml |
| 2 | +# but tweaked in several ways. If you make changes here, consider doing so across other |
| 3 | +# repositories in e.g. ostreedev etc. |
| 4 | +name: Rust |
| 5 | + |
| 6 | +permissions: |
| 7 | + actions: read |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: [main] |
| 12 | + pull_request: |
| 13 | + branches: [main] |
| 14 | + workflow_dispatch: {} |
| 15 | + |
| 16 | +env: |
| 17 | + CARGO_TERM_COLOR: always |
| 18 | + |
| 19 | +jobs: |
| 20 | + tests: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + container: quay.io/coreos-assembler/fcos-buildroot:testing-devel |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v3 |
| 25 | + - name: Code lints |
| 26 | + run: ./ci/lints.sh |
| 27 | + - name: Install deps |
| 28 | + run: ./ci/installdeps.sh |
| 29 | + # xref containers/containers-image-proxy-rs |
| 30 | + - name: Cache Dependencies |
| 31 | + uses: Swatinem/rust-cache@v2 |
| 32 | + with: |
| 33 | + key: "tests" |
| 34 | + - name: cargo fmt (check) |
| 35 | + run: cargo fmt -- --check -l |
| 36 | + - name: Build |
| 37 | + run: cargo test --no-run |
| 38 | + - name: Individual checks |
| 39 | + run: (cd cli && cargo check) && (cd lib && cargo check) |
| 40 | + - name: Run tests |
| 41 | + run: cargo test -- --nocapture --quiet |
| 42 | + - name: Manpage generation |
| 43 | + run: mkdir -p target/man && cargo run --features=docgen -- man --directory target/man |
| 44 | + - name: cargo clippy |
| 45 | + run: cargo clippy |
| 46 | + build: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + container: quay.io/coreos-assembler/fcos-buildroot:testing-devel |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v3 |
| 51 | + - name: Install deps |
| 52 | + run: ./ci/installdeps.sh |
| 53 | + - name: Cache Dependencies |
| 54 | + uses: Swatinem/rust-cache@v2 |
| 55 | + with: |
| 56 | + key: "build" |
| 57 | + - name: Build |
| 58 | + run: cargo build --release --features=internal-testing-api |
| 59 | + - name: Upload binary |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: ostree-ext-cli |
| 63 | + path: target/release/ostree-ext-cli |
| 64 | + build-minimum-toolchain: |
| 65 | + name: "Build using MSRV" |
| 66 | + runs-on: ubuntu-latest |
| 67 | + container: quay.io/coreos-assembler/fcos-buildroot:testing-devel |
| 68 | + steps: |
| 69 | + - name: Checkout repository |
| 70 | + uses: actions/checkout@v3 |
| 71 | + - name: Install deps |
| 72 | + run: ./ci/installdeps.sh |
| 73 | + - name: Detect crate MSRV |
| 74 | + shell: bash |
| 75 | + run: | |
| 76 | + msrv=$(cargo metadata --format-version 1 --no-deps | \ |
| 77 | + jq -r '.packages[1].rust_version') |
| 78 | + echo "Crate MSRV: $msrv" |
| 79 | + echo "ACTION_MSRV_TOOLCHAIN=$msrv" >> $GITHUB_ENV |
| 80 | + - name: Remove system Rust toolchain |
| 81 | + run: dnf remove -y rust cargo |
| 82 | + - uses: dtolnay/rust-toolchain@master |
| 83 | + with: |
| 84 | + toolchain: ${{ env['ACTION_MSRV_TOOLCHAIN'] }} |
| 85 | + - name: Cache Dependencies |
| 86 | + uses: Swatinem/rust-cache@v2 |
| 87 | + with: |
| 88 | + key: "min" |
| 89 | + - name: cargo check |
| 90 | + run: cargo check |
| 91 | + cargo-deny: |
| 92 | + runs-on: ubuntu-latest |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v3 |
| 95 | + - uses: EmbarkStudios/cargo-deny-action@v1 |
| 96 | + with: |
| 97 | + log-level: warn |
| 98 | + command: check bans sources licenses |
| 99 | + integration: |
| 100 | + name: "Integration" |
| 101 | + needs: build |
| 102 | + runs-on: ubuntu-latest |
| 103 | + container: quay.io/fedora/fedora-coreos:testing-devel |
| 104 | + steps: |
| 105 | + - name: Checkout repository |
| 106 | + uses: actions/checkout@v3 |
| 107 | + - name: Download ostree-ext-cli |
| 108 | + |
| 109 | + with: |
| 110 | + name: ostree-ext-cli |
| 111 | + - name: Install |
| 112 | + run: install ostree-ext-cli /usr/bin && rm -v ostree-ext-cli |
| 113 | + - name: Integration tests |
| 114 | + run: ./ci/integration.sh |
| 115 | + ima: |
| 116 | + name: "Integration (IMA)" |
| 117 | + needs: build |
| 118 | + runs-on: ubuntu-latest |
| 119 | + container: quay.io/fedora/fedora-coreos:testing-devel |
| 120 | + steps: |
| 121 | + - name: Checkout repository |
| 122 | + uses: actions/checkout@v3 |
| 123 | + - name: Download ostree-ext-cli |
| 124 | + |
| 125 | + with: |
| 126 | + name: ostree-ext-cli |
| 127 | + - name: Install |
| 128 | + run: install ostree-ext-cli /usr/bin && rm -v ostree-ext-cli |
| 129 | + - name: Integration tests |
| 130 | + run: ./ci/ima.sh |
| 131 | + privtest: |
| 132 | + name: "Privileged testing" |
| 133 | + needs: build |
| 134 | + runs-on: ubuntu-latest |
| 135 | + container: |
| 136 | + image: quay.io/fedora/fedora-coreos:testing-devel |
| 137 | + options: "--privileged --pid=host -v /var/tmp:/var/tmp -v /run/dbus:/run/dbus -v /run/systemd:/run/systemd -v /:/run/host" |
| 138 | + steps: |
| 139 | + - name: Checkout repository |
| 140 | + uses: actions/checkout@v3 |
| 141 | + - name: Download |
| 142 | + |
| 143 | + with: |
| 144 | + name: ostree-ext-cli |
| 145 | + - name: Install |
| 146 | + run: install ostree-ext-cli /usr/bin && rm -v ostree-ext-cli |
| 147 | + - name: Integration tests |
| 148 | + run: ./ci/priv-integration.sh |
| 149 | + privtest-cockpit: |
| 150 | + name: "Privileged testing (cockpit)" |
| 151 | + needs: build |
| 152 | + runs-on: ubuntu-latest |
| 153 | + container: |
| 154 | + image: quay.io/fedora/fedora-bootc:41 |
| 155 | + options: "--privileged --pid=host -v /var/tmp:/var/tmp -v /run/dbus:/run/dbus -v /run/systemd:/run/systemd -v /:/run/host" |
| 156 | + steps: |
| 157 | + - name: Checkout repository |
| 158 | + uses: actions/checkout@v4 |
| 159 | + - name: Download |
| 160 | + |
| 161 | + with: |
| 162 | + name: ostree-ext-cli |
| 163 | + - name: Install |
| 164 | + run: install ostree-ext-cli /usr/bin && rm -v ostree-ext-cli |
| 165 | + - name: Integration tests |
| 166 | + run: ./ci/priv-test-cockpit-selinux.sh |
| 167 | + container-build: |
| 168 | + name: "Container build" |
| 169 | + needs: build |
| 170 | + runs-on: ubuntu-latest |
| 171 | + steps: |
| 172 | + - name: Checkout repository |
| 173 | + uses: actions/checkout@v3 |
| 174 | + - name: Checkout coreos-layering-examples |
| 175 | + uses: actions/checkout@v3 |
| 176 | + with: |
| 177 | + repository: coreos/coreos-layering-examples |
| 178 | + path: coreos-layering-examples |
| 179 | + - name: Download |
| 180 | + |
| 181 | + with: |
| 182 | + name: ostree-ext-cli |
| 183 | + - name: Integration tests |
| 184 | + run: ./ci/container-build-integration.sh |
0 commit comments