diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..db7e878 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,73 @@ +name: Rust CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build-and-test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose + + cross-compile: + runs-on: ${{ matrix.host }} + strategy: + matrix: + include: + - host: ubuntu-latest + target: x86_64-pc-windows-gnu + - host: ubuntu-latest + target: x86_64-apple-darwin + - host: ubuntu-latest + target: aarch64-apple-darwin + - host: macOS-latest + target: x86_64-unknown-linux-gnu + - host: macOS-latest + target: x86_64-pc-windows-gnu + + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.target }} + override: true + - name: Install dependencies + run: | + if [ "${{ matrix.host }}" = "ubuntu-latest" ]; then + sudo apt-get update + sudo apt-get install -y mingw-w64 + fi + - name: Cross-compile + run: cargo build --verbose --target ${{ matrix.target }}