Skip to content

Commit

Permalink
chore: Update build system from other projects
Browse files Browse the repository at this point in the history
  • Loading branch information
scouten committed Sep 28, 2024
1 parent 11e1711 commit 8c47825
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 18 deletions.
35 changes: 35 additions & 0 deletions .commitlintrc.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: CI

on:
workflow_dispatch:
pull_request:
types:
- opened
- reopened
- synchronize
push:
branches: main
schedule:
Expand Down Expand Up @@ -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
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/pr_title.yml
Original file line number Diff line number Diff line change
@@ -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."
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PLZ_TOKEN }}

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

- name: Run release-plz
uses: MarcoIeni/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_ADMIN_COMMIT_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_

Expand All @@ -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_

Expand Down
2 changes: 0 additions & 2 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
29 changes: 24 additions & 5 deletions release-plz.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 3 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8c47825

Please sign in to comment.