You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB
YAML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 发布标签触发的跨平台质量检查格式、编译、Clippy 和单元测试。
name: Rust
on:
# 仅版本号标签触发,例如 0.5.0。
push:
tags: ["[0-9]+.[0-9]+.[0-9]+*"]
env:
CARGO_TERM_COLOR: always
jobs:
rust:
name: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os }}-latest
strategy:
# 任一平台失败后停止其他矩阵任务,尽快暴露发布阻塞。
fail-fast: true
matrix:
include:
- os: ubuntu
- os: macos
- os: windows
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: fmt
# 确保仓库源码已经按 rustfmt 规则提交。
run: cargo fmt --all -- --check
- name: build
# 当前只由标签触发;条件保留了历史 PR 工作流的 Windows 例外。
if: matrix.os != 'windows' || github.event_name != 'pull_request'
run: cargo build --verbose
- name: clippy
if: matrix.os != 'windows' || github.event_name != 'pull_request'
# 暂未把警告提升为错误,便于现有代码继续发布。
run: cargo clippy --
- name: test
if: matrix.os != 'windows' || github.event_name != 'pull_request'
run: cargo test --verbose -- --nocapture