diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57c6dbe..bbae663 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,11 +11,12 @@ on: - main permissions: - contents: write + contents: read jobs: - build-rust: + validate: strategy: + fail-fast: false matrix: platform: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{matrix.platform}} @@ -45,13 +46,29 @@ jobs: - name: Lint rust sources run: cargo clippy --workspace --all-targets --all-features -- -D warnings - - name: Execute rust tests - run: cargo nextest run --all-features --no-tests=pass + - name: Execute rust tests with coverage + run: cargo llvm-cov nextest --all-features --no-tests=pass --lcov --output-path lcov.info + - name: Upload coverage report + if: matrix.platform == 'ubuntu-latest' + uses: codecov/codecov-action@v4 + with: + files: lcov.info + fail_ci_if_error: false + + release: + if: startsWith(github.ref, 'refs/tags/') + needs: validate + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Generate a changelog uses: orhun/git-cliff-action@v4 id: git-cliff - if: startsWith(github.ref, 'refs/tags/') with: config: cliff.toml args: -vv --latest --strip header @@ -60,6 +77,5 @@ jobs: - name: Release uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') with: body: ${{ steps.git-cliff.outputs.content }} diff --git a/Makefile.toml b/Makefile.toml index a29669a..6601947 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -41,18 +41,11 @@ dependencies = ["add"] [tasks.cliff] install_crate = "git-cliff" -command = "git" -args = ["cliff", "-o", "CHANGELOG.md"] -dependencies = ["commit"] +command = "git-cliff" +args = ["-o", "CHANGELOG.md"] + +[tasks.release] +dependencies = ["commit", "cliff"] [tasks.do] -dependencies = [ - "format", - "deny", - "typos", - "check", - "clippy", - "test", - "commit", - "cliff" -] +dependencies = ["format", "deny", "typos", "check", "clippy", "test"] diff --git a/README.en.md b/README.en.md index 590ea5f..422ea50 100644 --- a/README.en.md +++ b/README.en.md @@ -44,7 +44,6 @@ No boilerplate setup. No repeated configuration. Just focus on building. ### ๐Ÿ” Code Quality -* `pre-commit` hooks * `cargo clippy` + `cargo fmt` * `typos` spell checking @@ -84,7 +83,6 @@ rustup update stable # for generate cargo install cargo-generate -pip install pre-commit # install dependencies cargo install cargo-deny cargo-cliff typos-cli cargo-make cargo-nextest @@ -104,15 +102,20 @@ cargo generate --git https://github.com/lhui-dev/rct --name my-app ```bash cd my-app -pre-commit install cargo build ``` -### 4. Run full pipeline +### 4. Run validation pipeline `cargo make do` -Run format โ†’ lint โ†’ test โ†’ commit โ†’ changelog in one command +Run format โ†’ lint โ†’ test in one command + +```bash +cargo make release +``` + +Run commit + changelog separately. --- @@ -120,14 +123,16 @@ Run format โ†’ lint โ†’ test โ†’ commit โ†’ changelog in one command Built-in automation powered by cargo-make. -**Run everything** +**Run validation** ```bash cargo make do ``` -**Pipeline:** format โ†’ deny โ†’ typos โ†’ check โ†’ clippy โ†’ test โ†’ commit โ†’ cliff +**Pipeline:** format โ†’ deny โ†’ typos โ†’ check โ†’ clippy โ†’ test + +**Release:** commit โ†’ changelog **Run individually** @@ -176,7 +181,6 @@ cargo deny check โ”œโ”€โ”€ cliff.toml โ”œโ”€โ”€ typos.toml โ”œโ”€โ”€ Makefile.toml -โ”œโ”€โ”€ .pre-commit-config.yaml โ”œโ”€โ”€ README.en.md โ”œโ”€โ”€ README.md โ””โ”€โ”€ LICENSE @@ -186,7 +190,9 @@ cargo deny check ## โš™๏ธ Customization -Supports `cargo-generate.toml` for template variables. +Supports `cargo-generate.toml` for template variables like `description`. + +After generating a project, update the repository URL in `cliff.toml` to match your own repository. --- diff --git a/README.md b/README.md index b0484db..cd740b7 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,6 @@ rustup update stable # ้กน็›ฎ็”Ÿๆˆๅทฅๅ…ท cargo install cargo-generate -pip install pre-commit # ๅทฅ็จ‹ๅทฅๅ…ท้“พ cargo install cargo-deny cargo-cliff typos-cli cargo-make cargo-nextest @@ -102,19 +101,24 @@ cargo generate --git https://github.com/lhui-dev/rct --name my-app ```bash cd my-app -pre-commit install cargo build ``` --- -### 4. ๆ‰ง่กŒๅฎŒๆ•ดๆต็จ‹ +### 4. ๆ‰ง่กŒๆฃ€ๆŸฅๆต็จ‹ ```bash cargo make do ``` -ไธ€ๆกๅ‘ฝไปคๅฎŒๆˆ๏ผšๆ ผๅผๅŒ– โ†’ ๆฃ€ๆŸฅ โ†’ ๆต‹่ฏ• โ†’ ๆไบค โ†’ ็”Ÿๆˆ CHANGELOG +ไธ€ๆกๅ‘ฝไปคๅฎŒๆˆ๏ผšๆ ผๅผๅŒ– โ†’ ๆฃ€ๆŸฅ โ†’ ๆต‹่ฏ• + +```bash +cargo make release +``` + +ๅ•็‹ฌๆ‰ง่กŒๆไบคๅ’Œ็”Ÿๆˆ CHANGELOGใ€‚ --- @@ -122,7 +126,7 @@ cargo make do ๅ†…็ฝฎๅŸบไบŽ `cargo-make` ็š„่‡ชๅŠจๅŒ–ไปปๅŠก็ณป็ปŸใ€‚ -### ไธ€้”ฎๆ‰ง่กŒ +### ไธ€้”ฎๆฃ€ๆŸฅ ```bash cargo make do @@ -131,9 +135,17 @@ cargo make do ### ๆ‰ง่กŒๆต็จ‹ ``` -format โ†’ deny โ†’ typos โ†’ check โ†’ clippy โ†’ test โ†’ commit โ†’ cliff +format โ†’ deny โ†’ typos โ†’ check โ†’ clippy โ†’ test +``` + +### ๅ‘ๅธƒๆต็จ‹ + +```bash +cargo make release ``` +commit โ†’ changelog + ### ๅ•็‹ฌๆ‰ง่กŒไปปๅŠก ```bash @@ -183,7 +195,6 @@ cargo deny check โ”œโ”€โ”€ cliff.toml โ”œโ”€โ”€ typos.toml โ”œโ”€โ”€ Makefile.toml -โ”œโ”€โ”€ .pre-commit-config.yaml โ”œโ”€โ”€ README.en.md โ”œโ”€โ”€ README.md โ””โ”€โ”€ LICENSE @@ -193,7 +204,9 @@ cargo deny check ## โš™๏ธ ๆจกๆฟ่‡ชๅฎšไน‰ -ๆ”ฏๆŒ้€š่ฟ‡ `cargo-generate.toml` ๅฎšไน‰ๆจกๆฟๅ˜้‡๏ผŒๅฎž็Žฐๅˆๅง‹ๅŒ–ๆ—ถๅŠจๆ€ๆ›ฟๆขใ€‚ +ๆ”ฏๆŒ้€š่ฟ‡ `cargo-generate.toml` ๅฎšไน‰ๆจกๆฟๅ˜้‡๏ผŒๅฎž็Žฐๅˆๅง‹ๅŒ–ๆ—ถๅŠจๆ€ๆ›ฟๆข๏ผŒไพ‹ๅฆ‚ `description`ใ€‚ + +็”Ÿๆˆ้กน็›ฎๅŽ๏ผŒ่ฎฐๅพ—ๆŠŠ `cliff.toml` ้‡Œ็š„ไป“ๅบ“ๅœฐๅ€ๆ”นๆˆไฝ ่‡ชๅทฑ็š„ไป“ๅบ“ๅœฐๅ€ใ€‚ --- diff --git a/cargo-generate.toml b/cargo-generate.toml index c719ed5..73832f9 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -1,2 +1,11 @@ [template] -exclude = ["cliff.toml"] \ No newline at end of file +# Copy cliff.toml as-is so git-cliff's own `{{ }}` syntax is not treated as +# a cargo-generate template expression. Users should update the repository URL +# in the generated file after project creation. +exclude = ["cliff.toml"] +ignore = [".idea", "target", "CHANGELOG.md"] + +[placeholders.description] +type = "string" +prompt = "What does your project do?" +default = "A Rust project." diff --git a/cliff.toml b/cliff.toml index 5ddf796..b9ce981 100644 --- a/cliff.toml +++ b/cliff.toml @@ -95,7 +95,7 @@ commit_parsers = [ { message = "^revert", group = "โ—€๏ธ Revert" }, ] # Prevent commits that are breaking from being excluded by commit parsers. -protect_breaking_commits = false +protect_breaking_commits = true # Exclude commits that are not matched by any commit parser. filter_commits = false # Regex to select git tags that represent releases.