Skip to content
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

Updated GitHub labels generation to contain state and PR based labels. #1241

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/label-merge-conflict.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
- name: Check if PRs have conflicts
uses: eps1lon/actions-label-merge-conflict@releases/2.x
with:
dirtyLabel: "CONFLICT"
dirtyLabel: "PR: CONFLICT"
removeOnDirtyLabel: "Needs review"
repoToken: "${{ secrets.GITHUB_TOKEN }}"
51 changes: 38 additions & 13 deletions .scaffold/tests/bats/workflow.utilities.bats
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,54 @@ load _helper.workflow.bash
assert_output_not_contains "ERROR"

run curl https://github.com/drevops/scaffold-destination/labels
assert_success

assert_output_contains ">AUTOMERGE<"
assert_output_contains ">BLOCKED<"
assert_output_contains "Issue or pull request is blocked"
assert_output_contains ">PR: AUTOMERGE<"
assert_output_contains "Pull request has been approved and set to automerge"
assert_output_contains ">CONFLICT<"
assert_output_contains ">PR: CONFLICT<"
assert_output_contains "Pull request has a conflict that needs to be resolved before it can be merged"
assert_output_contains ">DO NOT MERGE<"
assert_output_contains ">PR: Dependencies<"
assert_output_contains "Pull request was raised automatically by a dependency bot"
assert_output_contains ">PR: DO NOT MERGE<"
assert_output_contains "Do not merge this pull request"
assert_output_contains ">Do not review<"
assert_output_contains ">PR: Do not review<"
assert_output_contains "Do not review this pull request"
assert_output_contains ">Needs review<"
assert_output_contains ">PR: Needs review<"
assert_output_contains "Pull request needs a review from assigned developers"
assert_output_contains ">Questions<"
assert_output_contains "Pull request has some questions that need to be answered before further review can progress"
assert_output_contains ">Ready for test<"
assert_output_contains ">PR: Ready for test<"
assert_output_contains "Pull request is ready for manual testing"
assert_output_contains ">Ready to be merged<"
assert_output_contains ">PR: Ready to be merged<"
assert_output_contains "Pull request is ready to be merged (assigned after testing is complete)"
assert_output_contains ">Requires more work<"
assert_output_contains ">PR: Requires more work<"
assert_output_contains "Pull request was reviewed and reviver(s) asked to work further on the pull request"
assert_output_contains ">URGENT<"
assert_output_contains ">PR: URGENT<"
assert_output_contains "Pull request needs to be urgently reviewed"
assert_output_contains ">dependencies<"
assert_output_contains "Pull request was raised automatically by a dependency bot"
assert_output_contains ">State: Confirmed<"
assert_output_contains "The issue was triaged and confirmed for development"
assert_output_contains ">State: Done<"
assert_output_contains "The issue is complete and waiting for a release"
assert_output_contains ">State: In progress<"
assert_output_contains "The issue is being worked on"
assert_output_contains ">State: Needs more info<"
assert_output_contains "The issue requires more information"
assert_output_contains ">State: Needs more work<"
assert_output_contains "The issue requires more work"
assert_output_contains ">State: Needs triage<"
assert_output_contains "An issue or PR has not been assessed and requires a triage"
assert_output_contains ">State: QA<"
assert_output_contains "The issue is in QA"
assert_output_contains ">Type: Chore<"
assert_output_contains "Issue is a related to a maintenance"
assert_output_contains ">Type: Defect<"
assert_output_contains "Issue is a defect"
assert_output_contains ">Type: Feature<"
assert_output_contains "Issue is a new feature request"
assert_output_contains ">Type: Question<"
assert_output_contains "Issue is a question"
assert_output_contains ">UPSTREAM<"
assert_output_contains "Issue or pull request is related to an upstream project"

assert_output_not_contains ">bug<"
assert_output_not_contains ">duplicate<"
Expand Down
6 changes: 5 additions & 1 deletion .scaffold/tests/lint.scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ for file in "${targets[@]}"; do
echo "Checking file ${file}"

if ! "${ROOT_DIR}/.scaffold/tests/vendor/bin/shellvar" lint "${file}"; then
exit 1
# Skip the file with a false positive.
# @see https://github.com/AlexSkrypnyk/shellvar/issues/65
if [[ ! "${file}" =~ github-labels ]]; then
exit 1
fi
fi

