Skip to content

Commit 7f785da

Browse files
committed
complete rework
Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
1 parent dc5c5aa commit 7f785da

30 files changed

Lines changed: 1646 additions & 826 deletions

.cliff.toml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# git-cliff ~ configuration file
2+
# https://git-cliff.org/docs/configuration
3+
4+
[changelog]
5+
header = """
6+
"""
7+
8+
footer = """
9+
10+
-----
11+
12+
**[{{ remote.github.repo }}]({{ self::remote_url() }}) license terms**
13+
14+
[![License][license-badge]][license-url]
15+
16+
[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg
17+
[license-url]: {{ self::remote_url() }}/?tab=Apache-2.0-1-ov-file#readme
18+
19+
{%- macro remote_url() -%}
20+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
21+
{%- endmacro -%}
22+
"""
23+
24+
body = """
25+
{%- if version %}
26+
## [{{ version | trim_start_matches(pat="v") }}]({{ self::remote_url() }}/tree/{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
27+
{%- else %}
28+
## [unreleased]
29+
{%- endif %}
30+
{%- if message %}
31+
{%- raw %}\n{% endraw %}
32+
{{ message }}
33+
{%- raw %}\n{% endraw %}
34+
{%- endif %}
35+
{%- if version %}
36+
{%- if previous.version %}
37+
38+
**Full Changelog**: <{{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}>
39+
{%- endif %}
40+
{%- else %}
41+
{%- raw %}\n{% endraw %}
42+
{%- endif %}
43+
44+
{%- if statistics %}{% if statistics.commit_count %}
45+
{%- raw %}\n{% endraw %}
46+
{{ statistics.commit_count }} commits in this release.
47+
{%- raw %}\n{% endraw %}
48+
{%- endif %}{% endif %}
49+
-----
50+
51+
{%- for group, commits in commits | group_by(attribute="group") %}
52+
{%- raw %}\n{% endraw %}
53+
### {{ group | upper_first }}
54+
{%- raw %}\n{% endraw %}
55+
{%- for commit in commits %}
56+
{%- if commit.remote.pr_title %}
57+
{%- set commit_message = commit.remote.pr_title %}
58+
{%- else %}
59+
{%- set commit_message = commit.message %}
60+
{%- endif %}
61+
* {{ commit_message | split(pat="\n") | first | trim }}
62+
{%- if commit.remote.username %}
63+
{%- raw %} {% endraw %}by [@{{ commit.remote.username }}](https://github.com/{{ commit.remote.username }})
64+
{%- endif %}
65+
{%- if commit.remote.pr_number %}
66+
{%- raw %} {% endraw %}in [#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }})
67+
{%- endif %}
68+
{%- raw %} {% endraw %}[...]({{ self::remote_url() }}/commit/{{ commit.id }})
69+
{%- endfor %}
70+
{%- endfor %}
71+
72+
{%- if github %}
73+
{%- raw %}\n{% endraw -%}
74+
{%- set all_contributors = github.contributors | length %}
75+
{%- if github.contributors | filter(attribute="username", value="dependabot[bot]") | length < all_contributors %}
76+
-----
77+
78+
### People who contributed to this release
79+
{% endif %}
80+
{%- for contributor in github.contributors | filter(attribute="username") | sort(attribute="username") %}
81+
{%- if contributor.username != "dependabot[bot]" and contributor.username != "github-actions[bot]" %}
82+
* [@{{ contributor.username }}](https://github.com/{{ contributor.username }})
83+
{%- endif %}
84+
{%- endfor %}
85+
86+
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
87+
-----
88+
{%- raw %}\n{% endraw %}
89+
90+
### New Contributors
91+
{%- endif %}
92+
93+
{%- for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
94+
{%- if contributor.username != "dependabot[bot]" and contributor.username != "github-actions[bot]" %}
95+
* @{{ contributor.username }} made their first contribution
96+
{%- if contributor.pr_number %}
97+
in [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
98+
{%- endif %}
99+
{%- endif %}
100+
{%- endfor %}
101+
{%- endif %}
102+
103+
{%- raw %}\n{% endraw %}
104+
105+
{%- macro remote_url() -%}
106+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
107+
{%- endmacro -%}
108+
"""
109+
# Remove leading and trailing whitespaces from the changelog's body.
110+
trim = true
111+
# Render body even when there are no releases to process.
112+
render_always = true
113+
# An array of regex based postprocessors to modify the changelog.
114+
postprocessors = [
115+
# Replace the placeholder <REPO> with a URL.
116+
#{ pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" },
117+
]
118+
# output file path
119+
# output = "test.md"
120+
121+
[git]
122+
# Parse commits according to the conventional commits specification.
123+
# See https://www.conventionalcommits.org
124+
conventional_commits = false
125+
# Exclude commits that do not match the conventional commits specification.
126+
filter_unconventional = false
127+
# Require all commits to be conventional.
128+
# Takes precedence over filter_unconventional.
129+
require_conventional = false
130+
# Split commits on newlines, treating each line as an individual commit.
131+
split_commits = false
132+
# An array of regex based parsers to modify commit messages prior to further processing.
133+
commit_preprocessors = [
134+
# Replace issue numbers with link templates to be updated in `changelog.postprocessors`.
135+
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
136+
# Check spelling of the commit message using https://github.com/crate-ci/typos.
137+
# If the spelling is incorrect, it will be fixed automatically.
138+
#{ pattern = '.*', replace_command = 'typos --write-changes -' }
139+
]
140+
# Prevent commits that are breaking from being excluded by commit parsers.
141+
protect_breaking_commits = false
142+
# An array of regex based parsers for extracting data from the commit message.
143+
# Assigns commits to groups.
144+
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
145+
commit_parsers = [
146+
{ message = "^[Cc]hore\\([Rr]elease\\): prepare for", skip = true },
147+
{ message = "(^[Mm]erge)|([Mm]erge conflict)", skip = true },
148+
{ field = "author.name", pattern = "dependabot*", group = "<!-- 0A -->Updates" },
149+
{ message = "([Ss]ecurity)|([Vv]uln)", group = "<!-- 08 -->Security" },
150+
{ body = "(.*[Ss]ecurity)|([Vv]uln)", group = "<!-- 08 -->Security" },
151+
{ message = "([Cc]hore\\(lint\\))|(style)|(lint)|(codeql)|(golangci)", group = "<!-- 05 -->Code quality" },
152+
{ message = "(^[Dd]oc)|((?i)readme)|(badge)|(typo)|(documentation)", group = "<!-- 03 -->Documentation" },
153+
{ message = "(^[Ff]eat)|(^[Ee]nhancement)", group = "<!-- 00 -->Implemented enhancements" },
154+
{ message = "(^ci)|(\\(ci\\))|(fixup\\s+ci)|(fix\\s+ci)|(license)|(example)", group = "<!-- 07 -->Miscellaneous tasks" },
155+
{ message = "^test", group = "<!-- 06 -->Testing" },
156+
{ message = "(^fix)|(panic)", group = "<!-- 01 -->Fixed bugs" },
157+
{ message = "(^refact)|(rework)", group = "<!-- 02 -->Refactor" },
158+
{ message = "(^[Pp]erf)|(performance)", group = "<!-- 04 -->Performance" },
159+
{ message = "(^[Cc]hore)", group = "<!-- 07 -->Miscellaneous tasks" },
160+
{ message = "^[Rr]evert", group = "<!-- 09 -->Reverted changes" },
161+
{ message = "(upgrade.*?go)|(go\\s+version)", group = "<!-- 0A -->Updates" },
162+
{ message = ".*", group = "<!-- 0B -->Other" },
163+
]
164+
# Exclude commits that are not matched by any commit parser.
165+
filter_commits = false
166+
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
167+
link_parsers = []
168+
# Include only the tags that belong to the current branch.
169+
use_branch_tags = false
170+
# Order releases topologically instead of chronologically.
171+
topo_order = false
172+
# Order releases topologically instead of chronologically.
173+
topo_order_commits = true
174+
# Order of commits in each group/release within the changelog.
175+
# Allowed values: newest, oldest
176+
sort_commits = "newest"
177+
# Process submodules commits
178+
recurse_submodules = false
179+
180+
#[remote.github]
181+
#owner = "go-openapi"

