44 Commits

Author SHA1 Message Date
Baranov Victor
ef3ce0dcb2
[Github] Remove redundant 'START_REV', 'END_REV' env variables (NFC) (#154218)
After https://github.com/llvm/llvm-project/pull/133023, `START_REV` and
`END_REV` env variables became redundant.
2025-08-19 11:41:37 +03:00
Aiden Grossman
ca44e11e00
[CI][Github] Bump actions/checkout to v5.0.0 (#153340)
https://github.com/actions/checkout/releases/tag/v5.0.0 was released a
couple of days ago (still new, sufficient bake time that there probably
is not a significant security issue). There are few changes, with the
most notable ones being dependency bumps, specifically the node version
bump to v24. This requires actions runner v2.327.1. I will land this
after all of the infrastructure has been moved over to the new runner
version.
2025-08-13 21:17:53 -07:00
Owen Pan
b01ef20c5b
[GitHub][workflows] Use latest clang-format version 20.1.8 (#148099) 2025-07-10 22:26:33 -07:00
Aiden Grossman
46f90165be
[Github] Bump PR Code Format clang-format version (#141819)
As we have discussed in the past, we should be using the latest version.
This has not been updated in a while.
2025-05-28 12:16:01 -07:00
Aiden Grossman
f11d46c151 [Github] Remove invalid comment from pr-code-format.yaml
The comment was originally added in
b3af755254599f474601d0d7b7374dcc36af279a, but
2898c3e0bbf904c68efb194525bcdfeedb3014c2 greatly simplified things
making the previous comment invalid. We no longer need to look at
diffing main versus the PR and whether we are doing a two dot or three
dot diff as we are just diffing the merge commit.
2025-04-27 04:12:54 +00:00
Aiden Grossman
2898c3e0bb
[Github] Simplify Getting Changed Files in Code Formatting Workflow (#133023)
This patch changes getting changed files in the pr code format job to
just checking out the previous two commits (the merge commit and its
porent, the current commit latest in main), which allows us to just diff
the merge commit. This means we do not have to checkout the ref through
the merge base, which should save approximately a minute per job (or
much more in some cases where the PR is particularly out of date).
2025-03-28 21:45:07 -07:00
Aiden Grossman
6616acd80c [Github] Change to step-security fork of changed actions
The tj-actions/changed-files repo has been taken down to the security
incident
(https://www.stepsecurity.io/blog/harden-runner-detection-tj-actions-changed-files-action-is-compromised).

This patch moves these jobs over step-security's fork, which has been
loosely audited and has had the malicious commits removed. This is
mainly intended as a stop-gap to get these actions running again while
we figure out the best path forward.
2025-03-15 20:56:29 +00:00
Aiden Grossman
0ce4b685d2
[Github] Prefer ubuntu-24.04 over ubuntu-latest (#129936)
This patch replaces all instances of ubuntu-latest with ubuntu-24.04
(outside of the entries in libc++) based on the guidelines in the LLVM
CI best practices doc (https://llvm.org/docs/CIBestPractices.html).
2025-03-06 10:32:02 -08:00
Aiden Grossman
705decc860
[Github] Hash Pin Actions in Most Workflows (#129486)
This patch haspins all actions in most of the LLVM Github workflows.
This is something we try to do, but no one has gone through and combed
through all of the workflows before this patch.

Notably, this patch does not bump any major versions of actions just in
case there are subtle breaking changes introduced between versions that
could impact us. Also, this patch omits the libc/libc++ workflows so
that they can be split into separate PRs for the respective subproject
maintainers to review.
2025-03-03 08:37:20 -08:00
Louis Dionne
858f025a00
[ci] Bump the version of clang-format used in the CI (#119915)
The version of clang-format we use in the CI to format all PRs is a bit
outdated, leading to some confusion when the CI job produces different
output from what people have locally.
2025-01-07 16:40:22 -05:00
Aiden Grossman
1293ab35e4
[Github] Cancel previous in-progress code formatting jobs (#106701) 2024-08-30 14:43:15 -07:00
Aiden Grossman
54916e5784
[Github] Set code formatting job timeout to 30 minutes (#106674)
This patch sets the timeout of the code formatting job to 30 minutes.
The job is currently failing in specific circumstances and needs to be
reworked, but as a temp hack, change the timeout to 30 minutes so that
we can catch these jobs before they hit the Github Actions timeout limit
of six hours.

Somewhat (hackily) alleviates #79661 slightly.
2024-08-30 01:08:38 -07:00
Tobias Stadler
9811971860
[GitHub] Run format job on stacked PRs (#102957)
Currently the formatter only runs for the main branch, which prevents
the formatter from running for stacked PRs, which have to target user
branches instead of main.
2024-08-14 14:10:57 +02:00
Owen Pan
5914a5671a
[GitHub][workflows] Use latest clang-format version 18.1.7 (#95757)
Since clang-format 18.1.4, there have been a number of commits that
fixed various kinds of issues:

- Bug
3ceccbdb1995

- Regression
6dbaa89433f7
51ff7f38b633
35fea1032741
7699b341b763
768118d1ad38
8c0fe0d65ed8

- Crash
f1491c7460e7

- Invalid code generation
0abb89a80f5c
2024-06-17 09:49:12 -07:00
Jannick Kremer
e38729968b
[CI] Update setup-python action to v5 for GHA (#95414)
We currently receive a warning on all Github Actions workflows that use
`setup-python`, since they all use v4 of the action, which uses the
deprecated Node.js 16. This PR upgrades the action in all places to v5,
which uses Node.js 20 (see [setup-python release
page](https://github.com/actions/setup-python/releases/tag/v5.0.0))
2024-06-13 10:16:59 -07:00
Marius Brehler
a952c12388
[GitHub] Set top level token permission (#87326) 2024-04-11 22:58:47 +02:00
Aiden Grossman
f6c87be1dd [Github] Fix typo in PR code formatting job
The recent change to split the PR code formatting job accidentally
misspelled the repository field when specifying the repository to fetch
the code formatting utils from. This patch fixes the spelling so that
the job does not throw a warning and clones the tools from the specified
repository.
2024-04-02 00:33:50 -07: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
Owen Pan
6f39c1e284 [GitHub][workflows] Use latest clang-format version 18.1.1 (#85502) 2024-03-16 04:23:15 -07:00
Aiden Grossman
f1ca0b6ce8 Revert "[GitHub][workflows] Use latest clang-format version 18.1.1 (#85502)"
This reverts commit dec63221d56e8092557f29f1f2c127828d7521bb.

This probably needs more discussion before we can land it. The consensus
(from what I can gather) in https://discourse.llvm.org/t/rfc-clang-format-all-the-things/76614
is that we should be careful with version upgrades for consistency.
2024-03-16 02:45:27 -07:00
Owen Pan
dec63221d5
[GitHub][workflows] Use latest clang-format version 18.1.1 (#85502) 2024-03-16 02:17:49 -07:00
Aiden Grossman
4b34558f43 [Github] Fix triggers formatting in code format action
A recent comment modified the job to only run on the main branch, but
the formatting was slightly off, causing the job to not run. This patch
fixes the formatting so the job will run as expected.
2024-02-04 21:33:30 -08:00
Tom Stellard
2193c95e24
[workflows] Only run code formatter on the main branch (#80348)
Modifying a cherry-picked patch to fix code formatting issues can be
risky, so we don't typically do this. Therefore, it's not necessary to
run this job on the release branches.
2024-02-03 21:42:40 -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
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