Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal] Improve Changelog by grouping changes #703

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codegen.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"formatter": "yapf -pri $FILENAMES && autoflake -i $FILENAMES && isort $FILENAMES",
"changelog_config": ".codegen/changelog_config.yml",
"template_libraries": [
".codegen/lib.tmpl"
],
Expand Down
44 changes: 38 additions & 6 deletions .codegen/changelog.md.tmpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Version changelog

## {{.Version}}
{{- range .GroupChanges}}

{{range .Changes -}}
### {{.Type.Message}}
{{range .Changes}}
* {{.}}.
{{end}}{{- if .ApiChanges}}
API Changes:
{{range .ApiChanges}}
* {{.Action}} {{template "what" .}}{{if .Extra}} {{.Extra}}{{with .Other}} {{template "what" .}}{{end}}{{end}}.
{{- end}}
{{end}}
{{if .ApiChanges}}
### API Changes:
{{range .ApiChanges.GroupDiff}}
* {{.Action}} {{template "group-what" .}}{{if .Extra}} {{.Extra}}{{with .Other}} {{template "other-what" .}}{{end}}{{end}}.
{{- end}}

OpenAPI SHA: {{.Sha}}, Date: {{.Changed}}
Expand All @@ -20,7 +24,35 @@ Dependency updates:

## {{.PrevVersion}}

{{- define "what" -}}
{{- define "group-what" -}}
{{if gt (len .Changes) 1 -}} {{template "single-what" .Changes.First}}{{end -}}
{{range .Changes.Middle -}}, {{template "single-what" .}}{{end -}}
{{if gt (len .Changes) 1}} and {{end}}{{template "single-what" .Changes.Last}}{{template "suffix-what" .}}
{{- end -}}

{{- define "single-what" -}}
{{if eq .X "package" -}}
`databricks.sdk.service.{{.Package.Name}}`
{{- else if eq .X "service" -}}
{{template "service" .Service}}
{{- else if eq .X "method" -}}
`{{.Method.SnakeName}}()`
{{- else if eq .X "entity" -}}
{{template "entity" .Entity}}
{{- else if eq .X "field" -}}
`{{.Field.SnakeName}}`
{{- end}}
{{- end -}}

{{- define "suffix-what" -}}
{{if eq .Type "package" }} package{{if gt (len .Changes) 1}}s{{end}}
{{- else if eq .Type "method" }} method{{if gt (len .Changes) 1}}s{{end}} for {{template "service" .Parent.Service}}
{{- else if eq .Type "entity" }} dataclass{{if gt (len .Changes) 1}}es{{end}}
{{- else if eq .Type "field" }} field{{if gt (len .Changes) 1}}s{{end}} for {{template "entity" .Parent.Entity}}
{{- end}}
{{- end -}}

{{- define "other-what" -}}
{{if eq .X "package" -}}
`databricks.sdk.service.{{.Package.Name}}` package
{{- else if eq .X "service" -}}
Expand Down
11 changes: 11 additions & 0 deletions .codegen/changelog_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
change_types:
- message: New Features and Improvements
tag: "[Feature]"
- message: Bug Fixes
tag: "[Fix]"
- message: Documentation
tag: "[Doc]"
- message: Internal Changes
tag: "[Internal]"
# Default for messages without a tag
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this after a release (once all "unreleased" commits have a tag)

- message: Other Changes
19 changes: 19 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,22 @@ jobs:

- name: Fail on differences
run: git diff --exit-code

commit-message:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Validate Tag
run: |
TAG=$(echo ${{ github.event.pull_request.title }} | sed -ne 's/\[\(.*\)\].*/\1/p')
if grep -q "tag: \"[$TAG]\"" .codegen/changelog_config.yml; then
echo "Invalid or missing tag in commit message: [$TAG]"
exit 1
else
echo "Valid tag found: [$TAG]"
fi
Loading