Use `chloggen` go tool for managing the changelog (#637)

This commit is contained in:
Joao Grassi 2024-02-05 16:41:55 +01:00 committed by GitHub
parent 482cb01c45
commit 379db81270
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 391 additions and 72 deletions

21
.chloggen/TEMPLATE.yaml Normal file
View File

@ -0,0 +1,21 @@
# Use this changelog template to create an entry for release notes.
#
# If your change doesn't affect end users you should instead start
# your pull request title with [chore] or use the "Skip Changelog" label.
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type:
# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
component:
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note:
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: []
# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

24
.chloggen/config.yaml Normal file
View File

@ -0,0 +1,24 @@
# The directory that stores individual changelog entries.
# Each entry is stored in a dedicated yaml file.
# - 'make chlog-new' will copy the 'template_yaml' to this directory as a new entry file.
# - 'make chlog-validate' will validate that all entry files are valid.
# - 'make chlog-update' will read and delete all entry files in this directory, and update 'changelog_md'.
# Specify as relative path from root of repo.
# (Optional) Default: .chloggen
entries_dir: .chloggen
# This file is used as the input for individual changelog entries.
# Specify as relative path from root of repo.
# (Optional) Default: .chloggen/TEMPLATE.yaml
template_yaml: .chloggen/TEMPLATE.yaml
# The CHANGELOG file or files to which 'chloggen update' will write new entries
# (Optional) Default filename: CHANGELOG.md
change_logs:
user: CHANGELOG.md
# The default change_log or change_logs to which an entry should be added.
# If 'change_logs' is specified in this file, and no value is specified for 'default_change_logs',
# then 'change_logs' MUST be specified in every entry file.
default_change_logs: [user]

View File

@ -9,5 +9,6 @@ Note: if the PR is touching an area that is not listed in the [existing areas](h
## Merge requirement checklist
* [ ] [CONTRIBUTING.md](https://github.com/open-telemetry/semantic-conventions/blob/main/CONTRIBUTING.md) guidelines followed.
* [ ] [CHANGELOG.md](https://github.com/open-telemetry/semantic-conventions/blob/main/CHANGELOG.md) updated for non-trivial changes.
* [ ] Change log entry added, according to the guidelines in [When to add a changelog entry](https://github.com/open-telemetry/semantic-conventions/blob/main/CONTRIBUTING.md#when-to-add-a-changelog-entry).
* If your PR does not need a change log, start the PR title with `[chore]`
* [ ] [schema-next.yaml](https://github.com/open-telemetry/semantic-conventions/blob/main/schema-next.yaml) updated with changes to existing conventions.

88
.github/workflows/changelog.yml vendored Normal file
View File

@ -0,0 +1,88 @@
# This action requires that any PR targeting the main branch should touch at
# least one CHANGELOG file. If a CHANGELOG entry is not required, add the "Skip
# Changelog" label to disable this action.
name: 'Changelog'
on:
pull_request:
types: [opened, ready_for_review, synchronize, reopened, labeled, unlabeled]
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
changelog:
runs-on: ubuntu-latest
if: >-
${{
!contains(github.event.pull_request.labels.*.name, 'dependencies') &&
!contains(github.event.pull_request.labels.*.name, 'Skip Changelog') &&
!contains(github.event.pull_request.title, '[chore]')
}}
env:
PR_HEAD: ${{ github.event.pull_request.head.sha }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ~1.21.6
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: changelog-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Ensure no changes to the CHANGELOG.md
run: |
if [[ $(git diff --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD ./CHANGELOG*.md) ]]
then
echo "CHANGELOG.md should not be directly modified."
echo "Please add a .yaml file to the ./.chloggen/ directory."
echo "See CONTRIBUTING.md for more details."
echo "Alternately, add either \"[chore]\" to the title of the pull \ request or add the \"Skip Changelog\" label if this job should be skipped."
false
else
echo "CHANGELOG.md was not modified."
fi
- name: Ensure ./.chloggen/*.yaml addition(s)
run: |
if [[ 1 -gt $(git diff --diff-filter=A --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD ./.chloggen | grep -c \\.yaml) ]]
then
echo "No changelog entry was added to the ./.chloggen/ directory."
echo "Please add a .yaml file to the ./.chloggen/ directory."
echo "See CONTRIBUTING.md for more details."
echo "Alternately, add either \"[chore]\" to the title of the pull request or add the \"Skip Changelog\" label if this job should be skipped."
false
else
echo "A changelog entry was added to the ./.chloggen/ directory."
fi
- name: Validate ./.chloggen/*.yaml changes
run: |
make chlog-validate \
|| { echo "New ./.chloggen/*.yaml file failed validation."; exit 1; }
# In order to validate any links in the yaml file, render the config to markdown
- name: Render .chloggen changelog entries
run: make chlog-preview > changelog_preview.md
- name: Install markdown-link-check
run: npm install -g markdown-link-check
- name: Run markdown-link-check
run: |
markdown-link-check \
--verbose \
--config .markdown_link_check_config.json \
changelog_preview.md \
|| { echo "Check that anchor links are lowercase"; exit 1; }

View File

@ -1,9 +1,11 @@
<!-- #####################################################
THIS FILE IS AUTOGENERATED. DO NOT MODIFY MANUALLY!
See CONTRIBUTING.md for instructions to add an entry.
##################################################### -->
# Changelog
Please update changelog as part of any significant pull request. Place short
description of your change into "Unreleased" section. As part of release process
content of "Unreleased" section content will generate release notes for the
release.
<!-- next version -->
## Unreleased

View File

@ -6,6 +6,38 @@ Before you start - see OpenTelemetry general
[contributing](https://github.com/open-telemetry/community/blob/main/CONTRIBUTING.md)
requirements and recommendations.
<details>
<summary>Table of Contents</summary>
<!-- toc -->
- [Sign the CLA](#sign-the-cla)
- [How to Contribute](#how-to-contribute)
* [Prerequisites](#prerequisites)
* [1. Modify the YAML model](#1-modify-the-yaml-model)
+ [Schema files](#schema-files)
* [2. Update the markdown files](#2-update-the-markdown-files)
+ [Hugo frontmatter](#hugo-frontmatter)
* [3. Verify the changes before committing](#3-verify-the-changes-before-committing)
* [4. Changelog](#4-changelog)
+ [When to add a Changelog Entry](#when-to-add-a-changelog-entry)
- [Examples](#examples)
+ [Adding a Changelog Entry](#adding-a-changelog-entry)
* [5. Getting your PR merged](#5-getting-your-pr-merged)
- [Automation](#automation)
* [Consistency Checks](#consistency-checks)
* [Auto formatting](#auto-formatting)
* [Markdown style](#markdown-style)
* [Misspell check](#misspell-check)
* [Markdown link check](#markdown-link-check)
- [Updating the referenced specification version](#updating-the-referenced-specification-version)
- [Making a Release](#making-a-release)
- [Merging existing ECS conventions](#merging-existing-ecs-conventions)
<!-- tocstop -->
</details>
## Sign the CLA
Before you can contribute, you will need to sign the [Contributor License
@ -18,51 +50,21 @@ key, but non-obvious, aspects:
- All attributes, metrics, etc. are formally defined in YAML files under
the `model/` directory.
- All descriptions, normative language are defined in the `docs/`
directory.
- We provide tooling to generate Markdown documentation from the formal
YAML definitons. See [Yaml to Markdown](#yaml-to-markdown).
- We use Hugo to render [semantic conventions on our website](https://opentelemetry.io/docs/specs/semconv/).
You will see `<!--- Hugo front matter used to generate ...` sections
in markdown. See [Hugo frontmatter](#hugo-frontmatter) for details.
- All descriptions, normative language are defined in the `docs/` directory.
- All changes to existing attributes, metrics, etc. MUST be allowed as
per our [stability guarantees][stability guarantees] and
defined in a schema file. As part of any contribution, you should
include attribute changes defined in the `schema-next.yaml` file.
For details, please read [the schema specification](https://opentelemetry.io/docs/specs/otel/schemas/).
- Links to the specification repository MUST point to a tag and **not** to the `main` branch.
The tag version MUST match with the one defined in [README](README.md).
- After creating a pull request, please update the [CHANGELOG](CHANGELOG.md) file with
a description of your changes.
Please make sure all Pull Requests are compliant with these rules!
### Hugo frontmatter
### Prerequisites
At the top of all Markdown files under the `docs/` directory, you will see
headers like the following:
```
<!--- Hugo front matter used to generate the website version of this page:
linkTitle: HTTP
path_base_for_github_subdir:
from: content/en/docs/specs/semconv/http/_index.md
to: http/README.md
--->
```
When creating new pages, you should provide the `linkTitle` attribute. This is used
to generate the navigation bar on the website, and will be listed relative to the
"parent" document.
## Automation
Semantic Conventions provides a set of automated tools for general development.
### Consistency Checks
The Specification has a number of tools it uses to check things like style,
spelling and link validity. Before using the tools:
The Specification uses several tools to check things like style,
spelling and link validity. Before contributing, make sure to have your
environment configured:
- Install the latest LTS release of **[Node](https://nodejs.org/)**.
For example, using **[nvm][]** under Linux run:
@ -71,35 +73,166 @@ spelling and link validity. Before using the tools:
nvm install --lts
```
- Install tooling packages:
- Then from the root of the project, install the tooling packages:
```bash
npm install
```
### 1. Modify the YAML model
Refer to the
[Semantic Convention YAML Language](https://github.com/open-telemetry/build-tools/blob/v0.23.0/semantic-conventions/syntax.md)
to learn how to make changes to the YAML files.
#### Schema files
When making changes to existing semantic conventions (attributes, metrics, etc)
you MUST also update the `schema-next.yaml` file with the changes.
For details, please read
[the schema specification](https://opentelemetry.io/docs/specs/otel/schemas/).
You can also take examples from past changes inside the `schemas` folder.
> [!WARNING]
> DO NOT add your changes to files inside the `schemas` folder. Always add your
> changes to the `schema-next.yaml` file.
### 2. Update the markdown files
After updating the YAML file(s), you need to update
the respective markdown files. For this, run the following command:
```bash
make table-generation
```
#### Hugo frontmatter
At the top of all Markdown files under the `docs/` directory, you will see
headers like the following:
```md
<!--- Hugo front matter used to generate the website version of this page:
linkTitle: HTTP
path_base_for_github_subdir:
from: content/en/docs/specs/semconv/http/_index.md
to: http/README.md
--->
```
When creating new markdown files, you should provide the `linkTitle` attribute.
This is used to generate the navigation bar on the website,
and will be listed relative to the "parent" document.
### 3. Verify the changes before committing
Before sending a PR with your changes, make sure to run the automated checks:
```bash
make check
```
Alternatively, you can run each check individually.
Refer to the [Automation](#automation) section for more details.
### 4. Changelog
#### When to add a Changelog Entry
Pull requests that contain user-facing changes will require a changelog entry.
Keep in mind the following types of users (not limited to):
1. Those who are consuming the data following these conventions (e.g., in alerts, dashboards, queries)
2. Those who are using the conventions in instrumentations (e.g., library authors)
3. Those who are using the conventions to derive heuristics, predictions and automatic analyses (e.g., observability products/back-ends)
If a changelog entry is not required (e.g. editorial or trivial changes),
a maintainer or approver will add the `Skip Changelog` label to the pull request.
##### Examples
Changelog entry required:
- Any modification to existing conventions with change in functionality/behavior
- New semantic conventions
- Changes on definitions, normative language (in `/docs`)
No changelog entry:
- Typical documentation/editorial updates (e.g. grammar fixes, restructuring)
- Changes in internal tooling (e.g. make file, GH actions, etc)
- Refactorings with no meaningful change in functionality
- Chores, such as enabling linters, updating dependencies
#### Adding a Changelog Entry
The [CHANGELOG.md](./CHANGELOG.md) files in this repo is autogenerated
from `.yaml` files in the [/.chloggen](/.chloggen) directory.
Your pull request should add a new `.yaml` file to this directory.
The name of your file can be arbitrary but must be unique since the last release.
During the release process, all `./chloggen/*.yaml` files are transcribed into
`CHANGELOG.md` and then deleted.
1. Create an entry file using `make chlog-new`. The command generates a new file,
with its name based on the current branch (e.g. `./.chloggen/my-feature-xyz.yaml`)
2. Fill in all the fields in the generated file
3. The value for the `component` field MUST match a filename (without type) in the
[registry](https://github.com/open-telemetry/semantic-conventions/tree/main/model/registry)
(e.g. `browser`, `http`)
4. Run `make chlog-validate` to ensure the new file is valid
5. Commit and push the file
Alternately, copy `./.chloggen/TEMPLATE.yaml`, or just create your file from scratch.
### 5. Getting your PR merged
A PR (pull request) is considered to be **ready to merge** when:
- It has received at least two approvals from the [code
owners](./.github/CODEOWNERS) (if approvals are from only one company, they
won't count)
- There is no `request changes` from the [code owners](./.github/CODEOWNERS)
- There is no open discussions
- It has been at least two working days since the last modification (except for
the trivial updates, such like typo, cosmetic, rebase, etc.). This gives
people reasonable time to review
- Trivial changes (typos, cosmetic changes, CI improvements, etc.) don't have to
wait for two days
Any [maintainer](./README.md#contributing) can merge the PR once it is **ready
to merge**.
## Automation
Semantic Conventions provides a set of automated tools for general development.
### Consistency Checks
The Specification has a number of tools it uses to check things like style,
spelling and link validity.
You can perform all checks locally using this command:
```bash
make check
```
Note: This can take a long time as it checks all links. You should use this
prior to submitting a PR to ensure validity. However, you can run individual
checks directly.
> Note: `make check` can take a long time as it checks all links.
> You should use this prior to submitting a PR to ensure validity.
> However, you can run individual checks directly.
See:
For more information on each check, see:
- [MarkdownStyle](#markdown-style)
- [Misspell Check](#misspell-check)
- Markdown link checking (docs TODO)
- [Markdown style](#markdown-style)
- [Misspell check](#misspell-check)
- [Markdown link check](#markdown-link-check)
- Prettier formatting
### YAML to Markdown
Semantic conventions are declared in YAML files and markdown tables are
generated from these files. Read about semantic convention updates [here](./model/README.md).
### Autoformatting
### Auto formatting
Semantic conventions have some autogenerated components and additionally can do
automatic style/spell correction. You can run all of this via:
@ -113,7 +246,7 @@ You can also run these fixes individually.
See:
- [Misspell Correction](#misspell-check)
- Table Generation (docs TODO)
- [Update the markdown files](#2-update-the-markdown-files)
### Markdown style
@ -159,22 +292,13 @@ To quickly fix typos, use
make misspell-correction
```
### How to get your PR merged
### Markdown link check
A PR (pull request) is considered to be **ready to merge** when:
To check the validity of links in all markdown files, run the following command:
- It has received at least two approvals from the [code
owners](./.github/CODEOWNERS) (if approvals are from only one company, they
won't count).
- There is no `request changes` from the [code owners](./.github/CODEOWNERS).
- It has been at least two working days since the last modification (except for
the trivial updates, such like typo, cosmetic, rebase, etc.). This gives
people reasonable time to review.
- Trivial changes (typos, cosmetic changes, CI improvements, etc.) don't have to
wait for two days.
Any [maintainer](./README.md#contributing) can merge the PR once it is **ready
to merge**.
```bash
make markdown-link-check
```
## Updating the referenced specification version
@ -194,8 +318,10 @@ to merge**.
- Ensure the `next` version is appropriately configured as the `{version}`.
- Copy `schema-next.yaml` to `schemas/{version}`.
- Add `next` as a version in `schema-next.yaml` version.
- Update `CHANGELOG.md` for the latest version.
- Add `## v{version} ({date})` under `## Unreleased`
- Run `make chlog-update VERSION=v{version}`
- `make chlog-update` will clean up all the current `.yaml` files inside the
`.chloggen` folder automatically
- Double check that `CONTRIBUTING.md` is updated with the proper `v{version}`
- Send staging tag as PR for review.
- Create a tag `v{version}` on the merged PR and push remote.

View File

@ -3,9 +3,14 @@ ALL_DOCS := $(shell find . -type f -name '*.md' -not -path './.github/*' -not -p
PWD := $(shell pwd)
TOOLS_DIR := ./internal/tools
MISSPELL_BINARY=bin/misspell
MISSPELL = $(TOOLS_DIR)/$(MISSPELL_BINARY)
CHLOGGEN_BINARY=bin/chloggen
CHLOGGEN = $(TOOLS_DIR)/$(CHLOGGEN_BINARY)
CHLOGGEN_CONFIG := .chloggen/config.yaml
# see https://github.com/open-telemetry/build-tools/releases for semconvgen updates
# Keep links in model/README.md and .vscode/settings.json in sync!
SEMCONVGEN_VERSION=0.23.0
@ -124,3 +129,23 @@ fix: table-generation misspell-correction fix-format
install-tools: $(MISSPELL)
npm install
@echo "All tools installed"
$(CHLOGGEN):
cd $(TOOLS_DIR) && go build -o $(CHLOGGEN_BINARY) go.opentelemetry.io/build-tools/chloggen
FILENAME?=$(shell git branch --show-current)
.PHONY: chlog-new
chlog-new: $(CHLOGGEN)
$(CHLOGGEN) new --config $(CHLOGGEN_CONFIG) --filename $(FILENAME)
.PHONY: chlog-validate
chlog-validate: $(CHLOGGEN)
$(CHLOGGEN) validate --config $(CHLOGGEN_CONFIG)
.PHONY: chlog-preview
chlog-preview: $(CHLOGGEN)
$(CHLOGGEN) update --config $(CHLOGGEN_CONFIG) --dry --version $(VERSION)
.PHONY: chlog-update
chlog-update: $(CHLOGGEN)
$(CHLOGGEN) update --config $(CHLOGGEN_CONFIG) --version $(VERSION)

View File

@ -2,4 +2,7 @@ module github.com/open-telemetry/opentelemetry-specification/internal/tools
go 1.12
require github.com/client9/misspell v0.3.4
require (
github.com/client9/misspell v0.3.4
go.opentelemetry.io/build-tools/chloggen v0.12.0
)

View File

@ -1,2 +1,29 @@
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
go.opentelemetry.io/build-tools/chloggen v0.12.0 h1:BFj/1bNIGxOs1GykGjhV4gycz1nqVWI/xVDUaVfNibw=
go.opentelemetry.io/build-tools/chloggen v0.12.0/go.mod h1:zuYbAo3TkrHo3C7lCrM5dHWSS50BDr0UfRYtyBFv2dQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -13,6 +13,7 @@
// limitations under the License.
//
//go:build tools
// +build tools
package tools
@ -24,4 +25,5 @@ package tools
import (
_ "github.com/client9/misspell/cmd/misspell"
_ "go.opentelemetry.io/build-tools/chloggen"
)