|
| 1 | +name: PR Build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened] |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - master |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ${{ matrix.os.imageName }} |
| 13 | + timeout-minutes: 30 |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + rust_toolchain: ["stable"] |
| 17 | + os: |
| 18 | + - target_platform: x86_64-unknown-linux-gnu |
| 19 | + imageName: ubuntu-latest |
| 20 | + cross: "true" |
| 21 | + - target_platform: x86_64-unknown-linux-musl |
| 22 | + imageName: ubuntu-latest |
| 23 | + cross: "true" |
| 24 | + - target_platform: aarch64-unknown-linux-musl |
| 25 | + imageName: ubuntu-latest |
| 26 | + cross: "true" |
| 27 | + - target_platform: x86_64-apple-darwin |
| 28 | + imageName: "macOS-latest" |
| 29 | + - target_platform: aarch64-apple-darwin |
| 30 | + imageName: "macOS-latest" |
| 31 | + - target_platform: x86_64-pc-windows-msvc |
| 32 | + imageName: windows-latest |
| 33 | + |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v3 |
| 36 | + - name: Cache cargo & target directories |
| 37 | + uses: Swatinem/rust-cache@v2 |
| 38 | + with: |
| 39 | + prefix-key: v2-rust |
| 40 | + key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 41 | + restore-keys: | |
| 42 | +
|
| 43 | + - uses: rui314/setup-mold@v1 |
| 44 | + - uses: actions-rs/toolchain@v1 |
| 45 | + with: |
| 46 | + toolchain: ${{ matrix.rust_toolchain }} |
| 47 | + target: ${{ matrix.os.target_platform }} |
| 48 | + override: true |
| 49 | + profile: minimal |
| 50 | + - name: Install cross |
| 51 | + if: matrix.os.cross == 'true' |
| 52 | + run: cargo install cross --git https://github.com/cross-rs/cross |
| 53 | + - name: Run cargo check |
| 54 | + uses: actions-rs/cargo@v1 |
| 55 | + with: |
| 56 | + use-cross: ${{ matrix.os.cross == 'true' }} |
| 57 | + command: check |
| 58 | + args: --target ${{ matrix.os.target_platform }} |
| 59 | + - name: Run cargo build |
| 60 | + uses: actions-rs/cargo@v1 |
| 61 | + with: |
| 62 | + use-cross: ${{ matrix.os.cross == 'true' }} |
| 63 | + command: build |
| 64 | + args: --release --target ${{ matrix.os.target_platform }} |
| 65 | + - name: Run cargo test |
| 66 | + uses: actions-rs/cargo@v1 |
| 67 | + with: |
| 68 | + use-cross: ${{ matrix.os.cross == 'true' }} |
| 69 | + command: test |
| 70 | + args: --target ${{ matrix.os.target_platform }} |
0 commit comments