ci: 👷 新增CI配置,用于GitHub Actions自动测试(测试性提交) #1
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: CI | |
# 🔗CI语法参考:https://docs.github.com/zh/actions/writing-workflows/workflow-syntax-for-github-actions | |
# ! 📌【2024-09-13 23:41:22】不建议在`name`中附带空格:会影响到shields.io中的badge链接 | |
on: | |
push: # 推送到特定分支 | |
branches: | |
- main | |
- dev # ! ❌【2024-09-14 12:23:09】目前禁用:`dev`分支用于快速开发,没必要在推送时触发CI | |
- 'test**' | |
label: # 创建标签 | |
types: | |
- created | |
pull_request: # 拉取请求 | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build_and_test: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: Swatinem/rust-cache@v2 | |
- name: setup toolchain | |
uses: hecrj/setup-rust-action@v1 | |
with: | |
rust-version: stable | |
# ! ❌【2024-09-14 15:42:55】暂时不用:该repo部分测试需要外部CIN运行时支持(如Python),尚未兼容各操作系统 | |
# TODO: 🚧【2024-09-14 15:44:08】用类似「平台特定程序包」的方式 兼容远程与其它操作系统(预估难度:长期、复杂) | |
- name: cargo test | |
run: cargo test --all-features | |
- name: rustfmt | |
run: cargo fmt --all -- --check | |
- name: clippy | |
run: cargo clippy --all --all-features --tests -- -D warnings | |
# 📌【2024-08-25 00:23:12】暂不启用``参数:暂且不对clippy采取过于严格的限制 | |
# 📝【2024-08-25 00:33:21】现在可在Cargo.toml中 允许特定clippy限制(诸如:放宽对文档注释的要求) |