100 Commits

Author SHA1 Message Date
Aaron Siddhartha Mondal
55ae118db7
[GitHub] Skip undefcheck if no relevant files changed (#126749)
If the list of filtered files was empty the check would process every
file in the diff.
2025-02-11 18:43:27 +01:00
David Spickett
19fc8e3846 [GitHub] Correct word in commit access request greeting 2025-02-11 10:28:31 +00:00
Tom Stellard
cd26c112b2
[llvm][GitHub] Move PR project status to Done once backport PR is made (#126374)
It's common to use the /cherry-pick command on a PR to create a backport
request. However, this creates a lot of clutter in the LLVM Release
Status project, because we end up with two items in the project, one for
the original PR and one for the new PR.

This change will set the status of the original PR to Done once the new
PR (for the release branch) is created. This will save release managers
a lot of work of having to manually updated the status for PRs that
contain backport requests.
2025-02-10 13:06:51 -08:00
Tom Stellard
f8ef2699d8
workflows: Add some automation for commit access requests (#123113)
* Greet the user and ask them to read the developer policy.
* Post their contribution stats on the issue.
2025-01-30 20:05:05 -08:00
Aiden Grossman
c84f5a9e00
[Github] Skip MIR files for undef check (#120919)
This patch skips checking files with a .mir extension for the presence
of undef. This was creating false positives that got reported on
discourse.
2024-12-24 01:09:34 -08:00
Nuno Lopes
0c629206b0 undef reviewer: tweak the regex so it doesn't warn about #undef 2024-12-20 19:48:23 +00:00
Nuno Lopes
19bc282320
Add PR check to suggest alternatives to using undef (#118506)
As discussed in
https://discourse.llvm.org/t/please-dont-use-undef-in-tests-part-2/83388,
this patch adds a comment to PRs that introduce new uses of undef.

It uses the the `git diff -S' command to find new uses, avoiding warning
about old uses. It further trims down with a regex to get only added (+)
lines.
2024-12-11 21:09:05 +00:00
Tom Stellard
0d5ae3632d
workflows/commit-access-review: Use Python APIs for graphql queries (#108903) 2024-12-06 18:34:03 -08:00
Mehdi Amini
c4aa83840b
Improve slightly the pre-commit git hook usage of the auto-format helper (#117326)
The default mode does not provide a way to see the actual failure of the
formatters without modifying the code. Instead offer the user the option
to rerun with a `FORMAT_HOOK_VERBOSE=1` environment variable to print
the actual formatting diff.
2024-11-22 16:58:12 +01:00
Tom Stellard
f14fd32602
workflows/commit-access-review: Use get_collaborators() function (#108313)
This gets us the full list of users with commit access to
llvm/llvm-project rather than the list of people in the llvm-committers
team. This will ensure we are able everyone to track everyone with
commit access in case they receive access some other way.
2024-09-16 13:37:49 -07:00
Nicolas van Kempen
c49770c60f
[NFC] Prefer subprocess.DEVNULL over os.devnull (#106500)
There is no need to support Python 2.7 anymore, Python 3.3+ has
`subprocess.DEVNULL`. This is good practice and also prevents file
handles from
staying open unnecessarily.

Also remove a couple unused or unneeded `__future__` imports.
2024-08-30 19:26:49 +01:00
Stephan T. Lavavej
7036394048
Update Python requirements to fix more CVEs (#105853)
Followup to #90109.

In Microsoft, our automated scans are warning that LLVM has vulnerable
dependencies. Specifically:

* [CVE-2024-35195](https://nvd.nist.gov/vuln/detail/CVE-2024-35195) was
fixed in `requests` 2.32.0.
* [CVE-2024-37891](https://nvd.nist.gov/vuln/detail/CVE-2024-37891) was
fixed in `urllib3` 2.2.2.

I've updated LLVM's dependencies by running the following commands in
`llvm/utils/git`:

```
pip-compile --upgrade --generate-hashes --output-file=requirements.txt requirements.txt.in
pip-compile --upgrade --generate-hashes --output-file=requirements_formatting.txt requirements_formatting.txt.in
```

Note that for `requirements_formatting.txt` this adds
`--generate-hashes` (according to my vague understanding, it's highly
desirable and was already used for `requirements.txt`) and was locally
run within `llvm/utils/git` (changing the recorded command, which
apparently was originally run from the repo root - again,
`requirements.txt` was already being regenerated with a locally run
command, so this increases consistency).

I observe that this has updated the relevant components to pick up the
CVE fixes. Note that I am largely clueless in this area, so I hope that
(like #90109) no other changes will be necessary.
2024-08-24 09:51:08 -07:00
David Spickett
5adbce072c [llvm][GitHub] Fix formatting of new contributor comments
GitHub won't reflow the text unless we put it all on one line.

If we try to make our own paragrpahs it comes out too narrow or
too wide.
2024-08-20 09:26:09 +00:00
pcc
564efe2674
utils/git: Add linkify script.
This script linkifies (i.e. makes clickable in the terminal) text that appears
to be a pull request or issue reference (e.g. #12345 or PR12345) or a
40-character commit hash (e.g. abc123). You can configure git to automatically
send the output of commands that pipe their output through a pager, such as
`git log` and `git show`, through this script by running this command from
within your LLVM checkout:

git config core.pager 'llvm/utils/git/linkify | pager'

The pager command is run from the root of the repository even if the git
command is run from a subdirectory, so the relative path should always work.

It requires OSC 8 support in the terminal. For a list of compatible terminals,
see https://github.com/Alhadis/OSC8-Adoption

Reviewers: MaskRay

Reviewed By: MaskRay

Pull Request: https://github.com/llvm/llvm-project/pull/103496
2024-08-14 17:25:28 -07:00
Louis Dionne
b3c450d4dc
[CI][format] Explicitly pass extensions to git-clang-format (take 2) (#98227)
This patch ensures that the CI script controls which file extensions are
considered instead of letting git-clang-format apply its own filtering
rules. In particular, this properly handles libc++ extension-less
headers which were passed to git-clang-format, but then dropped by 
the tool as having an unrecognized extension.

This is a second attempt to land 7620fe0d2d1e, which was reverted in
9572388 because it caused formatting not to be enforced for several patches.
The problem was that we'd incorrectly pass the extensions with additional
quoting to git-clang-format. The incorrect quoting has been removed in this
version of the patch.
2024-07-10 14:07:24 -04:00
Aiden Grossman
9572388a84 Revert "[CI][format] Explicitly pass extensions to git-clang-format (#95794)"
This reverts commit 7620fe0d2d1e0257611c0ab0d96f3bf1bf7a1079.

This patch was causing some significant portion of code formatting jobs
to succeed when they should have failed. More investigation is needed.

Tracked in #97060.
2024-06-28 22:52:29 +00:00
Tom Stellard
2879a03647
[workflows] Fix release note request workflow (#94784)
We need to use the issue-write workflow to write the comments, because
pull_request targets don't have permissions to write comments.
2024-06-27 15:54:22 -07:00
Louis Dionne
7620fe0d2d
[CI][format] Explicitly pass extensions to git-clang-format (#95794)
This ensures that the CI script controls which file extensions are
considered instead of letting git-clang-format apply its own filtering
rules. In particular, this properly handles libc++ extension-less
headers which were passed to git-clang-format, but then dropped by that
tool as having an unrecognized extension.
2024-06-17 16:20:58 -04:00
Tom Stellard
89b83d2d3f
[git] Add hashes to requirements.txt for extra security (#92305)
https://pip.pypa.io/en/stable/topics/secure-installs/
2024-05-17 06:49:27 -07:00
Tom Stellard
c99d1156c2
[workflows] Add a job for requesting a release note on release branch PRs (#91826)
We have been collecting release notes from the PRs for most of the
18.1.x releases and this just helps automate the process.
2024-05-13 16:31:21 -07:00
Joyce
00e3620a0e
Generate a new requirements.txt to fix CVEs (#90109)
Hi! Here is a patch for #81859 that fix the vulnerabilities found in
gitpython, cryptography, urllib3 and requests.

I have just regenerated the requirements.txt files running pip-compile
again. Fortunately, this was enough to set all the dependencies on safe
versions.

I have also checked if new vulnerabilities were introduced by running
scorecard on my fork, but none has been introduced.

Thanks!

Signed-off-by: Joyce Brum <joycebrum@google.com>
2024-05-10 12:05:54 -07:00
J. Ryan Stinnett
8a7f021f9e
[GitHub] Fix typos in automation (#86886) 2024-03-28 10:37:31 +00:00
Tom Stellard
de917dc20e
[workflow] Don't add a comment when the first run of the formatter passes (#86335)
This was inadvertently changed in
2120f574103c487787390263b3692c4b167f6bdf.
2024-03-25 15:04:11 -07:00
Tom Stellard
2120f57410
Reapply [workflows] Split pr-code-format into two parts to make it more secure (#78215) (#80495)
Actions triggered by pull_request_target events have access to all
repository secrets, so it is unsafe to use them when executing untrusted
code. The pr-code-format workflow does not execute any untrusted code,
but it passes untrused input into clang-format. An attacker could use
this to exploit a flaw in clang-format and potentially gain access to
the repository secrets.
    
By splitting the workflow, we can use the pull_request target which is
more secure and isolate the issue write permissions in a separate job.
The pull_request target also makes it easier to test changes to the
code-format-helepr.py script, because the version of the script from the
pull request will be used rather than the version of the script from
main.
    
Fixes #77142
2024-03-22 11:45:51 -07:00
Danny Mösch
cd8286a667
[GitHub] Allow shortcut for "introductory issue" and request linking to issue in PR (#84635)
The answer to many requests in issues to be assigned to users is often
"just create a pull request". That's in contradiction to the
"introductory issue" instructions posted by the GitHub bot.

This change updates the instructions, mentioning the shortcut of "just
creating a PR". Moreover, it now explains linking PRs to issues in order
to close them automatically upon merge.
2024-03-22 18:51:44 +01:00
Tom Stellard
d125d5576e
github-automation.py: Set maintainer_can_modify=True for backport PRs (#84819)
This makes it possible to rebase the branch using the Web UI, which
makes it easier to manually merge the PRs. Manual merge is required when
squash merge won't preserve author information of the backport.
2024-03-11 16:04:44 -07:00
Shourya Goel
9a894e7d84
[Github Automation] Allow colon after cherry-pick command (#81002)
Fixes: https://github.com/llvm/llvm-project/issues/64803

Removed unsupported branch command and changed Regex to
accept /cherry-pick: command.
2024-03-05 09:28:44 +01:00
Mircea Trofin
a81a7b9962
[Py Reformat] Exclude third-party in code-format-helper.py (#83872)
Follow-up from PR #83491. `Darker`'s configuration is ignored because of the way we invoke it - with an explicit list of files. We need to filter it in `code-format-helper.py`.
2024-03-04 11:22:35 -08:00
Nikita Popov
124cd11d7f Revert "[GitHub][workflows] Ask reviewers to merge PRs when author cannot (#81142)"
This reverts commit 38c706e30f5f339bfb0bfb26fd7b5c2d5086064a.

This workflow always fails in cases where it needs to create a
comment, due to a permissions issue, see the discussion at:
https://discourse.llvm.org/t/rfc-fyi-pull-request-greetings-for-new-contributors/75458/20
2024-02-14 11:33:36 +01:00
David Spickett
38c706e30f
[GitHub][workflows] Ask reviewers to merge PRs when author cannot (#81142)
This uses
https://pygithub.readthedocs.io/en/stable/github_objects/Repository.html?highlight=get_collaborator_permission#github.Repository.Repository.get_collaborator_permission.

Which does
https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#get-repository-permissions-for-a-user
and returns the top level "permission" key.

This is less detailed than the user/permissions key but should be fine
for this
use case.

When a review is submitted we check:
* If it's an approval.
* Whether we have already left a merge on behalf comment (by looking for
a hidden HTML comment).
* Whether the author has permissions to merge their own PR. 
* Whether the reviewer has permissions to merge.

If needed we leave a comment tagging the reviewer. If the reviewer also
doesn't have merge permission, then it asks them to find someone else
who does.
2024-02-13 14:52:02 +00:00
Tom Stellard
bd65547805
[workflows] Create a more descriptive title and body when creating a PR for backports (#80396)
When a backport request is made, the resulting pull request will have a
title like this:

<release branch>: <First line of HEAD commit for the branch>

And a body that says:

Backport <commit0> <commit1> ..

Requested By: <user>
2024-02-09 13:04:49 -08:00
Tom Stellard
9805c051f7
[workflows] Close issues used for backports once the PR has been created (#80394)
This will allow us to track the state of the backport request in the PR,
rather than in the issue. The state updates for PRs can be automated, so
this will save us some triage work.
2024-02-05 10:59:14 -08:00
Tom Stellard
06c14c03da Revert "[workflows] Split pr-code-format into two parts to make it more secure (#78216)"
This reverts commit bc06cd5cbcfc22dd976f6742d10bc934e1353b8a.

This caused the job to fail for PRs which still had an older version
of code-format-helper.py in their tree.
2024-02-02 12:03:38 -08:00
Tom Stellard
bc06cd5cbc
[workflows] Split pr-code-format into two parts to make it more secure (#78216)
Actions triggered by pull_request_target events have access to all
repository secrets, so it is unsafe to use them when executing untrusted
code. The pr-code-format workflow does not execute any untrusted code,
but it passes untrused input into clang-format. An attacker could use
this to exploit a flaw in clang-format and potentially gain access to
the repository secrets.

By splitting the workflow, we can use the pull_request target which is
more secure and isolate the issue write permissions in a separate job.
The pull_request target also makes it easier to test changes to the
code-format-helepr.py script, because the version of the script from the
pull request will be used rather than the version of the script from
main.

Fixes #77142
2024-02-02 11:31:23 -08:00
David Spickett
96a3d05ed9 [GitHub][workflows] Reflow some text in buildbot info PR comment
When the markdown link renders the line gets a lot shorter.
2024-02-01 10:44:25 +00:00
David Spickett
44ba4c732b
[GitHub][workflows] Add buildbot information comment to first merged PR from a new contributor (#78292)
This change adds a comment to the first PR from a new contributor that
is merged, which tells them what to expect post merge from the build
bots.

How they will be notified, where to ask questions, that you're more
likely to be reverted than in other projects, etc. The information
overlaps with, and links to
https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr.
So that users who simply read the email are still aware, and know where
to follow up if they do get reports.

To do this, I have added a hidden HTML comment to the new contributor
greeting comment. This workflow will look for that to tell if the author
of the PR was a new contributor at the time they opened the merge. It
has to be done this way because as soon as the PR is merged, they are by
GitHub's definition no longer a new contributor and I suspect that their
author association will be "contributor" instead.

I cannot 100% confirm that without a whole lot of effort and probably
breaking GitHub's terms of service, but it's fairly cheap to work around
anyway. It seems rare / almost impossible to reopen a PR in llvm at
least, but in case it does happen the buildbot info comment has its own
hidden HTML comment. If we find this we will not post another copy of
the same information.
2024-01-31 10:11:24 +00:00
Tom Stellard
e99edf6bcb
[workflows] Drop the intermediate /branch comment for release workflow (#79481)
We used to support a /branch comment to specify a branch with commits to
backport to the release branch. However, now that we can use pull
requests this is not needed.

This also simplifies the process, because now the cherry-pick job can
create the pull request directly instead of having it split across two
separate jobs.
2024-01-25 13:11:09 -08:00
Nikita Popov
56444d5687
Remove fork handling from release issue workflow (#79310)
This is currently broken, because the check is performed on the wrong
repository. repo here is llvm/llvm-project, which is not a fork (so this
will always trigger), then we'll push a new branch to
llvmbot/llvm-project, and then again set the wrong owner, so we'll look
for the branch in llvm/llvm-project rather than llvmbot/llvm-project.

Rather than fixing this, I'm removing the code entirely, as it shouldn't
be needed anymore (llvmbot/llvm-project is a fork of llvm/llvm-project).
2024-01-24 17:39:10 +01:00
Nikita Popov
416b079336
Fix release issue workflow (#79268)
Remove the `--phab-token` argument (which currently eats the subsequent
"auto" as the token no longer exists) and related code.

I think this will fix the workflow failure in
https://github.com/llvm/llvm-project/issues/79253#issuecomment-1907679229.
2024-01-24 11:23:28 +01:00
Tom Stellard
f33e9276e2
github-automation: Use the llvm/llvm-project repo for backport pull requests (#71727)
Now that the project uses PRs for code review, we don't need to use the
llvm/llvm-project-release-prs repo for reviewing backports.
2024-01-11 17:06:27 -08:00
Aiden Grossman
fc3eed1bce
[Github] Reformat strings for code format action (#75764)
Before this patch, there was a regression in comment formatting due to
some code formatting in bd3e8eb6e325081bf7cfbe93652aa825de3170e5. This
was fixed in 428660cfb986dd0a59cd2a16972c5f7109080522. Github interprets
a tab before a string as starting code formatting. The message that
indicted the code formatting in a PR had been fixed was refactored to a
python multi-line string, but with a tab in front, causing these
messages to be rendered as code blocks in Github, instead of as
intended. This patch builds upon the original fix to reformat the
strings so that they fit within ~80 character lines and are simpler to
modify in the future, hopefully removing traps like the one that caused
the original issue.
2023-12-21 22:49:04 -08:00
David Spickett
428660cfb9 [GitHub] Don't indent comment that revision has passed the formatting check
Due to the way the f string was written, the text ended up with 4 spaces
at the start. 4 space indent in Markdown means plain text, which is not
what we intend here.
2023-12-18 10:54:59 +00:00
Tobias Hieta
a3a8acd9a6
[NFC] Missing argument for the PR issue number in the code format helper 2023-12-11 09:50:04 +01:00
Tobias Hieta
bd3e8eb6e3
code-format: Improve the code-format-helper to be able to run as a git hook (#73957)
As part of #73798 there was some discussion about using the format
helper to run from a git-hook. That was not possible for a number of
reasons, but with these changes it can now be installed as a hook and
then run on the local cache in git instead of a diff between revisions.

This also checks for two environment variables DARKER_FORMAT_PATH and
CLANG_FORMAT_PATH where you can specify the path to the program you want
to use.
2023-12-11 09:35:26 +01:00
Aiden Grossman
2b1c76c7c4
[Github] Use three dot diff for darker in code format action (#74704)
Using a two dot diff allows changes made in main after the merge base to
show up in the formatting diff. Using a three dot diff fixes this and
ensures that only changes made in the source branch (branch from the PR
author) will get passed along to the formatter.

Without this, issues like #73873 occur.
2023-12-07 12:05:04 -08:00
David Spickett
77249546aa
[GitHub] Add greeting comment to opened PRs from new contributors (#72384)
This includes some commonly needed information like how to add
reviewers.

This is implemented as a job before the labeler, so that on a new PR the
comment is added before there are any subscribers and only the author
gets a nofitication.

The labeler job depends on the greeter having run or having been
skipped. So if the PR wasn't just opened, or it's from a regular
contributor, the labeling still happens.

But we can be sure that when a greeting comment is left, it's the very
first thing we do.
2023-12-05 11:28:43 +00:00
Tom Stellard
dc16964f0e
[workflows] Remove sync-release-repo.yml (#73682)
This should not be needed now that the project uses PRs, plus the
OpenSSF Scorecard report flagged this as insecure.
2023-11-29 07:53:51 -08:00
Danny Mösch
6a4489a733
[GitHub] Use proper Markdown syntax and avoid child list items (#73700) 2023-11-29 08:47:57 +01:00
Da-Viper
dc8b055c71
[GitHub] Update bot message to suggest GitHub pull requests (#65914)
Fixes #65890.

---------

Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2023-11-26 16:53:37 +01:00
Timm Baeder
81761bd0f1
Try to fix good-first-issue bot (#71816)
The previous code was just overriding the `comment` variable. Fix this by writing two comments if necessary instead.
2023-11-24 07:57:14 +01:00