| 1 | name: Rust |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: [ "main" ] |
| 6 | pull_request: |
| 7 | branches: [ "main" ] |
| 8 | |
| 9 | env: |
| 10 | CARGO_TERM_COLOR: always |
| 11 | RUSTFLAGS: "-D warnings" |
| 12 | |
| 13 | jobs: |
| 14 | build: |
| 15 | runs-on: ubuntu-latest |
| 16 | |
| 17 | steps: |
| 18 | - uses: actions/checkout@v3 |
| 19 | - name: Format |
| 20 | run: cargo fmt --check |
| 21 | - name: Clippy |
| 22 | run: cargo clippy && cargo clippy --all-features |
| 23 | - name: Build |
| 24 | run: cargo build --verbose --all-features |
| 25 | - name: Run tests |
| 26 | run: cargo test --verbose |
| 27 | - name: Doc |
| 28 | run: cargo doc --all-features |
| 29 | - name: Run device tests |
| 30 | run: sudo -E env "PATH=$PATH" cargo test --tests --features device-test |
| 31 | |
| 32 | cross-linux: |
| 33 | runs-on: ubuntu-latest |
| 34 | strategy: |
| 35 | matrix: |
| 36 | target: |
| 37 | - arch: 'aarch64' |
| 38 | rust: 'aarch64-unknown-linux-gnu' |
| 39 | os: 'aarch64-linux-gnu' |
| 40 | - arch: 'arm' |
| 41 | rust: 'armv7-unknown-linux-gnueabihf' |
| 42 | os: 'arm-linux-gnueabihf' |
| 43 | - arch: 'i386' |
| 44 | rust: 'i686-unknown-linux-gnu' |
| 45 | os: 'i686-linux-gnu' |
| 46 | |
| 47 | steps: |
| 48 | - uses: actions/checkout@v3 |
| 49 | - name: Install Rust toolchain |
| 50 | uses: actions-rs/toolchain@v1 |
| 51 | with: |
| 52 | toolchain: stable |
| 53 | override: true |
| 54 | components: rustfmt, clippy |
| 55 | target: ${{ matrix.target.rust }} |
| 56 | - name: Install QEMU and toolchain |
| 57 | run: | |
| 58 | sudo apt update |
| 59 | sudo apt -y install qemu-user qemu-user-static gcc-${{ matrix.target.os }} binutils-${{ matrix.target.os }} binutils-${{ matrix.target.os }}-dbg |
| 60 | - name: Append .cargo config |
| 61 | run: | |
| 62 | echo "[target.${{ matrix.target.rust }}]" >> ~/.cargo/config |
| 63 | echo "runner = \"qemu-${{ matrix.target.arch }} -L /usr/${{ matrix.target.os }}/\"" >> ~/.cargo/config |
| 64 | echo "linker = \"${{ matrix.target.os }}-gcc\"" >> ~/.cargo/config |
| 65 | - name: Build |
| 66 | run: cargo build --target ${{ matrix.target.rust }} |
| 67 | - name: Run tests |
| 68 | run: cargo test --target ${{ matrix.target.rust }} |
| 69 | - name: Doc |
| 70 | run: cargo doc --target ${{ matrix.target.rust }} |
| 71 | |
| 72 | freebsd: |
| 73 | runs-on: ubuntu-latest |
| 74 | name: build (FreeBSD) |
| 75 | steps: |
| 76 | - uses: actions/checkout@v3 |
| 77 | - name: Build |
| 78 | uses: vmactions/freebsd-vm@v1 |
| 79 | with: |
| 80 | envs: 'RUSTFLAGS' |
| 81 | usesh: true |
| 82 | prepare: | |
| 83 | pkg install -y curl |
| 84 | |
| 85 | run: | |
| 86 | curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal -y |
| 87 | . "$HOME/.cargo/env" |
| 88 | cargo build --all-features |
| 89 | cargo test |