name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Run tests
run: cargo test
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run rustfmt
run: cargo fmt -- --check
- name: Update README badge
run: |
sed -i 's|build-.*\.svg|build-${{ github.sha }}.svg|g' README.md
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "Update build badge" || true
git push origin main || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}