Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
open-pull-requests-limit: 10
commit-message:
prefix: "chore"
include: "scope"
reviewers:
- "@me"
assignees:
- "@me"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
open-pull-requests-limit: 5
commit-message:
prefix: "chore"
include: "scope"
126 changes: 126 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- name: Check formatting
run: cargo fmt --all -- --check
if: matrix.rust == 'stable'

- name: Run clippy
run: cargo clippy --all-targets --all-features
# -- -D warnings
if: matrix.rust == 'stable'

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose

build:
name: Build
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: col
asset_name: col-linux-x86_64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: col.exe
asset_name: col-windows-x86_64.exe
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: col
asset_name: col-macos-x86_64

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- name: Build release
run: cargo build --release --target ${{ matrix.target }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}

security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rustsec/audit-check@v1.4.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
70 changes: 70 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Coverage

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Install grcov
run: cargo install grcov

- name: Build
run: cargo build
env:
RUSTFLAGS: '-Cinstrument-coverage'
LLVM_PROFILE_FILE: 'codecov-instrumentation-%p-%m.profraw'

- name: Run tests
run: cargo test
env:
RUSTFLAGS: '-Cinstrument-coverage'
LLVM_PROFILE_FILE: 'codecov-instrumentation-%p-%m.profraw'

- name: Generate coverage report
run: |
grcov . \
--binary-path ./target/debug/ \
--source-dir . \
--output-type lcov \
--branch \
--ignore-not-existing \
--ignore "/*" \
--ignore "target/*" \
--ignore "tests/*" \
--output-path coverage.lcov

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: coverage.lcov
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
30 changes: 30 additions & 0 deletions .github/workflows/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
1. **CI Workflow** (`.github/workflows/ci.yml`)

* Triggered on pushes to the `main`/`develop` branches and on PR creation
* Tests on multiple Rust versions (stable, beta, nightly)
* Includes code formatting checks, Clippy linting, build, and test
* Builds binaries for Linux, Windows, and macOS
* Includes security audit checks

2. **Release Workflow** (`.github/workflows/release.yml`)

* Triggered when pushing a tag (v*)
* Automatically creates a GitHub Release
* Builds and uploads binaries for multiple platforms
* Optionally publishes to crates.io (requires CRATES_TOKEN configuration)

3. **Dependency Update Workflow** (`.github/workflows/update-deps.yml`)

* Runs automatically every Monday
* Updates dependency versions in `Cargo.lock`
* Automatically creates a PR if updates are available

4. **Code Coverage Workflow** (`.github/workflows/coverage.yml`)

* Generates code coverage reports
* Uploads to Codecov (optional)

5. **Dependabot Configuration** (`.github/dependabot.yml`)

* Automatically monitors Rust dependencies and GitHub Actions updates
* Creates update PRs weekly
124 changes: 124 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Release

on:
push:
tags:
- 'v*'

env:
CARGO_TERM_COLOR: always

jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.id }}
steps:
- uses: actions/checkout@v4

- name: Get tag name
id: tag_name
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_name.outputs.TAG }}
release_name: Release ${{ steps.tag_name.outputs.TAG }}
draft: false
prerelease: false
body: |
## 更新内容 / What's Changed

请查看提交历史了解详细更改。
See commit history for detailed changes.

## 下载 / Downloads

- **Linux**: col-linux-x86_64
- **Windows**: col-windows-x86_64.exe
- **macOS**: col-macos-x86_64

build-and-upload:
name: Build and Upload
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: col
asset_name: col-linux-x86_64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: col.exe
asset_name: col-windows-x86_64.exe
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: col
asset_name: col-macos-x86_64

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Build release
run: cargo build --release --target ${{ matrix.target }}

- name: Strip binary (Linux and macOS)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/octet-stream

publish-crate:
name: Publish to crates.io
needs: create-release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CRATES_TOKEN }}
continue-on-error: true
Loading