-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: enhance auto-labeling in the repo (#2237)
Signed-off-by: Ahmed AbouZaid <[email protected]>
- Loading branch information
Showing
9 changed files
with
219 additions
and
35 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
support: | ||
- 'SUPPORT-\d+' | ||
|
||
platform/aws: | ||
- '/Platform:.*(AWS|EKS).*/i' | ||
|
||
platform/gcp: | ||
- '/Platform:.*(GCP|GKE).*/i' | ||
|
||
platform/openshift: | ||
- '/Platform:.*OpenShift.*/i' | ||
|
||
platform/local: | ||
- '/Platform:.*(KIND|K3d|Local).*/i' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# | ||
# Components. | ||
|
||
component/connectors: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- 'charts/camunda-platform-*/templates/connectors/**' | ||
|
||
component/console: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- 'charts/camunda-platform-*/templates/console/**' | ||
|
||
component/identity: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- 'charts/camunda-platform-*/templates/identity/**' | ||
- 'charts/camunda-platform-*/charts/identity/**' | ||
|
||
component/operate: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- 'charts/camunda-platform-*/templates/operate/**' | ||
- 'charts/camunda-platform-*/charts/operate/**' | ||
|
||
component/optimize: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- 'charts/camunda-platform-*/templates/optimize/**' | ||
- 'charts/camunda-platform-*/charts/optimize/**' | ||
|
||
component/monitoring: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- 'charts/camunda-platform-*/templates/service-monitor/**' | ||
|
||
component/tasklist: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- 'charts/camunda-platform-*/templates/tasklist/**' | ||
- 'charts/camunda-platform-*/charts/tasklist/**' | ||
|
||
component/web-modeler: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- 'charts/camunda-platform-*/templates/web-modeler/**' | ||
|
||
component/zeebe: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- 'charts/camunda-platform-*/templates/zeebe/**' | ||
- 'charts/camunda-platform-*/charts/zeebe/**' | ||
- 'charts/camunda-platform-*/templates/zeebe-gateway/**' | ||
- 'charts/camunda-platform-*/charts/zeebe-gateway/**' | ||
# | ||
# Tools. | ||
|
||
tool/github-actions: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- '.github/actions/**' | ||
- '.github/workflows/**' | ||
|
||
tool/release-please: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- '.github/config/release-please/**' | ||
|
||
tool/renovatebot: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- '.github/renovate.json5' | ||
|
||
tool/asdf: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- '.tool-versions' | ||
|
||
tool/script: | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- 'Makefile' | ||
- 'scripts/**' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Repo - Issue Labels | ||
|
||
on: | ||
issues: | ||
types: | ||
- opened | ||
- edited | ||
|
||
permissions: | ||
issues: write | ||
contents: read | ||
|
||
jobs: | ||
issue-labeler: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Run Issue Labeler | ||
uses: github/issue-labeler@c1b0f9f52a63158c4adc09425e858e87b32e9685 # v3.4 | ||
with: | ||
configuration-path: .github/config/issue-labeler.yaml | ||
enable-versioned-regex: 0 | ||
repo-token: "${{ github.token }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Repo - Pull Request Labels | ||
|
||
on: | ||
pull_request_target: | ||
|
||
jobs: | ||
labeler: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Run Labeler | ||
uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5 | ||
with: | ||
configuration-path: .github/config/pr-labeler.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# A script to label PRs based on the app and chart version. | ||
# It meant to run in the post-release workflow and before merging the release PR. | ||
|
||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# Init. | ||
# Check dependencies. | ||
dep_names="ct gh git git-cliff grep jq yq" | ||
for dep_name in ${dep_names}; do | ||
test -n "$(which ${dep_name})" || ( | ||
echo "Missing dependency: ${dep_name}"; | ||
echo "Dependencies list: ${dep_names}"; | ||
exit 1 | ||
) | ||
done | ||
# Ensure that the main branch is there. | ||
test "$(git branch --show-current)" != "main" && | ||
git fetch origin main:main --no-tags | ||
|
||
# Vars. | ||
release_please_config=".github/config/release-please/release-please-config.json" | ||
latest_release_commit="$(git show main:${release_please_config} | jq -r '."bootstrap-sha"')" | ||
cliff_config_file=".github/config/cliff.toml" | ||
|
||
# Get PRs from commits in a certain chart dir. | ||
get_prs_per_chart_dir () { | ||
chart_dir="${1}" | ||
git-cliff --context \ | ||
--config "${cliff_config_file}" \ | ||
--include-path "${chart_dir}/**" \ | ||
${latest_release_commit}.. | | ||
jq '.[].commits[].message' | grep -Po '(?<=#)\d+' | ||
} | ||
|
||
# Get the issues fixed by a PR. | ||
# Note: GH CLI doesn't support this so we use the API call directly. | ||
# https://github.com/cli/cli/discussions/7097#discussioncomment-5229031 | ||
get_issues_per_pr () { | ||
pr_nubmer="${1}" | ||
gh api graphql -F owner='camunda' -F repo='camunda-platform-helm' -F pr="${pr_nubmer}" -f query=' | ||
query ($owner: String!, $repo: String!, $pr: Int!) { | ||
repository(owner: $owner, name: $repo) { | ||
pullRequest(number: $pr) { | ||
closingIssuesReferences(first: 100) { | ||
nodes { | ||
number | ||
} | ||
} | ||
} | ||
} | ||
}' --jq '.data.repository.pullRequest.closingIssuesReferences.nodes[].number' | ||
} | ||
|
||
# Run. | ||
# Label PRs with the app and chart version only if there is a change in the chart. | ||
ct list-changed | while read chart_dir; do | ||
app_version="$(yq '.appVersion | sub("\..$", "")' ${chart_dir}/Chart.yaml)" | ||
chart_version="$(yq '.version' ${chart_dir}/Chart.yaml)" | ||
app_version_label="version/${app_version}" | ||
# The "version:x.y.z" label format is used by the support team, | ||
# it must not changed without checking with the support team. | ||
chart_version_label="version:${chart_version}" | ||
|
||
echo -e "\nChart dir: ${chart_dir}" | ||
echo "Apps version: ${app_version}" | ||
echo "Chart version: ${chart_version}" | ||
get_prs_per_chart_dir "${chart_dir}" | while read pr_nubmer; do | ||
# Label PR. | ||
gh pr edit "${pr_nubmer}" --add-label "${app_version_label},${chart_version_label}" | ||
# Label the PR's corresponding issue. | ||
# TODO: Update the logic to work with multi issues (usually we don't have that). | ||
issue_nubmer="$(get_issues_per_pr ${pr_nubmer})" | ||
test -n "${issue_nubmer}" && | ||
gh issue edit "${issue_nubmer}" --add-label "${app_version_label},${chart_version_label}" | ||
done | ||
done |