ci: add commit-lint in CI (#50)
no need too many workflows's yaml file, for ci we just need one. Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
This commit is contained in:
parent
4e6b222e09
commit
b9e192275b
5 changed files with 149 additions and 152 deletions
149
.github/workflows/ci.yml
vendored
Normal file
149
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, release ]
|
||||
tags:
|
||||
- 'release-*'
|
||||
pull_request:
|
||||
branches: [ main, release ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
ARTIFACT_DIR: release-artifacts
|
||||
|
||||
jobs:
|
||||
commit-lint:
|
||||
name: Lint Commit Messages
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Install commitlint
|
||||
run: |
|
||||
npm install --save-dev @commitlint/cli @commitlint/config-conventional
|
||||
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
|
||||
|
||||
- name: Lint commit messages
|
||||
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
|
||||
|
||||
fmt:
|
||||
name: Code Formatting
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Check formatting
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
clippy:
|
||||
name: Lint with Clippy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: ${{ runner.os }}-cargo-
|
||||
|
||||
- name: Run clippy
|
||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||
|
||||
test:
|
||||
name: Run Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# install nodejs
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Set up Python
|
||||
run: uv python install
|
||||
|
||||
- name: Create venv for python
|
||||
run: uv venv
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: ${{ runner.os }}-cargo-
|
||||
|
||||
- name: Run tests
|
||||
run: cargo test --all-features
|
||||
|
||||
release:
|
||||
name: Release crates
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/release' || startsWith(github.ref, 'refs/tags/release')
|
||||
needs: [fmt, clippy, test]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: ${{ runner.os }}-cargo-
|
||||
|
||||
- name: Cargo login
|
||||
run: cargo login ${{ secrets.CRATES_TOKEN }}
|
||||
|
||||
- name: Publish macros dry run
|
||||
run: cargo publish -p rmcp-macros --dry-run
|
||||
continue-on-error: true
|
||||
|
||||
- name: Publish rmcp dry run
|
||||
run: cargo publish -p rmcp --dry-run
|
||||
continue-on-error: true
|
||||
|
||||
- name: Publish macro
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/release') }}
|
||||
continue-on-error: true
|
||||
run: cargo publish -p rmcp-macros
|
||||
|
||||
- name: Publish rmcp
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/release') }}
|
||||
continue-on-error: true
|
||||
run: cargo publish -p rmcp
|
||||
33
.github/workflows/clippy.yml
vendored
33
.github/workflows/clippy.yml
vendored
|
|
@ -1,33 +0,0 @@
|
|||
name: Clippy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
clippy:
|
||||
name: Lint with Clippy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: ${{ runner.os }}-cargo-
|
||||
|
||||
- name: Run clippy
|
||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||
23
.github/workflows/fmt.yml
vendored
23
.github/workflows/fmt.yml
vendored
|
|
@ -1,23 +0,0 @@
|
|||
name: Format
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
fmt:
|
||||
name: Code Formatting
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Check formatting
|
||||
run: cargo fmt --all -- --check
|
||||
54
.github/workflows/release.yml
vendored
54
.github/workflows/release.yml
vendored
|
|
@ -1,54 +0,0 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ release ]
|
||||
tags:
|
||||
- 'release-*'
|
||||
pull_request:
|
||||
branches: [ release ]
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
ARTIFACT_DIR: release-artifacts
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release crates
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: ${{ runner.os }}-cargo-
|
||||
|
||||
- name: Check formatting
|
||||
run: cargo fmt --all -- --check
|
||||
- name: Run clippy
|
||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||
- name: Cargo login
|
||||
run: cargo login ${{ secrets.CRATES_TOKEN }}
|
||||
- name: Publish macros dry run
|
||||
run: cargo publish -p rmcp-macros --dry-run
|
||||
continue-on-error: true
|
||||
- name: Publish rmcp dry run
|
||||
run: cargo publish -p rmcp --dry-run
|
||||
continue-on-error: true
|
||||
- name: Publish macro
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/release') }}
|
||||
continue-on-error: true
|
||||
run: cargo publish -p rmcp-macros
|
||||
- name: Publish rmcp
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/release') }}
|
||||
continue-on-error: true
|
||||
run: cargo publish -p rmcp
|
||||
|
||||
42
.github/workflows/test.yml
vendored
42
.github/workflows/test.yml
vendored
|
|
@ -1,42 +0,0 @@
|
|||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Run Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
# install nodejs
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '20'
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
- name: Set up Python
|
||||
run: uv python install
|
||||
- name: Create venv for python
|
||||
run: uv venv
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: ${{ runner.os }}-cargo-
|
||||
|
||||
- name: Run tests
|
||||
run: cargo test --all-features
|
||||
Loading…
Reference in a new issue