Skip to content

.github: Add Python and Scripting labels to pull requests#32700

Merged
peterbarker merged 1 commit into
ArduPilot:masterfrom
cclauss:patch-7
Apr 12, 2026
Merged

.github: Add Python and Scripting labels to pull requests#32700
peterbarker merged 1 commit into
ArduPilot:masterfrom
cclauss:patch-7

Conversation

@cclauss

@cclauss cclauss commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Add Python and Scripting labels to pull requests that add, delete, or modify files containing those languages.
image is added to pull requests that modify .py files.
Scripting is added to pull requests that modify .lua files.

Summary

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

Lua is currently 4.8%, and Python is 12.7% of this repo, so most pull requests will not modify these files. However, some contributors will have expertise in these languages and will be interested in reviewing pull requests that modify them. This quick GitHub Action will add labels to enable the rapid isolation of pull requests that contain these minority languages.

How was this tested?

It is quite difficult to test pull_request_target triggered GitHub Actions on a repo that you are not a maintainer of because GitHub purposefully makes it difficult to generate pull_request_target events.

@cclauss cclauss force-pushed the patch-7 branch 4 times, most recently from 9272f82 to 489370f Compare April 8, 2026 00:46
@peterbarker

Copy link
Copy Markdown
Contributor

How was this tested?

@cclauss

cclauss commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

I ran numerous tests on my own repo. Given that it runs in a few seconds yet it takes hours of CI resources here and other unrelated tests frequently fail I did not replicate those tests on this repo.

@tpwrules

tpwrules commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

What will this do on e.g. my fork that does not have these labels? Is it a no-operation?

(Our repo does not but that would be simple to add.)

May consider changing "Lua" to "Scripting", that label already exists.

@cclauss

cclauss commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

It will add a Python label even if that label has not been predefined.

Changing Lua to Scripting on line 46 would change the label.

@cclauss

cclauss commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

Add commented-out debugging commands for those who desire to test.

@cclauss cclauss changed the title .github: Add Lua and Python labels to pull requests .github: Add Python and Scripting labels to pull requests Apr 10, 2026
@cclauss

cclauss commented Apr 10, 2026

Copy link
Copy Markdown
Contributor Author

Changed Lua to Scripting to use that preexsisting label.

@cclauss cclauss marked this pull request as draft April 10, 2026 13:16
@cclauss

cclauss commented Apr 10, 2026

Copy link
Copy Markdown
Contributor Author

How was this tested?

Try creating a pull request at https://github.com/cclauss/labels_by_language, adding test.lua and test.py.

It is quite difficult to test pull_request_target triggered GitHub Actions on a repo that you are not a maintainer of because GitHub purposefully makes it difficult to generate pull_request_target events.

@cclauss cclauss marked this pull request as ready for review April 10, 2026 16:08
@cclauss cclauss force-pushed the patch-7 branch 5 times, most recently from ff805f9 to ce340e1 Compare April 11, 2026 17:00

@tpwrules tpwrules left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we need to remove labels if the PRs no longer contain those types of file? I see this runs on force pushes.

Comment thread .github/workflows/labels.yml Outdated
if (filename.endsWith('.lua')) labels.add('Scripting');
else if (filename.endsWith('.py')) labels.add('Python');

if (labels.size === 2) break;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this super tiny optimization is worth the chance of forgetting to update it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@cclauss

cclauss commented Apr 11, 2026

Copy link
Copy Markdown
Contributor Author

I see this runs on force pushes.

Are you saying that calling github.rest.issues.addLabels() is doing a force push?!?
I doubt this workflow does because it never uses: action/checkout.

Add ___Lua___ and ___Python___ labels to pull requests that add, delete, or modify files containing those languages.  Lua is currently 4.8%, and Python is 12.7% of this repo, so most pull requests will not modify these files.  However, some contributors will have expertise in these languages and will be interested in reviewing pull requests that modify them.

This quick GitHub Action will add labels to enable the rapid isolation of pull requests that contain these minority languages.
@tpwrules

tpwrules commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

I'm saying this new workflow will update the labels on a PR if that PR is force pushed. That is what "synchronize" means AFAIK.

But it can only ever add labels if the force push has a new type. Should it remove them too if the PR is force pushed to remove a change to a type of file? Not saying it needs to, just pointing out an observation and wondering your intention.

@cclauss

cclauss commented Apr 11, 2026

Copy link
Copy Markdown
Contributor Author

I don't think the super-tiny optimization of dealing with forced revert is worth the chance of getting it wrong.

@tpwrules tpwrules requested a review from peterbarker April 11, 2026 20:26

@tpwrules tpwrules left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, let's see how it does.

@cclauss

cclauss commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

The default color of a new GitHub label is a drab black-and-white. See:

Label colors can be set at:
https://github.com/ArduPilot/ardupilot/labels
https://github.com/ArduPilot/ardupilot_wiki/labels
Find (or add) the Python label and click the ... at the far right.

The Python logo color, Philadelphia (#306998), worked for me.

@peterbarker peterbarker merged commit cc1224b into ArduPilot:master Apr 12, 2026
116 of 119 checks passed
@peterbarker

Copy link
Copy Markdown
Contributor

Let's see how it goes.

@cclauss cclauss deleted the patch-7 branch April 12, 2026 04:14
@cclauss

cclauss commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants