-
Notifications
You must be signed in to change notification settings - Fork 34
[CI] Adding release notes for non-rc versions & PR validations workflows #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3e26ccb
91aa535
355728a
ba88c03
5ed1f83
9640e9c
cbe71fc
6264877
3413976
8ec1302
72ae161
e51bd28
c5d7b50
6cb4f4b
79daf5b
0aa31b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| name: PR Validation | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, edited, reopened] | ||
| concurrency: | ||
| group: pr-validation-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| validate-and-label: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - name: Validate PR title and assign label | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
| script: | | ||
| const title = context.payload.pull_request.title; | ||
| const prNumber = context.payload.pull_request.number; | ||
|
|
||
| const allowedScopes = ['feature', 'fix', 'docs', 'improvement', 'revert', 'breaking', 'ci']; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The allowed scopes (feature, fix, docs, improvement, revert, breaking, ci) don't align with cliff.toml's commit parsers (feat, fix, perf, refactor, docs, chore, revert, breaking). feature passes validation but won't match [feat] in cliff |
||
|
|
||
| const scopeToLabel = { | ||
| feature: 'feature', | ||
| ci: 'ci', | ||
| fix: 'bug', | ||
| docs: 'documentation', | ||
| improvement: 'improvement', | ||
| revert: 'revert', | ||
| breaking: 'breaking-change', | ||
| }; | ||
|
|
||
| const match = title.match(/^\[([^\]]+)\]\s+\S+/); | ||
|
|
||
| if (!match) { | ||
| core.setFailed( | ||
| `PR title must follow the format: [scope] description\n` + | ||
| `Allowed scopes (case-insensitive): [Feature], [Fix], [Docs], [Improvement], [Revert], [Breaking], [CI]\n` + | ||
| `Example: [Feature] Add SeaweedFS bucket auto-creation` | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const scope = match[1].toLowerCase(); | ||
|
|
||
| if (!allowedScopes.includes(scope)) { | ||
| core.setFailed( | ||
| `Invalid scope "[${match[1]}]".\n` + | ||
| `Allowed scopes (case-insensitive): [Feature], [Fix], [Docs], [Improvement], [Revert], [Breaking], [CI]\n` + | ||
| `Example: [Fix] Resolve crash on startup` | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const labelName = scopeToLabel[scope]; | ||
|
|
||
| // Remove any stale scope labels from a previous title edit | ||
| const allScopeLabels = Object.values(scopeToLabel); | ||
| const currentLabels = context.payload.pull_request.labels.map(l => l.name); | ||
|
|
||
| for (const stale of currentLabels) { | ||
| if (allScopeLabels.includes(stale) && stale !== labelName) { | ||
| await github.rest.issues.removeLabel({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| name: stale, | ||
| }); | ||
| core.info(`Removed stale label: ${stale}`); | ||
| } | ||
| } | ||
|
|
||
| // Apply the correct label if not already present | ||
| if (!currentLabels.includes(labelName)) { | ||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| labels: [labelName], | ||
| }); | ||
| } | ||
|
|
||
| core.info(`PR title valid — scope: [${scope}] → label: ${labelName}`); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| [changelog] | ||
| header = "" | ||
| body = """ | ||
| {% for group, commits in commits | sort(attribute="group") | group_by(attribute="group") %}\ | ||
| ### {{ group | striptags | trim | upper_first }} | ||
| {% for commit in commits %}\ | ||
| - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ | ||
| {% if commit.breaking %}[**breaking**] {% endif %}\ | ||
| {{ commit.message | split(pat="\n") | first | upper_first }} \ | ||
| ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/mlrun/ce/commit/{{ commit.id }}))\ | ||
| \n \ | ||
| {% endfor %} | ||
| {% endfor %}\n | ||
| """ | ||
| trim = true | ||
| footer = "" | ||
|
|
||
| [git] | ||
| conventional_commits = false | ||
| filter_unconventional = false | ||
| split_commits = false | ||
| commit_preprocessors = [] | ||
| commit_parsers = [ | ||
| # skip merge commits | ||
| { message = "(?i)^merge", skip = true }, | ||
|
|
||
| # new PR title format (enforced by pr-validation.yml): [scope] description | ||
| # allowed scopes: feature, fix, docs, improvement, revert, breaking, ci | ||
| { message = "(?i)^\\[feature\\]", group = "Features" }, | ||
| { message = "(?i)^\\[fix\\]", group = "Bug Fixes" }, | ||
| { message = "(?i)^\\[docs\\]", group = "Documentation" }, | ||
| { message = "(?i)^\\[improvement\\]", group = "Improvements" }, | ||
| { message = "(?i)^\\[revert\\]", group = "Reverts" }, | ||
| { message = "(?i)^\\[breaking\\]", group = "Breaking Changes" }, | ||
| { message = "(?i)^\\[ci\\]", group = "CI/CD" }, | ||
|
|
||
| # conventional commits format: feat: / fix: ... | ||
| { message = "(?i)^feat", group = "Features" }, | ||
| { message = "(?i)^fix", group = "Bug Fixes" }, | ||
| { message = "(?i)^refactor", group = "Improvements" }, | ||
| { message = "(?i)^docs?", group = "Documentation" }, | ||
| { message = "(?i)^chore\\(deps\\)", group = "Improvements" }, | ||
| { message = "(?i)^revert", group = "Reverts" }, | ||
|
|
||
| # historical [ComponentName] format — infer type from the verb in the message | ||
| { message = "(?i)^\\[[^\\]]+\\].*(fix|bug|broken|regression)", group = "Bug Fixes" }, | ||
| { message = "(?i)^\\[[^\\]]+\\].*(add|support|enable|upgrade|update|migrate|connect|expose|allow)", group = "Features" }, | ||
| { message = "(?i)^\\[[^\\]]+\\]", group = "Other" }, | ||
|
|
||
| # plain English fallback | ||
| { message = "(?i)^(fix|bug)", group = "Bug Fixes" }, | ||
| { message = "(?i)^(add|update|upgrade|support|enable|migrate|expose|allow)", group = "Features" }, | ||
| { message = "(?i)^(remove|disable|clean|deprecat)", group = "Other" }, | ||
|
|
||
| # catch-all — anything that didn't match above | ||
| { message = ".*", group = "Other" }, | ||
| ] | ||
| protect_breaking_commits = false | ||
| filter_commits = false | ||
| tag_pattern = "mlrun-ce-[0-9].*" | ||
| skip_tags = "" | ||
| ignore_tags = "" | ||
| topo_order = false | ||
| sort_commits = "newest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add conmcurrency to avoid race conditions