diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..426caae --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: PR Validation + +on: + pull_request: + branches: + - main + +env: + CARGO_TERM_COLOR: always + +jobs: + build-and-test: + runs-on: ${{ matrix.platform.os }} + + strategy: + fail-fast: false + + matrix: + platform: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + command: cargo + + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + command: cross + + - os: windows-latest + target: x86_64-pc-windows-msvc + command: cargo + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache Cargo and cross + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + ~/.cargo/bin + key: ${{ matrix.platform.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ matrix.platform.target }}-cargo + + - name: Install cross + if: matrix.platform.command == 'cross' + run: | + if ! command -v cross &>/dev/null; then + cargo install cross + fi + + - name: Build + run: ${{ matrix.platform.command }} build --target ${{ matrix.platform.target }} + + - name: Test + run: ${{ matrix.platform.command }} test --target ${{ matrix.platform.target }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index 000bb2c..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Rust - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose