Skip to content

Commit e250dcb

Browse files
authored
chore(ci): simplify chanelog validation to always check for authors (#21463)
* dummy changelog * remove redundant authors argument
1 parent aeaeecd commit e250dcb

File tree

2 files changed

+18
-44
lines changed

2 files changed

+18
-44
lines changed

.github/workflows/changelog.yaml

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,53 +23,32 @@ jobs:
2323
env:
2424
PR_HAS_LABEL: ${{ contains( github.event.pull_request.labels.*.name, 'no-changelog') }}
2525
steps:
26-
# checkout full depth because in the check_changelog_fragments script, we need to specify a
27-
# merge base. If we only shallow clone the repo, git may not have enough history to determine
28-
# the base.
26+
# Checkout full depth because in the check_changelog_fragments script, we need to specify a
27+
# merge base. If we only shallow clone the repo, git may not have enough history to determine
28+
# the base.
2929
- uses: actions/checkout@v3
3030
with:
3131
fetch-depth: 0
3232

3333
- name: Generate authentication token
34-
# don't run this step if the PR is from a fork or dependabot since the secrets won't exist
34+
# Don't run this step if the PR is from a fork or dependabot since the secrets won't exist
3535
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
3636
id: generate_token
3737
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a
3838
with:
3939
app_id: ${{ secrets.GH_APP_DATADOG_VECTOR_CI_APP_ID }}
4040
private_key: ${{ secrets.GH_APP_DATADOG_VECTOR_CI_APP_PRIVATE_KEY }}
4141

42-
- name: Get PR comment author
43-
# don't run this step if the PR is from a fork or dependabot since the secrets won't exist
44-
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
45-
id: author
46-
uses: tspascoal/get-user-teams-membership@v3
47-
with:
48-
username: ${{ github.actor }}
49-
team: 'Vector'
50-
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
51-
52-
- env:
53-
# if the prior step did not run, this var will be ''
54-
AUTHOR_IS_TEAM_MEMBER: ${{ steps.author.outputs.isTeamMember }}
55-
run: |
42+
- run: |
5643
if [[ $PR_HAS_LABEL == 'true' ]] ; then
5744
echo "'no-changelog' label detected."
5845
exit 0
5946
fi
6047
61-
# helper script needs to reference the master branch to compare against
48+
# Helper script needs to reference the master branch to compare against
6249
git fetch origin master:refs/remotes/origin/master
6350
64-
# If the PR author is an external contributor, validate that the
65-
# changelog fragments added contain the author line for website rendering.
66-
args=""
67-
if [[ $AUTHOR_IS_TEAM_MEMBER != 'true' ]] ; then
68-
echo "PR author detected to be an external contributor."
69-
args="--authors"
70-
fi
71-
72-
./scripts/check_changelog_fragments.sh ${args}
51+
./scripts/check_changelog_fragments.sh
7352
7453
check-changelog:
7554
name: Changelog

scripts/check_changelog_fragments.sh

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,17 @@ while IFS= read -r fname; do
5656
exit 1
5757
fi
5858

59-
# if specified, this option validates that the contents of the news fragment
60-
# contains a properly formatted authors line at the end of the file, generally
61-
# used for external contributor PRs.
62-
if [[ $1 == "--authors" ]]; then
63-
last=$( tail -n 1 "${CHANGELOG_DIR}/${fname}" )
64-
if [[ "${last}" == "authors: "*@* ]]; then
65-
echo "invalid fragment contents: author should not be prefixed with @"
66-
exit 1
67-
elif [[ "${last}" == "authors: "*,* ]]; then
68-
echo "invalid fragment contents: authors should be space delimited, not comma delimited."
69-
exit 1
70-
elif ! [[ "${last}" =~ ^(authors: .*)$ ]]; then
71-
echo "invalid fragment contents: author option was specified but fragment ${fname} contains no authors."
72-
exit 1
73-
fi
74-
59+
# Each fragment should have a properly formatted authors line at the end of the file.
60+
last=$( tail -n 1 "${CHANGELOG_DIR}/${fname}" )
61+
if [[ "${last}" == "authors: "*@* ]]; then
62+
echo "invalid fragment contents: author should not be prefixed with @"
63+
exit 1
64+
elif [[ "${last}" == "authors: "*,* ]]; then
65+
echo "invalid fragment contents: authors should be space delimited, not comma delimited."
66+
exit 1
67+
elif ! [[ "${last}" =~ ^(authors: .*)$ ]]; then
68+
echo "invalid fragment contents: author option was specified but fragment ${fname} contains no authors."
69+
exit 1
7570
fi
7671

7772
done <<< "$FRAGMENTS"

0 commit comments

Comments
 (0)