Skip to content

update workflow

update workflow #13

Workflow file for this run

name: Rust
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
# 新增:检查代码格式
- name: fmt
uses: actions-rs/cargo@v1
with:
command: fmt
# --check 参数让命令在发现未格式化的代码时失败,而不是直接修改文件
args: -- --check
# 新增:运行 Clippy lints
- name: clippy
uses: actions-rs/cargo@v1
with:
command: clippy
# --all-features 确保检查所有特性门控后的代码
# -- -D warnings 将所有 Clippy 警告(warnings)视为错误(Deny),导致 CI 失败
args: --all-features -- -D warnings
# 原有的步骤保持不变
- name: Install tools
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-all-features
- name: Release build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test-all-features
args: --verbose
- name: Check if can be packaged
uses: actions-rs/cargo@v1
with:
command: package
# publish:
# runs-on: ubuntu-latest
# needs: [build]
# if: startsWith(github.ref, 'refs/tags/')
# steps:
# - uses: actions/checkout@v3
# - name: Publish to Crates.io
# uses: actions-rs/cargo@v1
# with:
# command: publish
# env:
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}