From 73c8706e83693f9a088a17b51f3539feaab49dd5 Mon Sep 17 00:00:00 2001 From: Jan Kadlec Date: Tue, 7 Jan 2025 08:33:42 +0100 Subject: [PATCH 1/2] ci: generate changelog for release JIRA: PSDK-216 risk: low --- .github/workflows/build-release.yaml | 9 +++++++++ .github/workflows/bump-version.yaml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index fdef088da..af9f052b6 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -60,6 +60,15 @@ jobs: uses: actions/download-artifact@v4 with: path: dist/ + - name: Generate changelog + id: changelog + uses: requarks/changelog-action@v1 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + tag: ${{ github.ref_name }} + writeToFile: false + includeRefIssues: false + useGitmojis: false - name: Create GitHub release uses: "softprops/action-gh-release@v2" with: diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version.yaml index f618a71ff..eb7f8a3d8 100644 --- a/.github/workflows/bump-version.yaml +++ b/.github/workflows/bump-version.yaml @@ -70,7 +70,7 @@ jobs: git config user.email github-actions@github.com git checkout -b ${{ steps.branch.outputs.release_branch }} git add -A - git commit -m "Bump to ${{steps.bump.outputs.new_version}}" + git commit -m "Release ${{steps.bump.outputs.new_version}}" git push origin ${{ steps.branch.outputs.release_branch }} git checkout master git merge ${{ steps.branch.outputs.release_branch }} From 9e7ef6315388b5b4791bb4227cd679ce5c28733d Mon Sep 17 00:00:00 2001 From: Jan Kadlec Date: Tue, 7 Jan 2025 08:44:29 +0100 Subject: [PATCH 2/2] ci: add gitlint to pre-commit hook JIRA: PSDK-216 risk: low --- .gitlint | 19 ++++++ .pre-commit-config.yaml | 4 ++ dev-requirements.txt | 2 + scripts/conventional_commit_gitlint_rule.py | 67 +++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 .gitlint create mode 100644 scripts/conventional_commit_gitlint_rule.py diff --git a/.gitlint b/.gitlint new file mode 100644 index 000000000..733396762 --- /dev/null +++ b/.gitlint @@ -0,0 +1,19 @@ +# (C) 2025 GoodData Corporation +[general] +# do not enforce maximum line length rules +ignore=T1, B1, B2, B5, T5 + +# prevent a warning about regexes in the ignore-by-title section +regex-style-search=true + +# enable our extended conventional commits rule +extra-path=packages/repo-tools/src/quiver_monorepo/conventional_commit_gitlint_rule.py + +# ignore all release commits (merge and revert commits are ignored by default) +[ignore-by-title] +regex=^Release(.*) +ignore=all + +# add the most likely scopes for each package +[gdc-title-conventional-commits] +scopes=gooddata-api-client,gooddata-dbt,gooddata-fdw,gooddata-flexconnect,gooddata-flight-server,gooddata-pandas,gooddata-sdk diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4826b5673..5f2d7def5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,3 +30,7 @@ repos: args: [ "--update", "FILES" ] language: script types: [ text ] + - repo: https://github.com/jorisroovers/gitlint + rev: v0.19.1 + hooks: + - id: gitlint diff --git a/dev-requirements.txt b/dev-requirements.txt index 197127bae..0379bdbf5 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,8 @@ -r ./tox-requirements.txt -r ./release-requirements.txt + pre-commit~=4.0.1 +gitlint~=0.19.1 -r ./fmt-requirements.txt diff --git a/scripts/conventional_commit_gitlint_rule.py b/scripts/conventional_commit_gitlint_rule.py new file mode 100644 index 000000000..69da6b3f1 --- /dev/null +++ b/scripts/conventional_commit_gitlint_rule.py @@ -0,0 +1,67 @@ +# (C) 2025 GoodData Corporation +""" +An extension of the CT1 rule from gitlint to enforce the conventional commit format. +This version also allows specifying allowed scope values. +""" + +import re + +from gitlint.options import ListOption +from gitlint.rules import CommitMessageTitle, LineRule, RuleViolation + +RULE_REGEX = re.compile(r"([^(]+?)(?:\(([^)]+?)\))?!?: .+") + +DEFAULT_TYPES = [ + "fix", + "feat", + "chore", + "docs", + "style", + "refactor", + "perf", + "test", + "revert", + "ci", + "build", +] +DEFAULT_SCOPES = [] + + +class ConventionalCommit(LineRule): + """This rule enforces the spec at https://www.conventionalcommits.org/.""" + + name = "gdc-title-conventional-commits" + id = "GD1" + target = CommitMessageTitle + + options_spec = [ + ListOption( + "types", + DEFAULT_TYPES, + "Comma separated list of allowed commit types.", + ), + ListOption( + "scopes", + DEFAULT_SCOPES, + "Comma separated list of allowed commit scopes.", + ), + ] + + def validate(self, line, _commit): + violations = [] + match = RULE_REGEX.match(line) + + if not match: + msg = "Title does not follow ConventionalCommits.org format 'type(optional-scope): description'" + violations.append(RuleViolation(self.id, msg, line)) + else: + line_commit_type = match.group(1) + line_commit_scope = match.group(2) + if line_commit_type not in self.options["types"].value: + opt_str = ", ".join(self.options["types"].value) + violations.append(RuleViolation(self.id, f"Title does not start with one of {opt_str}", line)) + if line_commit_scope and line_commit_scope not in self.options["scopes"].value: + opt_str = ", ".join(self.options["scopes"].value) + violations.append(RuleViolation(self.id, f"Scope is defined and is not one of {opt_str}", line)) + + return violations