-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Changelog | ||
# | ||
# Validates that a changelog entry was added. | ||
# Runs on PRs when: | ||
# - openen/re-opened | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
openen is not a recognized word. (unrecognized-spelling)
|
||
# - new commits pushed | ||
# - label is added or removed | ||
|
||
name: Changelog | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, labeled, unlabeled] | ||
|
||
jobs: | ||
check-changelog: | ||
env: | ||
PR_HAS_LABEL: ${{ contains( github.event.pull_request.labels.*.name, 'no-changelog') }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get PR comment author | ||
id: author | ||
uses: tspascoal/get-user-teams-membership@v3 | ||
with: | ||
username: ${{ github.actor }} | ||
team: 'Vector' | ||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
|
||
- | ||
env: | ||
EXTERN_CONTRIBUTOR: ${{ steps.author.outputs.isTeamMember }} | ||
run: | | ||
if [[ $PR_HAS_LABEL == 'true' ]] ; then | ||
echo "'no-changelog' label detected." | ||
exit 0 | ||
fi | ||
# helper script needs to reference the main branch to compare against | ||
git fetch origin main:refs/remotes/origin/master | ||
# If the PR author is an external contributor, validate that the | ||
# changelog fragments added contain the author line for website rendering. | ||
args="" | ||
if [[ $PR_HAS_LABEL == 'true' ]] ; then | ||
echo "PR author detected to be an external contributor." | ||
args="--author" | ||
fi | ||
./scripts/check_changelog_fragments.sh ${args} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
## Overview | ||
|
||
This directory contains changelog "fragments" that are collected during a release to | ||
generate the project's user facing changelog. | ||
|
||
The tool used to generate the changelog is [towncrier](https://towncrier.readthedocs.io/en/stable/markdown.html). | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
towncrier is not a recognized word. (unrecognized-spelling)
Check failure Code scanning / check-spelling Unrecognized Spelling Error
towncrier is not a recognized word. (unrecognized-spelling)
|
||
|
||
The configuration file is `changelog.toml`. | ||
The changelog fragments are are located in `changelog.d/`. | ||
Check failure Code scanning / check-spelling Forbidden Pattern Error
are are matches a line_forbidden.patterns entry: "\s([A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})\s\g{-1}\s". (forbidden-pattern)
|
||
|
||
## Process | ||
|
||
Fragments for un-released changes are placed in the root of this directory during PRs. | ||
|
||
During a release when the changelog is generated, the fragments in the root of this | ||
directory are moved into a new directory with the name of the release (e.g. '0.42.0'). | ||
|
||
### Pull Requests | ||
|
||
By default, PRs are required to add at least one entry to this directory. | ||
This is enforced during CI. | ||
|
||
To mark a PR as not requiring user-facing changelog notes, add the label 'no-changelog'. | ||
|
||
To run the same check that is run in CI to validate that your changelog fragments have | ||
the correct syntax, commit the fragment additions and then run ./scripts/check_changelog_fragments.sh | ||
|
||
The format for fragments is: \<pr_number\>.\<fragment_type\>.md | ||
|
||
### Fragment conventions | ||
|
||
When fragments used to generate the updated changelog, the content of the fragment file is | ||
rendered as an item in a bulleted list under the "type" of fragment. | ||
|
||
The contents of the file must be valid markdown. | ||
|
||
Filename rules: | ||
- Must begin with the PR number associated with the change. | ||
- The type must be one of: breaking|security|deprecated|feature|enhanced|fixed. | ||
These types are described in more detail in the config file (see `changelog.toml`). | ||
- Only the two period delimiters can be used. | ||
- The file must be markdown. | ||
|
||
### Breaking changes | ||
|
||
When using the type 'breaking' to add notes for a breaking change, these should be more verbose than | ||
other entries typically. It should include all details that would be relevant for the user to need | ||
to handle upgrading to the breaking change. | ||
|
||
## Example | ||
|
||
Here is an example of a changelog fragment that adds a breaking change explanation. | ||
|
||
$ cat changelog.d/42.breaking.md | ||
This change is so great. It's such a great change that this sentence | ||
explaining the change has to span multiple lines of text. | ||
|
||
It even necessitates a line break. It is a breaking change after all. | ||
|
||
This renders in the auto generated changelog as: | ||
(note that PR links are omitted in the public facing version of the changelog) | ||
|
||
## [X.X.X] | ||
|
||
### Breaking Changes & Upgrade Guide | ||
|
||
- This change is so great. It's such a great change that this sentence | ||
explaining the change has to span multiple lines of text. | ||
|
||
It even necessitates a line break. It is a breaking change after all. ([#42])(https://github.com/vectordotdev/vector/pull/42)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Configuration for `towncrier` used during release process to auto-generate changelog. | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
towncrier is not a recognized word. (unrecognized-spelling)
|
||
|
||
[tool.towncrier] | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
towncrier is not a recognized word. (unrecognized-spelling)
|
||
directory = "changelog.d" | ||
filename = "CHANGELOG.md" | ||
start_string = "<!-- changelog start -->\n" | ||
underlines = ["", "", ""] | ||
title_format = "## [{version}]" | ||
issue_format = "[#{issue}](https://github.com/vectordotdev/vector/pull/{issue})" | ||
|
||
# The following configurations specify which fragment "types" are | ||
# allowed. | ||
# | ||
# If a change applies to more than one type, select the one it most | ||
# applies to. Or, if applicable, multiple changelog fragments can be | ||
# added for one PR. For example, if a PR includes a breaking change | ||
# around some feature, but also fixes a bug in the same part of the | ||
# code but is tangential to the breaking change, a separate | ||
# fragment can be added to call out the fix. | ||
|
||
# A change that is incompatible with prior versions which | ||
# requires users to make adjustments. | ||
[[tool.towncrier.type]] | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
towncrier is not a recognized word. (unrecognized-spelling)
|
||
directory = "breaking" | ||
name = "Breaking Changes & Upgrade Guide" | ||
showcontent = true | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
showcontent is not a recognized word. (unrecognized-spelling)
|
||
|
||
# A change that has implications for security. | ||
[[tool.towncrier.type]] | ||
directory = "security" | ||
name = "Security" | ||
showcontent = true | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
showcontent is not a recognized word. (unrecognized-spelling)
|
||
|
||
# A change that is introducing a deprecation. | ||
[[tool.towncrier.type]] | ||
directory = "deprecated" | ||
name = "Deprecations" | ||
showcontent = true | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
showcontent is not a recognized word. (unrecognized-spelling)
|
||
|
||
# A change that is introducing a new feature. | ||
[[tool.towncrier.type]] | ||
directory = "feature" | ||
name = "New Features" | ||
showcontent = true | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
showcontent is not a recognized word. (unrecognized-spelling)
|
||
|
||
# A change that is enhancing existing functionality in a user | ||
# perceivable way. | ||
[[tool.towncrier.type]] | ||
directory = "enhanced" | ||
name = "Enhancements" | ||
showcontent = true | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
showcontent is not a recognized word. (unrecognized-spelling)
|
||
|
||
# A change that is fixing a bug. | ||
[[tool.towncrier.type]] | ||
directory = "fixed" | ||
name = "Fixes" | ||
showcontent = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#/bin/bash | ||
|
||
# This script is intended to run during CI, however it can be run locally by | ||
# committing changelog fragments before executing the script. If the script | ||
# finds an issue with your changelog fragment, you can unstage the fragment | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
unstage is not a recognized word. (unrecognized-spelling)
|
||
# from being committed and fix the issue. | ||
|
||
OPW_CHANGELOG_DIR="changelog.d" | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
OPW is not a recognized word. (unrecognized-spelling)
|
||
FRAGMENT_TYPES="breaking|security|deprecated|feature|enhanced|fixed" | ||
|
||
if [ ! -d "${OPW_CHANGELOG_DIR}" ]; then | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
OPW is not a recognized word. (unrecognized-spelling)
|
||
echo "No ./${OPW_CHANGELOG_DIR} found. This tool must be invoked from the root of the OPW repo." | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
OPW is not a recognized word. (unrecognized-spelling)
Check failure Code scanning / check-spelling Unrecognized Spelling Error
OPW is not a recognized word. (unrecognized-spelling)
|
||
exit 1 | ||
fi | ||
|
||
# diff-filter=A lists only added files | ||
ADDED=$(git diff --name-only --diff-filter=A origin/master ${OPW_CHANGELOG_DIR}) | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
OPW is not a recognized word. (unrecognized-spelling)
|
||
|
||
if [ $(echo "$ADDED" | grep -c .) -lt 1 ]; then | ||
echo "No changelog fragments detected" | ||
echo "If no changes necessitate user-facing explanations, add the GH label 'no-changelog'" | ||
echo "Otherwise, add changelog fragments to changelog.d/" | ||
exit 1 | ||
fi | ||
|
||
# extract the basename from the file path | ||
ADDED=$(echo ${ADDED} | xargs -n1 basename) | ||
|
||
# validate the fragments | ||
while IFS= read -r fname; do | ||
|
||
if [[ ${fname} == "README.md" ]]; then | ||
continue | ||
fi | ||
|
||
echo "validating '${fname}'" | ||
|
||
arr=(${fname//./ }) | ||
|
||
if [ "${#arr[@]}" -ne 3 ]; then | ||
echo "invalid fragment filename: wrong number of period delimiters. expected '<pr_number>.<fragment_type>.md'. (${fname})" | ||
exit 1 | ||
fi | ||
|
||
if ! [[ "${arr[0]}" =~ ^[0-9]+$ ]]; then | ||
echo "invalid fragment filename: fragment must begin with an integer (PR number). expected '<pr_number>.<fragment_type>.md' (${fname})" | ||
exit 1 | ||
fi | ||
|
||
if ! [[ "${arr[1]}" =~ ^(${FRAGMENT_TYPES})$ ]]; then | ||
echo "invalid fragment filename: fragment type must be one of: (${FRAGMENT_TYPES}). (${fname})" | ||
exit 1 | ||
fi | ||
|
||
if [[ "${arr[2]}" != "md" ]]; then | ||
echo "invalid fragment filename: extension must be markdown (.md): (${fname})" | ||
exit 1 | ||
fi | ||
|
||
# if specified, this option validates that the contents of the news fragment | ||
# contains a properly formatted authors line at the end of the file, generally | ||
# used for external contributor PRs. | ||
if [[ $1 == "--authors" ]]; then | ||
last=$( tail -n 1 "${OPW_CHANGELOG_DIR}/${fname}" ) | ||
if ! [[ "${last}" =~ ^(authors: .*)$ ]]; then | ||
echo "invalid fragment contents: author option was specified but fragment ${fname} contains no authors." | ||
exit 1 | ||
fi | ||
|
||
fi | ||
|
||
done <<< "$ADDED" | ||
|
||
|
||
echo "changelog additions are valid." |