name: Lints, Tests, Deploy
on:
- push
- pull_request
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
toolchain: ["stable", "beta", "nightly"]
features: ["libm", "std"]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
default: true
profile: minimal
components: rustfmt, clippy
- name: Display rust version
run: |
rustc --version
cargo clippy -- --version
cargo fmt -- --version
- name: Lint
run: cargo clippy --no-default-features --features "${{ matrix.features }}" -- -D warnings
if: matrix.toolchain != 'nightly'
- name: Format
run: cargo fmt -- --check
if: matrix.toolchain != 'nightly'
- name: Tests
run: cargo test --no-default-features --features "${{ matrix.features }}"
- name: Doc Tests
run: cargo test --doc --no-default-features --features "${{ matrix.features }}"
deploy-rust:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
profile: minimal
- name: Test publishing
run: cargo publish --dry-run
if: github.ref != 'refs/heads/master'
- name: Login to crates.io
run: cargo login $TOKEN
if: github.ref == 'refs/heads/master'
env:
TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io
run: cargo publish
if: github.ref == 'refs/heads/master'