Add rustfmt and clippy steps to Rust CI workflow #40
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: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
env: | |
CARGO_TERM_COLOR: always | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
MAX_LENGTH: 100 | |
MAX_CHARS: 5000 | |
LANGUAGE: "en" | |
TIMEOUT: 30 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Update system packages | |
run: sudo apt-get update | |
- name: Install latest Git | |
run: sudo apt-get install -y git | |
- name: Cache cargo registry | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
override: true | |
default: true | |
profile: minimal | |
components: rustfmt,clippy | |
- name: Build git-ai-hook | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --bin git-ai-hook --no-default-features | |
- name: Install git-ai | |
uses: actions-rs/cargo@v1 | |
with: | |
command: install | |
args: --path . --bin git-ai --no-default-features | |
- name: Run tests | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
- name: Rust fmt | |
uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: --all -- --check | |
- name: Rust clippy | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clippy | |
args: --all -- --deny warnings | |
- name: Test install hook | |
run: git ai install |