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

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

Open
HonkingGoose opened this issue Nov 24, 2021 · 13 comments
Open
Labels
priority-4-low Low priority, unlikely to be done unless it becomes important to more people status:in-progress Someone is working on implementation type:feature Feature (new functionality)

Comments

@HonkingGoose
Copy link
Collaborator

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

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

  • status:
  • type:
  • priority

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.

@HonkingGoose HonkingGoose added the enhancement New feature or request label Nov 24, 2021
@viceice
Copy link
Member

viceice commented Nov 26, 2021

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

@maxbrunet
Copy link
Collaborator

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 API1 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.

Footnotes

  1. https://docs.github.com/en/rest/reference/issues#create-a-label

@HonkingGoose
Copy link
Collaborator Author

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
Copy link
Collaborator

maxbrunet commented Nov 29, 2021

Created them for this repo

create_labels.sh
#!/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
Copy link
Collaborator Author

Oh wow, that's really cool! 😄 👍

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

@HonkingGoose HonkingGoose added status:in-progress Someone is working on implementation and removed enhancement New feature or request labels Nov 29, 2021
@HonkingGoose
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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'

@HonkingGoose HonkingGoose added priority-4-low Low priority, unlikely to be done unless it becomes important to more people type:refactor Refactoring or improving of existing code labels Nov 29, 2021
@HonkingGoose HonkingGoose changed the title Copy/paste status, priority and type labels from the Renovate repo? Copy/paste status, priority and type labels from the Renovate repo Nov 29, 2021
@maxbrunet
Copy link
Collaborator

Oops I fixed these labels

@HonkingGoose
Copy link
Collaborator Author

@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? 1

Footnotes

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

@viceice
Copy link
Member

viceice commented Nov 30, 2021

i prefer our .github repo

@HonkingGoose
Copy link
Collaborator Author

i prefer our .github repo

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

@maxbrunet
Copy link
Collaborator

maxbrunet commented Dec 1, 2021

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
Copy link
Collaborator Author

HonkingGoose commented Dec 2, 2021

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? 😄

@maxbrunet maxbrunet added type:feature Feature (new functionality) and removed type:refactor Refactoring or improving of existing code labels Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-4-low Low priority, unlikely to be done unless it becomes important to more people status:in-progress Someone is working on implementation type:feature Feature (new functionality)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants