Skip to content

Commit

Permalink
chore: Checks PR to ensure new changelog entry file is present and va…
Browse files Browse the repository at this point in the history
…lid (#2126)

* echo vars

* env vars

* create go file

* skip logic

* use log.Fatal

* import changelog package

* check file

* rename to check-changelog

* test file

* validate file if present

* comment

* test file error

* remove file

* help message

* doc

* Update contributing/changelog-process.md

Co-authored-by: Agustin Bettati <[email protected]>

* Update contributing/changelog-process.md

Co-authored-by: Agustin Bettati <[email protected]>

* rename to check-changelog-entry-file

* additional info in error message

* extract function validateChangelog

---------

Co-authored-by: Agustin Bettati <[email protected]>
  • Loading branch information
lantoli and AgustinBettati authored Apr 9, 2024
1 parent 5a7d85c commit 3ccc11c
Show file tree
Hide file tree
Showing 6 changed files with 285 additions and 5 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/check-changelog-entry-file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check changelog entry file

on:
pull_request:
types: [opened, reopened, synchronize, edited, labeled, unlabeled]

jobs:
check:
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version-file: 'go.mod'
- run: make check-changelog-entry-file
6 changes: 5 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ update-tf-compatibility-matrix: ## Update Terraform Compatibility Matrix documen
.PHONY: update-changelog-unreleased-section
update-changelog-unreleased-section:
./scripts/update-changelog-unreleased-section.sh

.PHONY: generate-changelog-entry
generate-changelog-entry:
./scripts/generate-changelog-entry.sh

.PHONY: check-changelog-entry-file
check-changelog-entry-file:
go run ./tools/check-changelog-entry-file/*.go
8 changes: 8 additions & 0 deletions contributing/changelog-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [Changelog format](#changelog-format)
- [Changelog entry guidelines](#changelog-entry-guidelines)
- [Script for creating changelog entry files](#script-for-creating-changelog-entry-files)
- [PR Changelog check](#pr-changelog-check)

HashiCorp’s open-source projects have always maintained user-friendly, readable CHANGELOG.md that allow users to tell at a glance whether a release should have any effect on them, and to gauge the risk of an upgrade.

Expand Down Expand Up @@ -143,3 +144,10 @@ make generate-changelog-entry
```

- The `subcategory` input prompt refers to the prefix of the changelog entry, used for specifying the relevant resource/data source when needed (e.g. data-source/mongodbatlas_project)

## PR Changelog check

A PR check is included to validate the changelog entry file.
If a PR doesn't need a changelog entry its check can be skipped:
- Adding the label `skip-changelog-check` to the PR.
- Check in PRs with title `chore`, `test`, `doc` or `ci` is automatically skipped. However a changelog can still be added if needed.
16 changes: 14 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22
require (
github.com/aws/aws-sdk-go v1.51.13
github.com/go-test/deep v1.1.0
github.com/hashicorp/go-changelog v0.0.0-20240318095659-4d68c58a6e7f
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/hcl/v2 v2.20.1
Expand Down Expand Up @@ -33,9 +34,11 @@ require (
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go/storage v1.36.0 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
Expand All @@ -44,9 +47,14 @@ require (
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.11.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand Down Expand Up @@ -76,7 +84,9 @@ require (
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -88,17 +98,19 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
Expand All @@ -122,7 +134,7 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down
Loading

0 comments on commit 3ccc11c

Please sign in to comment.