name: Rust
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: cargo test --verbose
property-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run property based tests
run: cargo test --test property_tests --verbose
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy
- name: Run clippy
run: cargo clippy -- -D warnings
performance-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run performance tests
run: cargo test --release --test performance_tests -- --nocapture
set-local-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Get Version from Cargo.toml
id: get_version
run: |
VERSION=$(awk -F '"' '/^version =/ {print $2}' Cargo.toml)
echo "Version of the Rust library is $VERSION"
echo "::set-output name=LIB_LOCAL_VERSION::$VERSION"
- name: Print Version
run: echo "The version of the Rust library is ${{ steps.get_version.outputs.LIB_LOCAL_VERSION }}"
cargo-push:
needs: [test, property-tests, clippy]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Publish crates
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_TOKEN }}
ignore-unpublished-changes: true