ci: add dependabot config and CI workflow #3
This file contains hidden or 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: [ "*" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
schedule: | |
- cron: '20 7 * * *' | |
env: | |
CARGO_TERM_COLOR: always | |
permissions: | |
contents: read | |
jobs: | |
test: | |
name: test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# rust channels | |
- build: stable | |
os: ubuntu-24.04 | |
rust: stable | |
target: x86_64-unknown-linux-gnu | |
- build: beta | |
os: ubuntu-24.04 | |
rust: beta | |
target: x86_64-unknown-linux-gnu | |
- build: nightly | |
os: ubuntu-24.04 | |
rust: nightly | |
target: x86_64-unknown-linux-gnu | |
# release platforms | |
- build: linux-amd64 | |
os: ubuntu-24.04 | |
rust: stable | |
target: x86_64-unknown-linux-musl | |
- build: linux-arm64 | |
os: ubuntu-24.04-arm | |
rust: stable | |
target: aarch64-unknown-linux-musl | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
- run: rustup target add ${{ matrix.target }} | |
- run: cargo build --workspace --target ${{ matrix.target }} --release | |
- run: cargo run --target ${{ matrix.target }} --release -- --help | |
- run: cargo test --workspace --target ${{ matrix.target }} --release | |
env: | |
NO_COLOR: "true" | |
rustfmt: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: rustfmt | |
- name: Check formatting | |
run: cargo fmt --all --check | |
clippy: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: clippy | |
- name: Lint code with Clippy | |
run: cargo clippy --all-targets -- -D warnings | |
dependabot-auto-merge: | |
needs: | |
- test | |
- rustfmt | |
- clippy | |
permissions: | |
contents: write | |
pull-requests: write | |
runs-on: ubuntu-24.04 | |
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }} | |
steps: | |
- run: gh pr merge --auto --rebase "$PR_URL" | |
env: | |
PR_URL: ${{github.event.pull_request.html_url}} | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |