name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --release
- name: Run tests
run: cargo test --release
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Check formatting
run: cargo fmt --check
- name: Generate CLI help (README.md)
run: cargo run --bin gendoc
- name: Commit updated README.md if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if ! git diff --quiet README.md; then
git add README.md
git commit -m "Update README from clap docs"
git push
else
echo "No changes to README.md"
fi
if: github.ref == 'refs/heads/main'