-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Github] Fetch number of commits in PR for docs action #69763
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
[Github] Fetch number of commits in PR for docs action #69763
Conversation
This patch forces the files changed step in the test documentation Github action to use the Github API to look for changed files rather than using the local git history. Using the local git history takes a significant amount of time(~30m with no depth limit, ~10m with a depth limit of 100) while using the GH API is virtually instantaneous. This uses an extra GH API request, but given the frequency that this action runs with, that shouldn't be an issue.
@llvm/pr-subscribers-github-workflow Author: Aiden Grossman (boomanaiden154) ChangesThis patch forces the files changed step in the test documentation Github action to use the Github API to look for changed files rather than using the local git history. Using the local git history takes a significant amount of time(~30m with no depth limit, ~10m with a depth limit of 100) while using the GH API is virtually instantaneous. This uses an extra GH API request, but given the frequency that this action runs with, that shouldn't be an issue. Full diff: https://github.com/llvm/llvm-project/pull/69763.diff 1 Files Affected:
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index d58c7d51e0e44ab..0603dfa3df19b21 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -25,6 +25,15 @@ jobs:
name: "Test documentation build"
runs-on: ubuntu-latest
steps:
+ - name: Get subprojects that have doc changes
+ id: docs-changed-subprojects
+ uses: tj-actions/changed-files@v39
+ with:
+ files_yaml: |
+ llvm:
+ - 'llvm/docs/**'
+ clang:
+ - 'clang/docs/**'
- name: Fetch LLVM sources
uses: actions/checkout@v4
with:
@@ -41,15 +50,6 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build
- - name: Get subprojects that have doc changes
- id: docs-changed-subprojects
- uses: tj-actions/changed-files@v39
- with:
- files_yaml: |
- llvm:
- - 'llvm/docs/**'
- clang:
- - 'clang/docs/**'
- name: Build LLVM docs
if: steps.docs-changed-subprojects.outputs.llvm_any_changed == 'true'
run: |
|
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.
Moving it before the checkout is what causes it to use the API? You might want to add a comment explaining this.
Yes. If there isn't a checkout, it uses the Github API. A comment is a good point. I'll add one in. I'm planning on doing this for the code formatting action too but wanted to do it in a separate PR as I don't understand all the details of that action and want Tobias to make sure my changes won't disturb anything and I assume he's out for the weekend at this point. |
One thing that changed files also solved for us here is that it made sure that the git history was there for git-clang-format. I want you to test this when there is a big commit list between the PR head and the base commit. I would expect this to fail since git-clang-format won't be able to compute the diff. |
(I am mainly out for the weekend yeah) |
I'll make sure to do some experimentation with the code formatting action. It seems like it tries to only fetch the commits between main and the tip of the PR, but it doesn't make sense why that takes 10 minutes on average. I'll play around with it and see what I can get working. It doesn't matter for the documentation since we only need the state after the top commit to test the build. Enjoy your weekend! |
Looks like this needs some work as this only works on PRs and not against |
Updated. Apparently just setting |
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.
LGTM. If the speed is still an issue, the other solution would be to have separate workflow files for the clang and llvm docs.
Thanks for the review! I don't think the speed was a huge issue, but it's definitely better to not waste tens of minutes doing essentially nothing. After this I think the speed on PRs should be more than fine (sub ten minutes). If we still need more speed, I'll work on splitting jobs/throwing all the dependencies into a container image. |
This patches changes the docs action to run a fetch with a depth of the number of commits in the PR (1 if we're just running against a push event) which significantly increases the speed of the changed files event. The changed files event goes from taking ~30m to ~3s without any noticeable increase in fetch time.