-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[GitHub][CI] Run clang-format natively in ci-ubuntu container #161073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-github-workflow Author: Baranov Victor (vbvictor) ChangesTested in #160193 (run logs). If we calculate total time, this patch code-format job will take ~1m50sec vs ~2min for code-format job in But also this patch gives us a lot of opportunities for improvements, e.g.:
Full diff: https://github.com/llvm/llvm-project/pull/161073.diff 1 Files Affected:
diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index 61c8680cd72a1..841b601ed3f4f 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -12,6 +12,8 @@ on:
jobs:
code_formatter:
runs-on: ubuntu-24.04
+ container:
+ image: 'ghcr.io/llvm/ci-ubuntu-24.04:latest'
timeout-minutes: 30
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
@@ -38,24 +40,13 @@ jobs:
run: |
echo "Formatting files:"
echo "$CHANGED_FILES"
-
- # The clang format version should always be upgraded to the first version
- # of a release cycle (x.1.0) or the last version of a release cycle, or
- # if there have been relevant clang-format backports.
- - name: Install clang-format
- uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
- with:
- clangformat: 21.1.0
-
- - name: Setup Python env
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
- with:
- python-version: '3.11'
- cache: 'pip'
- cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt'
+
+ - name: Create python venv
+ run: |
+ python -m venv venv
- name: Install python dependencies
- run: pip install -r llvm/utils/git/requirements_formatting.txt
+ run: venv/bin/pip install -r llvm/utils/git/requirements_formatting.txt
- name: Run code formatter
env:
@@ -64,7 +55,7 @@ jobs:
# Create an empty comments file so the pr-write job doesn't fail.
run: |
echo "[]" > comments &&
- python ./llvm/utils/git/code-format-helper.py \
+ venv/bin/python ./llvm/utils/git/code-format-helper.py \
--write-comment-to-file \
--token ${{ secrets.GITHUB_TOKEN }} \
--issue-number $GITHUB_PR_NUMBER \
|
This comment was marked as resolved.
This comment was marked as resolved.
2470dc1
to
9157ce6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably shouldn't be dropping setup-python
. Removing the pip dependency cache (even if it doesn't hit unless it has been warmed on a PR) is probably going to be a significant regression.
I've checked ~10 different workflow runs (runs.txt) and on average it currently takes ~7sec to complete "Setup Python env + Install python dependencies" steps. In my test run, it took 6sec to "Create venv + install dependencies" so it could be even a speedup (or a very small regression) Apart from it, I observed that To sum up for this PR, I think we either can merge without caching and see if we made a net-positive in insights (we can always revert if average job time increased), or wait until a custom-container is made in #161083 so we wouldn't need any cache anymore. |
Ack. Even if it took a bit of time, I think this should be a net positive.
Yeah, especially in a minimal environment. It needs dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine for a temporary solution.
The only worry I have about this is that this patch ties the CI versions together, which we ideally don't want to do to avoid churn with the clang format version bumps. That should be temporary though assuming there is a concerted effort to get a clang-format specific container up and working.
I'm fine postponing this PR for a reasonable amount of time until a separate container is created. Also will have more time to gather opinions. |
Tested in #160193 (run logs).
With this patch, we skip "Install clang-format" step which usually takes 30sec (but can be up to 120sec) but add new step "Initialize containers" which adds 17sec.
If we calculate total time, this patch code-format job will take ~1m50sec vs ~2min for code-format job in
main
.But also this patch gives us a lot of opportunities for improvements, e.g.:
docker build
, which would give ~6sec speed up.