if ! LC_ALL=C.UTF-8 shellcheck "${file}"; then
Expand Down
2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": ["config:base"],
"branchPrefix": "deps/",
"labels": ["dependencies"],
"labels": ["PR: Dependencies"],
"assignees": [],
"ignorePresets": [":prHourlyLimit2"],
"rangeStrategy": "update-lockfile",
Expand Down
51 changes: 29 additions & 22 deletions scripts/drevops/github-labels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,29 @@
# Array of labels to create. If DELETE_EXISTING_LABELS=1, the labels list will
# be exactly as below, otherwise labels below will be added to existing ones.
labels=(
"AUTOMERGE" "934BF4" "Pull request has been approved and set to automerge"
"CONFLICT" "bc143e" "Pull request has a conflict that needs to be resolved before it can be merged"
"DO NOT MERGE" "d93f0b" "Do not merge this pull request"
"Do not review" "d93f0b" "Do not review this pull request"
"Needs review" "5319e7" "Pull request needs a review from assigned developers"
"Questions" "b5f492" "Pull request has some questions that need to be answered before further review can progress"
"Ready for test" "0e8a16" "Pull request is ready for manual testing"
"Ready to be merged" "c2e0c6" "Pull request is ready to be merged (assigned after testing is complete)"
"Requires more work" "b60205" "Pull request was reviewed and reviver(s) asked to work further on the pull request"
"URGENT" "d93f0b" "Pull request needs to be urgently reviewed"
"dependencies" "62E795" "Pull request was raised automatically by a dependency bot"
"BLOCKED" "D93F0B" "Issue or pull request is blocked"
"PR: AUTOMERGE" "934BF4" "Pull request has been approved and set to automerge"
"PR: CONFLICT" "bc143e" "Pull request has a conflict that needs to be resolved before it can be merged"
"PR: Dependencies" "62E795" "Pull request was raised automatically by a dependency bot"
"PR: DO NOT MERGE" "d93f0b" "Do not merge this pull request"
"PR: Do not review" "d93f0b" "Do not review this pull request"
"PR: Needs review" "5319e7" "Pull request needs a review from assigned developers"
"PR: Ready for test" "0e8a16" "Pull request is ready for manual testing"
"PR: Ready to be merged" "c2e0c6" "Pull request is ready to be merged (assigned after testing is complete)"
"PR: Requires more work" "b60205" "Pull request was reviewed and reviver(s) asked to work further on the pull request"
"PR: URGENT" "d93f0b" "Pull request needs to be urgently reviewed"
"State: Confirmed" "1183aa" "The issue was triaged and confirmed for development"
"State: Done" "0e8a16" "The issue is complete and waiting for a release"
"State: In progress" "f2f626" "The issue is being worked on"
"State: Needs more info" "adf2cd" "The issue requires more information"
"State: Needs more work" "ecaf2d" "The issue requires more work"
"State: Needs triage" "cccccc" "An issue or PR has not been assessed and requires a triage"
"State: QA" "dbad90" "The issue is in QA"
"Type: Chore" "006b75" "Issue is a related to a maintenance"
"Type: Defect" "d93f0b" "Issue is a defect"
"Type: Feature" "1d76db" "Issue is a new feature request"
"Type: Question" "b5f492" "Issue is a question"
"UPSTREAM" "fbca04" "Issue or pull request is related to an upstream project"

Check warning on line 63 in scripts/drevops/github-labels.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/github-labels.sh#L41-L63

Added lines #L41 - L63 were not covered by tests

# Uncomment default Github labels below to preserve them.
# "bug" "d73a4a" "Something isn't working"
Expand Down Expand Up @@ -265,17 +277,12 @@
local json="${1}"
local prop="${2}"

temp=$(
echo "${json}" |
sed 's/\\\\\//\//g' |
sed 's/[{}]//g' |
awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' |
sed 's/\"\:\"/\|/g' |
sed 's/[\,]/ /g' |
grep -w "${prop}" |
cut -d":" -f2 |
sed -e 's/^ *//g' -e 's/ *$//g'
)
temp=$(echo "${json}" |
sed 's/\\\\\//\//g' |
sed 's/[{}]//g' |
awk -v k="text" -F ',"' '{ for (i=1; i<=NF; i++) if ($i ~ /^'"${prop}"'":/) print $i }' |
sed 's/.*:"//g' |

Check warning on line 284 in scripts/drevops/github-labels.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/github-labels.sh#L280-L284

Added lines #L280 - L284 were not covered by tests
sed 's/"$//g')
temp="${temp//${prop}|/}"
temp="$(echo "${temp}" | tr '\r\n' ' ')"

Expand Down
Loading