diff --git a/.commitlintrc.yml b/.commitlintrc.yml new file mode 100644 index 0000000..8a9d499 --- /dev/null +++ b/.commitlintrc.yml @@ -0,0 +1,35 @@ +rules: + # Body may be empty + body-empty: + level: ignore + + # Description must not be empty + description-empty: + level: error + + # Description must start with a capital letter and must not end with a period or space + description-format: + level: error + format: ^[A-Z0-9].*[^. ]$ + + # Description should be <70 chars + description-max-length: + level: warning + length: 70 + + # Scope is not allowed + scope: + level: error + options: [] + + # Subject line should exist + subject-empty: + level: error + + # Type must be one of these options + type: + level: error + options: + - fix + - feat + - chore diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1c23998..98b3eda 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,16 @@ version: 2 + updates: - package-ecosystem: "cargo" directory: "macros" schedule: interval: "daily" + commit-message: + prefix: "update" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" + commit-message: + prefix: "chore" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d90f269..c2543d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,12 @@ name: CI on: + workflow_dispatch: pull_request: + types: + - opened + - reopened + - synchronize push: branches: main schedule: @@ -42,15 +47,14 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - - - name: Install clippy - run: rustup component add clippy + with: + components: clippy - name: Cache Rust dependencies uses: Swatinem/rust-cache@v2 - - name: Cargo clippy - run: cargo clippy --all-features --all-targets -- -D warnings + - name: Run Clippy + run: cargo clippy --all-features --all-targets -- -Dwarnings cargo_fmt: name: Enforce Rust code format diff --git a/.github/workflows/pr_title.yml b/.github/workflows/pr_title.yml new file mode 100644 index 0000000..be82d9b --- /dev/null +++ b/.github/workflows/pr_title.yml @@ -0,0 +1,91 @@ +name: PR title + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + title_cc_validation: + name: Conventional commits validation + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Check PR title + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + # If this step fails, please expand this step for more information. + # + # You will need to revise this pull request's title to + # match the "summary" (first) line of a Conventional Commit message. + # This enables us to automatically generate a meaningful changelog. + # + # The summary line (and thus the PR title) must have this exact format + # (including punctuation): + # + # type: description + # + # `type` describes the nature of changes you are making. This project + # requires the type to be one of these exact names: + # + # * fix + # * feat (will cause a minor version bump) + # * chore (will be omitted from changelog) + # + # NOTE: Conventional Commits also defines a `(scope)` parameter + # which can define a sub-area within the project where the change was + # made. This project is configured to disallow the use of `scope`. + # + # `description` is a short human-readable summary of the changes being made. + # + # This project enforces a few rules over and above the Conventional + # Commits definition of `description`: + # + # * The `description` must be non-empty. + # * The `description` must start with a capital letter or number. + # (Do not start `description` with a lower-case word.) + # * The `description` must not end with a period. + # + # This project does not currently enforce the following items, but + # we ask that you observe the following preferences in `description`: + # + # * The entire description should be written and capitalized as + # an English-language sentence, except (as noted earlier) that + # the trailing period must be omitted. + # * Any acronyms such as JSON or YAML should be capitalized as per + # commonusage in English-language sentences. + # + # After you edit the PR title, this task will run again and the + # warning should go away if you have made acceptable changes. + # + # For more information on Conventional Commits, please see: + # + # https://www.conventionalcommits.org/en/v1.0.0/ + # + # ------------ (end of message) ------------ + + if echo "$PR_TITLE" | grep -E '^chore(\(.*\))?: release '; then + echo "Exception / OK: chore release pattern" + exit 0; + fi + + if echo "$PR_TITLE" | grep -E '^chore(\(deps\))?: bump '; then + echo "Exception / OK: Dependabot update pattern" + exit 0; + fi + + echo "Installing commitlint-rs. Please wait 30-40 seconds ..." + cargo install --quiet commitlint-rs + set -e + + echo   + echo   + echo --- commitlint results for PR title \"$PR_TITLE\" --- + echo   + + echo "$PR_TITLE" | commitlint -g .commitlintrc.yml + + echo "✅ PR title matches all enforced rules." diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7de5217..14330cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ secrets.RELEASE_PLZ_TOKEN }} - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable @@ -26,5 +27,5 @@ jobs: - name: Run release-plz uses: MarcoIeni/release-plz-action@v0.5 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_ADMIN_COMMIT_TOKEN }} CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index f0a3ce5..fa24e00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm Since version 1.1.1, the format of this changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -Do not manually edit this file. It will be automatically updated when a new release is published. - ## [1.1.1](https://github.com/scouten/async-generic/compare/async-generic-v1.1.0...async-generic-v1.1.1) _30 August 2024_ @@ -17,19 +15,23 @@ _30 August 2024_ ## 1.1.0 _29 March 2024_ -* (MINOR) Bump MSRV to 1.70.0 ([#4](https://github.com/scouten/sync-generic/pull/4)) +* Bump MSRV to 1.70.0 ([#4](https://github.com/scouten/sync-generic/pull/4)) + ## 1.0.0 _26 December 2023_ -* (MAJOR) Prepare for 1.0 release ([#2](https://github.com/scouten/sync-generic/pull/2)) +* Prepare for 1.0 release ([#2](https://github.com/scouten/sync-generic/pull/2)) + ## 0.1.2 _28 September 2023_ * Set MSRV to 1.67.0 ([#1](https://github.com/scouten/sync-generic/pull/1)) + ## 0.1.1 _22 September 2023_ * Fix incorrect README + ## 0.1.0 _22 September 2023_ diff --git a/deny.toml b/deny.toml index 9744b67..fe06423 100644 --- a/deny.toml +++ b/deny.toml @@ -35,7 +35,5 @@ allow = [ confidence-threshold = 0.9 [sources] -allow-git = [] -allow-registry = ["https://github.com/rust-lang/crates.io-index"] unknown-git = "deny" unknown-registry = "deny" diff --git a/release-plz.toml b/release-plz.toml index 74b2942..d6cc8eb 100644 --- a/release-plz.toml +++ b/release-plz.toml @@ -3,18 +3,37 @@ body = """ ## [{{ version | trim_start_matches(pat="v") }}]{%- if release_link -%}({{ release_link }}){% endif %} _{{ timestamp | date(format="%d %B %Y") }}_ -{% for group, commits in commits | group_by(attribute="group") %} +{%- for group, commits in commits | group_by(attribute="group") %} +{% if group != "chore" -%} ### {{ group | upper_first }} -{% for commit in commits %} -{%- if commit.scope -%} -* *({{commit.scope}})* {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message }}{%- if commit.links %} ({% for link in commit.links %}[{{link.text}}]({{link.href}}) {% endfor -%}){% endif %} + +{% for commit in commits -%} +{%- if commit.scope and commit.scope != package -%} +* *({{commit.scope}})* {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}{%- if commit.links %} ({% for link in commit.links %}[{{link.text}}]({{link.href}}) {% endfor -%}){% endif %} {% else -%} -* {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message }} +* {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }} {% endif -%} {% endfor -%} +{% endif -%} {% endfor %} """ +commit_parsers = [ + { message = "^feat", group = "added" }, + { message = "^changed", group = "changed" }, + { message = "^deprecated", group = "deprecated" }, + { message = "^fix", group = "fixed" }, + { message = "^security", group = "security" }, + { message = "^chore", group = "chore" }, + { message = "^.*", group = "other" }, +] + +[workspace] +dependencies_update = true +features_always_increment_minor = true +release_always = false +release_commits = "^(feat|fix)[(:]" + [[package]] name = "async-generic" changelog_path = "CHANGELOG.md" diff --git a/rustfmt.toml b/rustfmt.toml index 1807a36..78ae574 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -7,10 +7,12 @@ # cargo +nightly fmt blank_lines_upper_bound = 1 -edition = "2018" +edition = "2021" +empty_item_single_line = true format_code_in_doc_comments = true group_imports = "StdExternalCrate" hex_literal_case = "Lower" imports_granularity = "Crate" reorder_impl_items = true unstable_features = true +wrap_comments = true