Automated Formatting Fixes #201
Workflow file for this run
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 CI | |
on: | |
push: | |
branches: ['**'] | |
pull_request: | |
branches: ['**'] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
issues: write | |
actions: write | |
steps: | |
- name: Generate GitHub App Token | |
id: generate_token | |
uses: tibdex/github-app-token@v1 | |
with: | |
app_id: ${{ vars.BTL_ACTIONS_BOT_APP_ID }} | |
private_key: ${{ secrets.BTL_ACTIONS_BOT_PRIVATE_KEY }} | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ steps.generate_token.outputs.token }} | |
- name: Install Rust stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt, clippy | |
override: true | |
- name: Cache Cargo registry | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache Cargo build | |
uses: actions/cache@v3 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-build- | |
- name: Run cargo fmt | |
run: cargo fmt --all | |
- name: Check if any files were formatted | |
id: changes | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
echo "changes=true" >> $GITHUB_OUTPUT | |
else | |
echo "changes=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Create Pull Request with Formatting Fixes | |
if: steps.changes.outputs.changes == 'true' | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ steps.generate_token.outputs.token }} | |
commit-message: "Apply rustfmt formatting" | |
branch: formatting-fixes | |
title: "Automated Formatting Fixes" | |
body: | | |
This pull request applies rustfmt formatting to the codebase. | |
labels: automated fix | |
- name: Run Clippy | |
if: steps.changes.outputs.changes == 'false' | |
run: cargo clippy --all-targets --all-features -- -D warnings | |
- name: Build | |
if: steps.changes.outputs.changes == 'false' | |
run: cargo build --verbose | |
- name: Run tests | |
if: steps.changes.outputs.changes == 'false' | |
run: cargo test --verbose | |
- name: Run cargo audit | |
if: steps.changes.outputs.changes == 'false' | |
uses: actions-rs/audit-check@v1 |