alexellis / derek

Reduce maintainer fatigue by automating GitHub
https://github.com/alexellis/derek/blob/master/USER_GUIDE.md
MIT License
806 stars 72 forks source link

Add comma separated multi labels facility #115

Closed rgee0 closed 5 years ago

rgee0 commented 5 years ago

Signed-off-by: Richard Gee richard@technologee.co.uk

Description

This change enables multiple labels to be applied through a single comment, by allowing for a comma separated list to be provided. Also added plural aliases for the labels commands.

This change also introduces a new env var which limits how many labels can be processed in a single command. This defaults to 5 but can be set to preference through multilabel_limit. An example has been included in the stack.example.yml. A test has been added for the function which retrieves this value from the env vars.

As the requested labels are pre-processed to ascertain which are actionable and which are not given the requested action, the limit will be applied to the first n actionable labels, rather than the first n requested labels.

As the deletion of multiple labels is currently an iterative process - due to how the GitHub API is presented - an error could occur mid-flow when deleting and cause subsequent labels to not be applied. Mitigation against this is that labels are visually verifiable.

Motivation and Context

Currently to add multiple labels a maintainer must add one comment for each label. Members have found this confusing with some calling the command multiple times per comment.

[x] I have raised an issue to propose this change (fixes #32, closes #110 )

How Has This Been Tested?

Unit tests added. Built Derek at rgee0/derek:multiLabels Deployed locally Tested on test repo - https://github.com/rgee0/Test/issues/8

environment:
      application_id: 6184
      debug: true
      customers_url: https://raw.githubusercontent.com/alexellis/derek/master/.CUSTOMERS
      validate_hmac: false
      validate_customers: true
      secret_path: /var/openfaas/secrets/ # use /run/secrets/ for older OpenFaaS versions

image

environment:
      application_id: 6184
      multilabel_limit: 3
      debug: true
      customers_url: https://raw.githubusercontent.com/alexellis/derek/master/.CUSTOMERS
      validate_hmac: false
      validate_customers: true
      secret_path: /var/openfaas/secrets/ # use /run/secrets/ for older OpenFaaS versions

image

environment:
      application_id: 6184
      multilabel_limit: 3
      debug: true
      customers_url: https://raw.githubusercontent.com/alexellis/derek/master/.CUSTOMERS
      validate_hmac: false
      validate_customers: true
      secret_path: /var/openfaas/secrets/ # use /run/secrets/ for older OpenFaaS versions

image

updated tests to cover handling of newlines

image

image

image

image

Types of changes

Checklist:

kolyshkin commented 5 years ago

@rgee0 thanks for your work! I am interested if you tried running Test_getCommandValue before your commit. I mean, it makes sense to check that the test fails before and passes after a fix.

alexellis commented 5 years ago

@kolyshkin the tests I believe are run through CI and Richard is known for his attention to detail and unit testing. Do we have some issues with the CI not running all tests for all packages?

I made a change for this recently, not sure if it's related?

Alex

alexellis commented 5 years ago

@rgee0 FYI I've been making major structural changes to the Derek README. Please can you revert your changes to README.md and apply them to the user guide? I'll go ahead and merge after that then bump the version.

Alex

rgee0 commented 5 years ago

rebased