|
| 1 | +# Copied from https://github.com/rerun-io/rerun_template |
| 2 | +on: [push, pull_request] |
| 3 | + |
| 4 | +name: Rust |
| 5 | + |
| 6 | +env: |
| 7 | + RUSTFLAGS: -D warnings |
| 8 | + RUSTDOCFLAGS: -D warnings |
| 9 | + |
| 10 | +jobs: |
| 11 | + rust-check: |
| 12 | + name: Rust |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - uses: actions-rs/toolchain@v1 |
| 18 | + with: |
| 19 | + profile: default |
| 20 | + toolchain: 1.76.0 |
| 21 | + override: true |
| 22 | + |
| 23 | + - name: Install packages (Linux) |
| 24 | + if: runner.os == 'Linux' |
| 25 | + |
| 26 | + with: |
| 27 | + packages: libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev |
| 28 | + version: 1.0 |
| 29 | + execute_install_scripts: true |
| 30 | + |
| 31 | + - name: Set up cargo cache |
| 32 | + uses: Swatinem/rust-cache@v2 |
| 33 | + |
| 34 | + - name: Rustfmt |
| 35 | + uses: actions-rs/cargo@v1 |
| 36 | + with: |
| 37 | + command: fmt |
| 38 | + args: --all -- --check |
| 39 | + |
| 40 | + - name: Lint vertical spacing |
| 41 | + run: ./scripts/lint.py |
| 42 | + |
| 43 | + - name: check --all-features |
| 44 | + uses: actions-rs/cargo@v1 |
| 45 | + with: |
| 46 | + command: check |
| 47 | + args: --all-features --all-targets |
| 48 | + |
| 49 | + - name: check default features |
| 50 | + uses: actions-rs/cargo@v1 |
| 51 | + with: |
| 52 | + command: check |
| 53 | + args: --all-targets |
| 54 | + |
| 55 | + - name: check --no-default-features |
| 56 | + uses: actions-rs/cargo@v1 |
| 57 | + with: |
| 58 | + command: check |
| 59 | + args: --no-default-features --lib --all-targets |
| 60 | + |
| 61 | + - name: Test doc-tests |
| 62 | + uses: actions-rs/cargo@v1 |
| 63 | + with: |
| 64 | + command: test |
| 65 | + args: --doc --all-features |
| 66 | + |
| 67 | + - name: cargo doc --lib |
| 68 | + uses: actions-rs/cargo@v1 |
| 69 | + with: |
| 70 | + command: doc |
| 71 | + args: --lib --no-deps --all-features |
| 72 | + |
| 73 | + - name: cargo doc --document-private-items |
| 74 | + uses: actions-rs/cargo@v1 |
| 75 | + with: |
| 76 | + command: doc |
| 77 | + args: --document-private-items --no-deps --all-features |
| 78 | + |
| 79 | + - name: Build tests |
| 80 | + uses: actions-rs/cargo@v1 |
| 81 | + with: |
| 82 | + command: test |
| 83 | + args: --all-features --no-run |
| 84 | + |
| 85 | + - name: Run test |
| 86 | + uses: actions-rs/cargo@v1 |
| 87 | + with: |
| 88 | + command: test |
| 89 | + args: --all-features |
| 90 | + |
| 91 | + - name: Clippy |
| 92 | + uses: actions-rs/cargo@v1 |
| 93 | + with: |
| 94 | + command: clippy |
| 95 | + args: --all-targets --all-features -- -D warnings |
| 96 | + |
| 97 | + # --------------------------------------------------------------------------- |
| 98 | + |
| 99 | + check_wasm: |
| 100 | + name: Check wasm32 |
| 101 | + runs-on: ubuntu-latest |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v4 |
| 104 | + - uses: actions-rs/toolchain@v1 |
| 105 | + with: |
| 106 | + profile: minimal |
| 107 | + toolchain: 1.76.0 |
| 108 | + target: wasm32-unknown-unknown |
| 109 | + override: true |
| 110 | + |
| 111 | + - name: Set up cargo cache |
| 112 | + uses: Swatinem/rust-cache@v2 |
| 113 | + |
| 114 | + - name: Check wasm32 |
| 115 | + uses: actions-rs/cargo@v1 |
| 116 | + with: |
| 117 | + command: check |
| 118 | + args: --target wasm32-unknown-unknown --lib |
| 119 | + |
| 120 | + - name: Clippy wasm32 |
| 121 | + env: |
| 122 | + CLIPPY_CONF_DIR: "scripts/clippy_wasm" # Use scripts/clippy_wasm/clippy.toml |
| 123 | + run: cargo clippy --target wasm32-unknown-unknown --lib -- -D warnings |
| 124 | + |
| 125 | + # --------------------------------------------------------------------------- |
| 126 | + |
| 127 | + cargo-deny: |
| 128 | + name: Check Rust dependencies (cargo-deny) |
| 129 | + runs-on: ubuntu-latest |
| 130 | + steps: |
| 131 | + - uses: actions/checkout@v3 |
| 132 | + - uses: EmbarkStudios/cargo-deny-action@v1 |
| 133 | + with: |
| 134 | + rust-version: "1.76.0" |
| 135 | + log-level: warn |
| 136 | + command: check |
| 137 | + |
| 138 | + # --------------------------------------------------------------------------- |
| 139 | + |
| 140 | + trunk: |
| 141 | + name: trunk |
| 142 | + runs-on: ubuntu-latest |
| 143 | + steps: |
| 144 | + - uses: actions/checkout@v4 |
| 145 | + - uses: actions-rs/toolchain@v1 |
| 146 | + with: |
| 147 | + profile: minimal |
| 148 | + toolchain: 1.76.0 |
| 149 | + target: wasm32-unknown-unknown |
| 150 | + override: true |
| 151 | + - name: Download and install Trunk binary |
| 152 | + run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf- |
| 153 | + - name: Build |
| 154 | + run: ./trunk build |
0 commit comments