Skip to content

删除无用代码

删除无用代码 #3

Workflow file for this run

name: Auto Format
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
format-check:
name: Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: |
if ! cargo fmt --all -- --check; then
echo "❌ 代码格式不符合规范!"
echo "请运行以下命令修复格式问题:"
echo " cargo fmt --all"
echo ""
echo "或者使用构建脚本:"
echo " ./scripts/build.sh format"
exit 1
else
echo "✅ 代码格式检查通过!"
fi
auto-format:
name: Auto Format (PR only)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Format code
run: cargo fmt --all
- name: Check for changes
id: verify-changed-files
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Commit formatted code
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "🎨 Auto-format code with rustfmt"
git push