renovatebot / renovate-approve-bot-bitbucket-cloud

renovate-approve-bot - Bitbucket Cloud Edition
ISC License
12 stars 8 forks source link

Copy/paste `status`, `priority` and `type` labels from the Renovate repo #59

Open HonkingGoose opened 2 years ago

HonkingGoose commented 2 years ago

Right now we have very basic labels like bug, enhancement etc.

I'd like to have these labels copied from the Renovate bot repository:

What do you think? Do you want the labels to be the same, or are you happy with just the basic labels?

I don't have the rights to create labels, so these will need to be copy/pasted by someone with write level rights.

viceice commented 2 years ago

Like to have then at all our repos. Anybody knows how to make that semi automatic?

maxbrunet commented 2 years ago

This could be a start:

Organization owners can manage default labels for repositories in the organization.

https://docs.github.com/en/organizations/managing-organization-settings/managing-default-labels-for-repositories-in-your-organization

For existing repos, the API^api could be used, for example, there is this EddieHubCommunity/gh-action-open-source-labels Github Actions which relies on xavierchow/github-label-template, but nothing standing out (more on the marketplace https://github.com/marketplace?type=actions&query=repository+label), a small script may be enough for a one time thing.

HonkingGoose commented 2 years ago

I've collected the list of our current "basic labels" that we use over on the Renovate repository:

Status of issue, hex color code: #1d76db status:requirements status:blocked status:ready status:in-progress status:waiting-on-response
Type of issue, hex color code: #006b75 type:bug type:docs type:feature type:refactor type:help
Priority, hex color code: #c2e0c6 priority-1-critical priority-2-important priority-3-normal priority-4-low priority-5-triage
maxbrunet commented 2 years ago

Created them for this repo

create_labels.sh ```bash #!/usr/bin/env bash set -euo pipefail declare -r GH_TOKEN="${GH_TOKEN?}" declare -r ORG='renovatebot' declare -rA LABELS=( ['priority-1-critical']='A bad bug or work that is holding up a lot of other important features or fixes' ['priority-2-important']='User-visible bugs or very important features' ['priority-3-normal']='Default priority, \"should be done\" but isn'\''t prioritised ahead of others' ['priority-4-low']='Low priority, unlikely to be done unless it becomes important to more people' ['priority-5-triage']='Needs Priority triage and a new priority label assigned' ['status:blocked']='Issue is blocked by another issue or external requirement' ['status:in-progress']='Someone is working on implementation' ['status:ready']='Ready to start implementation' ['status:requirements']='Full requirements are not yet known, so implementation should not be started' ['status:waiting-on-response']='Waiting on a response/more information from the user' ['type:bug']='Bug fix of existing functionality' ['type:docs']='Documentation' ['type:feature']='Feature (new functionality)' ['type:help']='Issues which should be converted to discussion' ['type:refactor']='Refactoring or improving of existing code' ) function get_repos() { local -n arr="${1}" # List all repos in the organization # shellcheck disable=SC2034 # while IFS=$'\n' read -r repo; do arr+=("${repo}"); done < <( # curl --silent --show-errors --fail \ # "https://api.github.com/orgs/${ORG}/repos" \ # --request GET \ # --header 'Accept: application/vnd.github.v3+json' \ # --header "Authorization: Bearer ${GH_TOKEN}" \ # | jq --raw-ouput '.[].name' # ) arr=('renovate-approve-bot-bitbucket-cloud') return 0 } function get_color() { local kind=${1} case "${kind}" in status:*) echo '1d76db' ;; type:*) echo '006b75' ;; priority-*) echo 'c2e0c6' ;; *) printf 'Error: Unknown kind %s\n' "${kind}" >&2 return 1 ;; esac return 0 } function main { local -a repos local repo label get_repos repos for repo in "${repos[@]}"; do for label in "${!LABELS[@]}"; do if ! curl --fail "https://api.github.com/repos/${ORG}/${repo}/labels" \ --request POST \ --header 'Accept: application/vnd.github.v3+json' \ --header "Authorization: Bearer ${GH_TOKEN}" \ --data "{ \"name\": \"${label}\", \"color\": \"$(get_color "${label}")\", \"description\": \"${LABELS[${label}]}\" }"; then printf 'Error: Could not create label %s. It may already exist.\n' "${label}" >&2 fi done done } main "${@}" ```
HonkingGoose commented 2 years ago

Oh wow, that's really cool! 😄 👍

I'll go apply the new labels to our existing issues.

HonkingGoose commented 2 years ago

The priority-3-normal label is missing from the label list.

Maybe there's a problem in the code that creates the priority-3-normal label? Maybe a problem with the special character escapes???

  ['priority-3-normal']='Default priority, "should be done" but isn'\''t prioritised ahead of others'
HonkingGoose commented 2 years ago

These descriptions are wrong:

// Current code:
  ['type:refactor']='Issues which should be converted to discussion'
  ['type:help']='Refactoring or improving of existing code'

It should be:

// Improved code:
  ['type:refactor']='Refactoring or improving of existing code'
  ['type:help']='Issues which should be converted to discussion'
maxbrunet commented 2 years ago

Oops I fixed these labels

HonkingGoose commented 2 years ago

@maxbrunet Thank you for fixing the script and the labels! 🥳

Can we put this script in a new repository under our organization? That way we can grab the script when we're making a new repository and get the labels set-up correctly. If the organization default labels change, they can be changed with a PR to the script repository.

Or we could let @rarkins set up the default labels for the organization? ^gh-docs

viceice commented 2 years ago

i prefer our .github repo

HonkingGoose commented 2 years ago

i prefer our .github repo

I totally forgot about that repository! 🙈 It should go in there! 😉

maxbrunet commented 2 years ago

The script is very basic and does not support updating labels, so even if it was a fun exercise to write it, I do not think we should use it.

What about this Probot app: https://github.com/probot/settings?

It supports configuring nearly everything including labels via PR, and inheritance from the .github repo

Edit: Looks like there is an issue, the inheritance has never been working

HonkingGoose commented 2 years ago

The script is very basic and does not support updating labels, so even if it was a fun exercise to write it, I do not think we should use it.

We could still put the script in renovatebot/.github and use it after we've created a new repository to set all the basic labels on the new repository? Or do you think that's also a bad idea? 😄