add rust build workflow
This commit is contained in:
parent
fc8596258a
commit
7af748e5ad
1 changed files with 73 additions and 0 deletions
73
.github/workflows/build.yml
vendored
Normal file
73
.github/workflows/build.yml
vendored
Normal file
|
@ -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 }}
|
Loading…
Add table
Reference in a new issue