18 Commits

Author SHA1 Message Date
Aiden Grossman
b3af755254
[Github] Set start rev to merge base in code format action (#75132)
This patch sets the start revision to the merge base so that the c++
formatting action won't produce any diffs related to changes in main but
not in the PR branch. This also leaves a TODO to migrate over to the
--diff_from_common_commit option in git-clang-format once LLVM v18 is
released.
2023-12-11 21:46:51 -08:00
Chris Bieneman
488d900209 [NFC] Map changed file through envar
This sanitizes the string for printing.
2023-11-27 16:41:25 -06:00
Aiden Grossman
688664fd19 [Github] Make code formatting action checkout SHA rather than ref
Checking out a ref of the branch requires the remote to be the same as
the fork whereas setting it to be the commit SHA allows for us to avoid
changing the remote. This should fix the action not working on PRs made
from forks (essentially all of them).
2023-11-11 20:33:03 -08:00
Aiden Grossman
1a66465c72
[Github] Fetch through merge base in code formatting action (#72020)
This commit adds another step to the Github workflow that runs the code
formatting check to fetch through the merge base. This ensures that the
necessary history is present to find the changed files and also to run
clang-format over. This change massively increases the speed of the
action (~10 minutes down to ~2 minutes in most cases from my testing)
and also increases the reliability significantly.
2023-11-11 19:48:03 -08:00
Aiden Grossman
83888a5404
[Github] Only run github actions on main monorepo (#69774)
There are currently a couple jobs that run on all forks of LLVM too (if
there is a PR opened, or in the case of the documentation builds, upon
pushing to main). This isn't desired behavior. This commit disables that
behavior, forcing the jobs to not run if they aren't running against
llvm/llvm-project or a PR against that repo.
2023-11-04 00:17:06 -07:00
Chris B
f2c24cceed
Increase git fetch depth (#70946)
We've gotten ~750 commits in the last 7 days. Upping the fetch depth to
2000 will make it more likely that PRs up to 2 weeks old will have
enough fetch history to find a common parent. This _might_ address some
of the failures we're seeing in the clang-format action where it cannot
find a common base commit.
2023-11-01 13:24:28 -05:00
Aiden Grossman
96410a6b14 Revert "[Github] Fetch all commits in PR for code formatting checks (#69766)"
This reverts commit 4aa12afb967bd7c5f051f3b72271f787f1a7538b.

This change introduced failures upon checking out the PR source code.
Pulling this out of tree while I investigate further.
2023-10-30 12:33:35 -07:00
Aiden Grossman
4aa12afb96
[Github] Fetch all commits in PR for code formatting checks (#69766)
This patch makes a couple changes to the PR code formatting check:
- Moves the `changed-files` action to before the checkout to make sure
that it pulls
information from the Github API rather than by running `git diff` to
alleviate some
performance problems.
- Checkout the head of the pull request head instead of the base of the
pull request
to ensure that we have the PR commits inside the checkout.
- Add an additional sparse checkout of the necessary LLVM tools to run
the action
to alleviate security problems introduced by checking out the head of
the pull
request. Only code from the base of the pull request runs.
- Adjust the commit references to be based on `HEAD` as Github doesn't
give
exact commit SHAs for the first commit in the PR.
2023-10-30 12:23:51 -07:00
Aiden Grossman
cd205efb9d Revert "[Github] Make PR formatting job only run with C/C++ changes (#69556)"
This reverts commit 80b2aac2c671771d74bc5d7426f7bd4ffa0b8a8e.

I mistakenly assumed this job didn't also do python formatting
(should've grepped for more than just black in the python portion of
this script). Pulling it out for now to get python formatting working
again while the patch is iterated further.
2023-10-18 23:28:20 -07:00
Aiden Grossman
80b2aac2c6
[Github] Make PR formatting job only run with C/C++ changes (#69556)
Currently the PR formatting job only runs clang-format. There isn't a
lot of utility in running it if there aren't any C/C++ changes as there
will be nothing to format. This isn't super noisy currently as the job
doesn't fail if there aren't any C/C++ changes, but it's a bit of a
waste.

In addition, this patch names the code formatting job "Check C++
Formatting" to make it clear that this job only checks C/C++ formatting
rather than Python formatting/other languages.
2023-10-18 22:53:17 -07:00
Tobias Hieta
db777db25c
[Workflow] Update clang-format to 17.0.1 (#67402)
17.0.1 is our most recent stable version which we decided to follow and
it fixes the issue described in llvm/llvm-project#67343
2023-09-28 08:37:30 +02:00
Tobias Hieta
a6e81df289
[Workflow] Roll back some settings since they caused more issues
This needs more investigation.
2023-09-23 17:53:51 +02:00
Tobias Hieta
cefc31c921
[Workflow] Use a higher max depth
This can fix not being able to fetch the right amounts of history for the code-format flow.
2023-09-23 15:44:16 +02:00
Tobias Hieta
e33703fce9
[Workflow] Try to fix code-formatter failing to find changes in some cases.
See comment here: https://github.com/tj-actions/changed-files#usage-
2023-09-23 15:30:21 +02:00
Tobias Hieta
bd0281669e
[workflow] Tweak code formatting workflow to be faster
This should limit how many commits we need to fetch and should be faster.
2023-09-22 17:18:23 +02:00
Tobias Hieta
a1177b0bdb
Reland: [Workflow] Add new code format helper.
I landed this format helper, but unfortunately, it didn't work because
of permissions, it could not add comments on a fork's PR. @cor3ntin
informed me there are fixes for this that you had worked on @tstellar -
but I didn't have time to read up on it too much. Can you explain what
changes are needed to get the action to be able to write comments on
fork's PR?
2023-09-22 10:26:09 +02:00
Tobias Hieta
fe5c185641
Revert "[Workflow] Add new code format helper. (#66684)"
This reverts commit da94bf0d561109529e4ab3dabfcbb8b6c258ea39.
2023-09-20 10:01:37 +02:00
Tobias Hieta
da94bf0d56
[Workflow] Add new code format helper. (#66684)
This helper will format python files with black/darker and
C/C++ files with clang-format.

The format helper is written so that we can expand it with new
formatters in the future like clang-tidy.
2023-09-20 08:52:29 +02:00