chore: cargo fmt #1
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: rust | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
push: | |
branches: | |
- main | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
fmt: | |
name: Check formatting | |
runs-on: windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Stable rust toolchain | |
run: rustup toolchain install stable --profile minimal | |
- name: Check formatting | |
run: cargo fmt --all -- --check | |
clippy: | |
name: Clippy | |
runs-on: windows-latest | |
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Stable rust toolchain | |
run: rustup toolchain install stable --profile minimal | |
- name: Add Clippy | |
run: rustup component add clippy | |
- name: Rust cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
prefix-key: "rust-stable" | |
shared-key: "clippy" | |
- name: Install cargo-binstall | |
run: wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-gnu.tgz -O - | tar -xz -C $HOME/.cargo/bin | |
- name: Install sarif-fmt & clippy-sarif | |
run: cargo binstall --no-confirm --force sarif-fmt clippy-sarif | |
- name: Run Clippy | |
run: cargo clippy --message-format=json | clippy-sarif | tee results.sarif | sarif-fmt | |
- name: Upload SARIF file | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: results.sarif | |
build: | |
name: Build ${{ matrix.platform.os_name }} [rust ${{ matrix.toolchain }}] | |
runs-on: ${{ matrix.platform.os }} | |
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | |
strategy: | |
matrix: | |
platform: | |
- os_name: Windows-x86_64 | |
os: windows-latest | |
target: x86_64-pc-windows-gnu | |
toolchain: | |
- nightly | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup ${{ matrix.toolchain }} toolchain | |
run: rustup toolchain install ${{ matrix.toolchain }} --target ${{ matrix.platform.target }} --profile minimal | |
- name: Rust cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
prefix-key: "rust-${{ matrix.toolchain }}" | |
shared-key: "build-${{ matrix.platform.target }}" | |
- name: Build | |
run: cargo build --target ${{ matrix.platform.target }} |