|
| 1 | +name: Rust |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + - develop # TODO: remove before merging to master |
| 7 | + tags: |
| 8 | + - 'v[0-9]+.[0-9]+.[0-9]+' |
| 9 | + pull_request: |
| 10 | + |
| 11 | +jobs: |
| 12 | + format: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + - name: Setup Rust |
| 17 | + uses: actions-rs/toolchain@v1 |
| 18 | + with: |
| 19 | + toolchain: stable |
| 20 | + profile: minimal |
| 21 | + components: rustfmt |
| 22 | + default: true |
| 23 | + override: true |
| 24 | + - name: Cargo cache |
| 25 | + uses: actions/cache@v2 |
| 26 | + with: |
| 27 | + path: | |
| 28 | + ~/.cargo/registry |
| 29 | + ~/.cargo/git |
| 30 | + key: ${{ runner.os }}-cargo-rust_stable-${{ hashFiles('**/Cargo.toml') }} |
| 31 | + - name: Format |
| 32 | + uses: actions-rs/cargo@v1 |
| 33 | + with: |
| 34 | + command: fmt |
| 35 | + args: --all -- --check |
| 36 | + |
| 37 | + doc: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v2 |
| 41 | + - name: Setup Rust |
| 42 | + uses: actions-rs/toolchain@v1 |
| 43 | + with: |
| 44 | + toolchain: stable |
| 45 | + profile: minimal |
| 46 | + components: rust-docs |
| 47 | + default: true |
| 48 | + override: true |
| 49 | + - name: Cargo cache |
| 50 | + uses: actions/cache@v2 |
| 51 | + with: |
| 52 | + path: | |
| 53 | + ~/.cargo/registry |
| 54 | + ~/.cargo/git |
| 55 | + key: ${{ runner.os }}-cargo-rust_nightly-${{ hashFiles('**/Cargo.toml') }} |
| 56 | + - name: Documentation |
| 57 | + uses: actions-rs/cargo@v1 |
| 58 | + env: |
| 59 | + DOCS_RS: 1 |
| 60 | + with: |
| 61 | + command: doc |
| 62 | + |
| 63 | + check: |
| 64 | + runs-on: ubuntu-latest |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v1 |
| 67 | + - run: sudo apt-get install -y libdrm-dev |
| 68 | + - uses: actions-rs/toolchain@v1 |
| 69 | + with: |
| 70 | + toolchain: nightly |
| 71 | + profile: minimal |
| 72 | + components: clippy |
| 73 | + default: true |
| 74 | + override: true |
| 75 | + - name: Cargo cache |
| 76 | + uses: actions/cache@v2 |
| 77 | + with: |
| 78 | + path: | |
| 79 | + ~/.cargo/registry |
| 80 | + ~/.cargo/git |
| 81 | + key: ${{ runner.os }}-cargo-rust_nightly-${{ hashFiles('**/Cargo.toml') }} |
| 82 | + - name: Build cache |
| 83 | + uses: actions/cache@v2 |
| 84 | + with: |
| 85 | + path: target |
| 86 | + key: ${{ runner.os }}-build-rust_nightly-check-${{ hashFiles('**/Cargo.toml') }} |
| 87 | + - name: Clippy check |
| 88 | + uses: actions-rs/clippy-check@v1 |
| 89 | + with: |
| 90 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + args: --all --all-features --all-targets -- -D warnings -A clippy::redundant_static_lifetimes |
| 92 | + |
| 93 | + check-minimal: |
| 94 | + runs-on: ubuntu-latest |
| 95 | + steps: |
| 96 | + - uses: actions/checkout@v1 |
| 97 | + - run: sudo apt-get install -y libdrm-dev |
| 98 | + - uses: actions-rs/toolchain@v1 |
| 99 | + with: |
| 100 | + toolchain: nightly |
| 101 | + profile: minimal |
| 102 | + default: true |
| 103 | + override: true |
| 104 | + - name: Cargo cache |
| 105 | + uses: actions/cache@v2 |
| 106 | + with: |
| 107 | + path: | |
| 108 | + ~/.cargo/registry |
| 109 | + ~/.cargo/git |
| 110 | + key: ${{ runner.os }}-cargo-rust_nightly-check-minimal-versions-${{ hashFiles('**/Cargo.toml') }} |
| 111 | + - name: Build cache |
| 112 | + uses: actions/cache@v2 |
| 113 | + with: |
| 114 | + path: target |
| 115 | + key: ${{ runner.os }}-build-rust_nightly-check-minimal-versions-${{ hashFiles('**/Cargo.toml') }} |
| 116 | + - uses: actions-rs/cargo@v1 |
| 117 | + with: |
| 118 | + command: check |
| 119 | + args: --all --all-features --all-targets -Z minimal-versions |
| 120 | + |
| 121 | + test: |
| 122 | + needs: |
| 123 | + - format |
| 124 | + - doc |
| 125 | + - check |
| 126 | + strategy: |
| 127 | + fail-fast: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 128 | + matrix: |
| 129 | + include: |
| 130 | + # Generate bindings |
| 131 | + - task: bindings |
| 132 | + os: ubuntu-latest |
| 133 | + rust: stable |
| 134 | + target: i686-unknown-linux-gnu |
| 135 | + - task: bindings |
| 136 | + os: ubuntu-latest |
| 137 | + rust: stable |
| 138 | + target: x86_64-unknown-linux-gnu |
| 139 | + - task: bindings |
| 140 | + os: ubuntu-latest |
| 141 | + rust: stable |
| 142 | + target: arm-unknown-linux-gnueabihf |
| 143 | + - task: bindings |
| 144 | + os: ubuntu-latest |
| 145 | + rust: stable |
| 146 | + target: armv7-unknown-linux-gnueabihf |
| 147 | + - task: bindings |
| 148 | + os: ubuntu-latest |
| 149 | + rust: stable |
| 150 | + target: aarch64-unknown-linux-gnu |
| 151 | + # Test channels |
| 152 | + - task: channels |
| 153 | + os: ubuntu-latest |
| 154 | + rust: stable |
| 155 | + target: x86_64-unknown-linux-gnu |
| 156 | + - task: channels |
| 157 | + os: ubuntu-latest |
| 158 | + rust: beta |
| 159 | + target: x86_64-unknown-linux-gnu |
| 160 | + - task: channels |
| 161 | + os: ubuntu-latest |
| 162 | + rust: nightly |
| 163 | + target: x86_64-unknown-linux-gnu |
| 164 | + runs-on: ${{ matrix.os }} |
| 165 | + steps: |
| 166 | + - uses: actions/checkout@v2 |
| 167 | + - name: Setup linux toolchain |
| 168 | + if: contains(matrix.target, '-linux-') && startsWith(matrix.target, 'x86_64-') |
| 169 | + run: | |
| 170 | + sudo apt-get update -y |
| 171 | + sudo apt-get install -y libdrm-dev libgbm-dev |
| 172 | + - name: Setup cross linux toolchain |
| 173 | + if: contains(matrix.target, '-linux-') && !startsWith(matrix.target, 'x86_64-') |
| 174 | + run: | |
| 175 | + case "${{ matrix.target }}" in |
| 176 | + i686-*) SYSTEM_ARCH=i386 ;; |
| 177 | + arm*) SYSTEM_ARCH=armhf ;; |
| 178 | + aarch64*) SYSTEM_ARCH=arm64 ;; |
| 179 | + esac |
| 180 | + GCC_TARGET=$(printf "${{ matrix.target }}" | sed 's/-unknown-/-/' | sed 's/arm[^-]*/arm/g') |
| 181 | + ENV_TARGET=$(printf "${{ matrix.target }}" | tr '-' '_') |
| 182 | + ENV_TARGET_UC=$(printf "${ENV_TARGET}" | tr '[[:lower:]]' '[[:upper:]]') |
| 183 | + sudo rm -f /etc/apt/sources.list.d/*.list |
| 184 | + case "${{ matrix.target }}" in |
| 185 | + arm* | aarch64*) |
| 186 | + sudo tee /etc/apt/sources.list << EOF |
| 187 | + deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ focal main universe |
| 188 | + deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ focal-updates main universe |
| 189 | + deb [arch=i386,amd64] http://security.ubuntu.com/ubuntu/ focal-security main universe |
| 190 | + deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ focal main universe |
| 191 | + deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main universe |
| 192 | + deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-security main universe |
| 193 | + EOF |
| 194 | + ;; |
| 195 | + esac |
| 196 | + sudo dpkg --add-architecture ${SYSTEM_ARCH} |
| 197 | + dpkg --print-foreign-architectures |
| 198 | + sudo apt-get update -y |
| 199 | + sudo apt-get upgrade -y --fix-broken |
| 200 | + sudo apt-get install -y libdrm-dev:${SYSTEM_ARCH} libgbm-dev:${SYSTEM_ARCH} gcc-${GCC_TARGET} pkg-config-${GCC_TARGET} |
| 201 | + echo "CARGO_TARGET_${ENV_TARGET_UC}_LINKER=${GCC_TARGET}-gcc" >> $GITHUB_ENV |
| 202 | + echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV |
| 203 | + echo "PKG_CONFIG_${ENV_TARGET}=${GCC_TARGET}-pkg-config" >> $GITHUB_ENV |
| 204 | + echo "PKG_CONFIG=${GCC_TARGET}-pkg-config" >> $GITHUB_ENV |
| 205 | + echo "BINDGEN_EXTRA_CLANG_ARGS=--sysroot=/usr/${GCC_TARGET}" >> $GITHUB_ENV |
| 206 | + - name: Setup Rust |
| 207 | + uses: actions-rs/toolchain@v1 |
| 208 | + with: |
| 209 | + toolchain: ${{ matrix.rust }} |
| 210 | + target: ${{ matrix.target }} |
| 211 | + profile: minimal |
| 212 | + components: rustfmt |
| 213 | + default: true |
| 214 | + override: true |
| 215 | + - name: Cargo cache |
| 216 | + uses: actions/cache@v2 |
| 217 | + with: |
| 218 | + path: | |
| 219 | + ~/.cargo/registry |
| 220 | + ~/.cargo/git |
| 221 | + key: ${{ runner.os }}-cargo-rust_${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }} |
| 222 | + - name: Build cache |
| 223 | + if: | |
| 224 | + runner.os != 'macOS' |
| 225 | + uses: actions/cache@v2 |
| 226 | + with: |
| 227 | + path: target |
| 228 | + key: ${{ runner.os }}-build-rust_${{ matrix.rust }}-target_${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }} |
| 229 | + - name: Update deps |
| 230 | + uses: actions-rs/cargo@v1 |
| 231 | + with: |
| 232 | + command: update |
| 233 | + - name: Build sys |
| 234 | + uses: actions-rs/cargo@v1 |
| 235 | + env: |
| 236 | + RUST_LOG: bindgen=warn,bindgen::ir=error,bindgen::codegen=error |
| 237 | + with: |
| 238 | + command: build |
| 239 | + args: --manifest-path gbm-sys/Cargo.toml --target ${{ matrix.target }} --features update_bindings |
| 240 | + - name: Upload bindings |
| 241 | + if: matrix.task == 'bindings' |
| 242 | + uses: actions/upload-artifact@v2 |
| 243 | + with: |
| 244 | + name: bindings |
| 245 | + path: | |
| 246 | + gbm-sys/${{ env.GBM_SYS_BINDINGS_FILE }} |
| 247 | + LICENSE |
| 248 | + README.md |
| 249 | + - name: Build |
| 250 | + uses: actions-rs/cargo@v1 |
| 251 | + with: |
| 252 | + command: build |
| 253 | + args: --target ${{ matrix.target }} |
| 254 | + - name: Test |
| 255 | + if: contains(matrix.target, '-linux-') && (startsWith(matrix.target, 'x86_64-') || startsWith(matrix.target, 'i686-')) |
| 256 | + uses: actions-rs/cargo@v1 |
| 257 | + timeout-minutes: 12 |
| 258 | + env: |
| 259 | + RUST_BACKTRACE: full |
| 260 | + with: |
| 261 | + command: test |
| 262 | + args: --all --target ${{ matrix.target }} |
| 263 | + |
| 264 | + update-bindings: |
| 265 | + if: ${{ github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/tags/') }} |
| 266 | + needs: |
| 267 | + - test |
| 268 | + runs-on: ubuntu-latest |
| 269 | + steps: |
| 270 | + - uses: actions/checkout@v2 |
| 271 | + - name: Download bindings |
| 272 | + uses: actions/download-artifact@v2 |
| 273 | + with: |
| 274 | + name: bindings |
| 275 | + - name: Create pull request |
| 276 | + uses: peter-evans/create-pull-request@v3 |
| 277 | + with: |
| 278 | + base: ${{ github.head_ref }} |
| 279 | + commit-message: Updated bindings |
| 280 | + branch: update-bindings |
| 281 | + delete-branch: true |
| 282 | + title: Update bindings |
| 283 | + body: | |
| 284 | + Bindings should be updated to be consistent with latest changes |
| 285 | +
|
| 286 | + publish: |
| 287 | + if: github.repository == 'Smithay/gbm.rs' && startsWith(github.ref, 'refs/tags/v') |
| 288 | + needs: |
| 289 | + - format |
| 290 | + - doc |
| 291 | + - check |
| 292 | + - check-minimal |
| 293 | + - test |
| 294 | + runs-on: ubuntu-latest |
| 295 | + steps: |
| 296 | + - uses: actions/checkout@v2 |
| 297 | + - name: Setup Rust |
| 298 | + uses: actions-rs/toolchain@v1 |
| 299 | + with: |
| 300 | + toolchain: stable |
| 301 | + override: true |
| 302 | + - name: Publish crates |
| 303 | + uses: katyo/publish-crates@v1 |
| 304 | + with: |
| 305 | + registry-token: ${{ secrets.CRATES_TOKEN }} |
| 306 | + args: --no-verify |
| 307 | + #dry-run: true |
0 commit comments