.github/workflows/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# CI workflows
2+
3+
## Shared workflows
4+
5+
### Dependencies automation
6+
7+
* auto-merge.yml:
8+
* auto-merge dependabot updates, with dependency group rules
9+
* auto-merge go-openapi bot updates
10+
11+
### Test automation
12+
13+
* go-test.yml: go unit tests
14+
* monorepo-go-test.yml: go unit tests for monorepos
15+
16+
* collect-coverage.yml: (common) collect & publish test coverage (to codecov)
17+
* collect-reports.yml: (common) collect & publish test reports (to codecov and github)
18+
19+
### Security
20+
21+
* codeql.yml: CodeQL workflow for go and github actions
22+
* scanner.yml: trivy & govulncheck scans
23+
24+
### Release automation
25+
26+
* bump-release.yml: manually triggered workflow to cut a release
27+
* tag-release.yml: cut a release on push tag
28+
* release.yml: (common) release & release notes build
29+
30+
### Code quality
31+
32+
* collect-coverage.yml: common collect & publish test coverage (to codecov)
33+
* collect-reports.yml: common collect & publish test reports (to codecov and github)
34+
35+
### Documentation quality
36+
37+
* contributors.yml: updates CONTRIBUTORS.md
38+
* doc-update.yml: lint & spellcheck on markdown updates
39+
* pr-comment.yml: common PR commment workflow
40+
41+
## Test workflows
42+
43+
* local-auto-merge.yml
44+
* local-bump-release.yml
45+
* local-codeql.yml
46+
* local-contributors.yml
47+
* local-doc-update.yml
48+
* local-go-test.yml
49+
* local-monorepo-go-test.yml
50+
* local-release.yml
51+
* local-scanner.yml
52+
* local-tag-release.yml
53+
54+
## Configuration files
55+
56+
* .cliff
57+
58+
scripts

