-
Notifications
You must be signed in to change notification settings - Fork 8k
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
ci(markdownlint): use GitHub API to get changed files #10390
Conversation
Co-authored-by: Onkar Ruikar <[email protected]>
This will be efficient cos unlike the third party action this uses GitHub APIs instead of git(requires to fetch a lot of history). @yin1999 can we use the List pull requests files API instead of the diff API? It will make the logic simple and reduce a few lines of code.
For testing you'll have to do the same change in yin1999#8 . After that wait till there are some commits to the main branch then manually rerun the worflows(without rebasing). Nitpick, we can work without using
|
Hi @OnkarRuikar. I've tried this before. But there is a limitation of 100 files per_page. So for some large PR. We may failed to fetch all the changed files (use And if we use
Thanks for the suggestion, I'll apply this. |
Co-authored-by: Onkar Ruikar <[email protected]>
also /cc @SphinxKnight for any suggestions :) |
Cool, if you've found a better solution, it might be worth upstreaming to that tj action, or create it as an action in mdn/workflows later for easier maintenance |
Thanks for suggestions, tj action metioned |
The Compare two commits API also has the same limitations. The
It works in my environment: gh api /repos/mdn/translated-content/pulls/9513/files --paginate \
--jq '.[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) |.filename' | wc -l
93 I tried it multiple times and it gave me 93 count every time which is correct: 93(added) + 90(deleted) = 183. Note, we are excluding deleted files in the query.
Head always points to the latest commit and the base remains the same every time. So with the current compare API code we always get files modified from first commit to the latest commit. So how is it different from the list PR files api?
There is already another third party action available that uses the same strategy (of using the Github compare commits API): https://github.com/jitterbit/get-changed-files/blob/d06c756e3609dd3dd5d302dde8d1339af3f790f2/src/main.ts#L62-L67 Third party workflows provide a lot of features that we don't use. I am in favor of having our own small, simple, customized solution to avoid any dependency. |
I'm not really sure, I tried it some time ago.
But we can make sure that it's ok for the final workflow run. @OnkarRuikar, we can try to move this part as the first step, to avoid some of the special cases. And yes, I prefer List pull requests files API, for we only need file changes info, if we would not be affected by those special cases. |
We need to merge this solution quickly and do this in
Ping @caugner |
Thanks @caugner, @OnkarRuikar and @nschonni. Let's see would it works fine. So we can go ahead for mdn/content and another workflow :) |
@yin1999 to test this quickly, rerun workflows on an old PR without rebasing it. |
Yes, we have some workflow runs here: https://github.com/mdn/translated-content/actions/workflows/pr-check_markdownlint.yml (with a merge commit in this PR: #10508) |
edit: seems ok for this workflow run: https://github.com/mdn/translated-content/actions/runs/3630538397/jobs/6125489914 |
There is a huge performance improvement. |
Description
fix(ci): use GitHub API to get changed files
Motivation
The tj-actions/changed-files@v34 action in Markdownlint (PR files) may failed to get changed files. And as a test for #8952.
I've made a test before to get changed via GitHub API. It works, but I'm not sure whether it's always ok. I just find out a limitation in
gh
cli as here before, so I've tried another way to get changed files (by commit compare REST API).And for the API I used for now, it could list 30 commits per REST API request, so the files limitation maybe resolved, see below:
Is there any other things I've ignored? @nschonni @OnkarRuikar
Related issues and pull requests
more information can be found in those PR: