ci: add ci for linting, formatting and publishing #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
'on': | |
push: | |
branches: | |
- master | |
pull_request: null | |
release: | |
types: | |
- published | |
concurrency: | |
group: '${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}' | |
cancel-in-progress: true | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
cargo-build-workspace: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- uses: Swatinem/rust-cache@v1 | |
- uses: actions-rs/cargo@v1 | |
name: Cargo Build Workspace | |
with: | |
command: build | |
args: '--workspace --all-features --all-targets' | |
env: | |
RUSTFLAGS: '-D warnings' | |
cargo-clippy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- uses: Swatinem/rust-cache@v1 | |
- name: Check Clippy Linter | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clippy | |
args: '--all-features --all-targets -- -D warnings' | |
cargo-toml-fmt-check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Install Cargo.toml linter | |
uses: baptiste0928/cargo-install@v1 | |
with: | |
crate: cargo-toml-lint | |
version: '0.1' | |
- name: Run Cargo.toml linter | |
run: git ls-files | grep Cargo.toml$ | xargs --verbose -n 1 cargo-toml-lint | |
cargo-fmt-check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Check Formatting | |
uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: '--all -- --check' | |
cargo-test-workspace: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- uses: Swatinem/rust-cache@v1 | |
- name: Install rg | |
run: sudo apt-get install ripgrep | |
- name: Run tests | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
cargo-unused-deps-check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
- uses: Swatinem/rust-cache@v1 | |
- name: Install cargo-udeps | |
uses: actions-rs/cargo@v1 | |
with: | |
command: install | |
args: cargo-udeps | |
- name: Check Unused Deps | |
uses: actions-rs/cargo@v1 | |
with: | |
command: udeps | |
args: '--all-targets' | |
publish: | |
needs: | |
- cargo-build-workspace | |
- cargo-clippy | |
- cargo-fmt-check | |
- cargo-test-workspace | |
- cargo-unused-deps-check | |
if: github.event_name == 'release' && github.event.action == 'published' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Publish crate | |
uses: xgreenx/publish-crates@v1 | |
with: | |
publish-delay: 30000 | |
registry-token: '${{ secrets.CARGO_REGISTRY_TOKEN }}' | |