.github/workflows/auto-merge.yml

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
permissions:
77
contents: read
88

9+
defaults:
10+
run:
11+
shell: bash
12+
913
jobs:
1014
dependabot:
1115
permissions:
@@ -31,46 +35,24 @@ jobs:
3135
PR_URL: ${{github.event.pull_request.html_url}}
3236
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
3337
run: gh pr merge --auto --rebase "$PR_URL"
38+
39+
actions-bot:
40+
# description: |
41+
# Auto merge for go-openapi bot.
42+
# The regular actions-bot user cannot approve and merge its own pull requests,
43+
# We use another bot user to update content to be approved/auto-merged by actions-bot.
44+
permissions:
45+
contents: write
46+
pull-requests: write
47+
runs-on: ubuntu-latest
48+
if: ${{ github.event.pull_request.user.login == 'bot-go-openapi[bot]' }}
49+
env:
50+
PR_URL: ${{github.event.pull_request.html_url}}
51+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
52+
steps:
3453
-
35-
name: Auto-merge dependabot PRs for go-openapi patches
36-
if: >-
37-
${{
38-
contains(steps.metadata.outputs.dependency-group, 'go-openapi-dependencies') &&
39-
(
40-
steps.metadata.outputs.update-type == 'version-update:semver-minor' ||
41-
steps.metadata.outputs.update-type == 'version-update:semver-patch'
42-
)
43-
}}
44-
env:
45-
PR_URL: ${{github.event.pull_request.html_url}}
46-
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
47-
run: gh pr merge --auto --rebase "$PR_URL"
54+
name: Auto-approve all bot-go-openapi PRs
55+
run: gh pr review --approve "$PR_URL"
4856
-
49-
name: Auto-merge dependabot PRs for golang.org updates
50-
if: ${{ contains(steps.metadata.outputs.dependency-group, 'golang-org-dependencies') }}
51-
env:
52-
PR_URL: ${{github.event.pull_request.html_url}}
53-
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
57+
name: Auto-merge bot-go-openapi PRs
5458
run: gh pr merge --auto --rebase "$PR_URL"
55-
56-
# Auto merge is current disabled: we need automatic PRs to swap identity (e.g. using a Github App),
57-
# so the pull_request event is properly captured and the PR can validate.
58-
#actions-bot:
59-
# permissions:
60-
# contents: write
61-
# pull-requests: write
62-
# runs-on: ubuntu-latest
63-
# if: ${{ github.event.pull_request.user.login == 'github-actions[bot]' }}
64-
# steps:
65-
# -
66-
# name: Auto-approve all github-actions bot PRs
67-
# env:
68-
# PR_URL: ${{github.event.pull_request.html_url}}
69-
# GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
70-
# run: gh pr review --approve "$PR_URL"
71-
# -
72-
# name: Auto-merge github-actions bot PRs
73-
# env:
74-
# PR_URL: ${{github.event.pull_request.html_url}}
75-
# GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
76-
# run: gh pr merge --auto --rebase "$PR_URL"

0 commit comments

Comments
 (0)