Uh oh!
There was an error while loading. Please reload this page.
bpo-40548: Fix "Check for source changes (pull_request)" GH Action job - #21806
Conversation
On Git 2.28, "git diff master..." (3 dots) no longer works when "fetch --depth=1" is used, whereas it works on Git 2.26. Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command computing the list of modified files between the base branch and the PR branch.
vstinner
commented
Aug 10, 2020
vstinner
commented
Aug 10, 2020
The macOS failure is unrelated and can be ignored: https://bugs.python.org/issue40275#msg375122 |
vstinner
commented
Aug 10, 2020
This change can be associated to https://bugs.python.org/issue40548 which introduced the "Check for source changes" job. |
shihai1991
commented
Aug 10, 2020
Oh, you are so quick. I try to fix it a minute ago: shihai1991#30 it) Lol~ |
| # into the PR branch anyway. | ||
| # | ||
| # https://github.com/python/core-workflow/issues/373 | ||
| git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo '::set-output name=run_tests::true' || true |
There was a problem hiding this comment.
I test it in last weekend, it can work. and removing the git fetch origin $GITHUB_BASE_REF --depth=1 can fix it too.
I guess depth=1 is not enough deep to find the merge base.
vstinner
commented
Aug 10, 2020
Correct. But depth=1 is part of https://bugs.python.org/issue40548 design to make the "Check for source changes" job fast. For example, on my latest change, it only took 18 seconds overall! I don't think that "..." (3 dots) to find the last common commit is needed for this job. ".." (2 dots) should be enough. |
shihai1991
left a comment
There was a problem hiding this comment.
Thanks, It's can work for me. so LGTM.
vstinner
commented
Aug 10, 2020
I tested manully: with this change, doc-only PR still skip build jobs. I created #21812 to test this PR. It's a "documentation-only" PR. Build GitHub Action jobs have been skipped as expected, and "Docs / Docs" is running as expected. |
vstinner
commented
Aug 10, 2020
@shihai1991@brettcannon: Thanks for the review! I merged my PR. So far, it works as expected. If something goes wrong, we can change the test again. Python 3.9 is also affected, example: #21809 Check for source changes: "fatal: ... no merge base". I backport the change to 3.8 and 3.9. |
miss-islington
commented
Aug 10, 2020
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
miss-islington
commented
Aug 10, 2020
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
bedevere-bot
commented
Aug 10, 2020
GH-21813 is a backport of this pull request to the 3.8 branch. |
pythonGH-21806) On Git 2.28, "git diff master..." (3 dots) no longer works when "fetch --depth=1" is used, whereas it works on Git 2.26. Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command computing the list of modified files between the base branch and the PR branch. (cherry picked from commit eaa5517) Co-authored-by: Victor Stinner <vstinner@python.org>
bedevere-bot
commented
Aug 10, 2020
GH-21814 is a backport of this pull request to the 3.9 branch. |
pythonGH-21806) On Git 2.28, "git diff master..." (3 dots) no longer works when "fetch --depth=1" is used, whereas it works on Git 2.26. Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command computing the list of modified files between the base branch and the PR branch. (cherry picked from commit eaa5517) Co-authored-by: Victor Stinner <vstinner@python.org>
GH-21806) On Git 2.28, "git diff master..." (3 dots) no longer works when "fetch --depth=1" is used, whereas it works on Git 2.26. Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command computing the list of modified files between the base branch and the PR branch. (cherry picked from commit eaa5517) Co-authored-by: Victor Stinner <vstinner@python.org>
GH-21806) On Git 2.28, "git diff master..." (3 dots) no longer works when "fetch --depth=1" is used, whereas it works on Git 2.26. Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command computing the list of modified files between the base branch and the PR branch. (cherry picked from commit eaa5517) Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner sorry for the delay, I did not have access to my computer over the weekend. I implemented this in another project and was running into an issue, this was my solution: - name: Check for source changesid: checkenv:
PREVIOUS: ${{ github.event.before }}CURRENT: ${{ github.sha }}run: | git fetch origin $PREVIOUS git diff --name-only $PREVIOUS $CURRENT | grep -q ... || trueTurns out github actions makes the previous object SHA available for us to use. We can use this to explicitly fetch it and to run the diff. It should be more reliable than the current approach. What do you think? |
vstinner
commented
Aug 10, 2020
I tried From what I understood, in practice, |
No,
It is documented in the webhooks documentation, see https://docs.github.com/en/actions/reference/events-that-trigger-workflows for context.
Github is doing a bad job with the documentation here, it took a lot of digging to uncover this. But it does work and is documented. |
pythonGH-21806) On Git 2.28, "git diff master..." (3 dots) no longer works when "fetch --depth=1" is used, whereas it works on Git 2.26. Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command computing the list of modified files between the base branch and the PR branch.
pythonGH-21806) On Git 2.28, "git diff master..." (3 dots) no longer works when "fetch --depth=1" is used, whereas it works on Git 2.26. Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command computing the list of modified files between the base branch and the PR branch.
miss-islington
commented
May 5, 2022
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
pythonGH-21806) On Git 2.28, "git diff master..." (3 dots) no longer works when "fetch --depth=1" is used, whereas it works on Git 2.26. Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command computing the list of modified files between the base branch and the PR branch. (cherry picked from commit eaa5517) Co-authored-by: Victor Stinner <vstinner@python.org>
bedevere-bot
commented
May 5, 2022
GH-92342 is a backport of this pull request to the 3.7 branch. |
GH-21806) (GH-92342) On Git 2.28, "git diff master..." (3 dots) no longer works when "fetch --depth=1" is used, whereas it works on Git 2.26. Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command computing the list of modified files between the base branch and the PR branch. (cherry picked from commit eaa5517) Co-authored-by: Victor Stinner <vstinner@python.org>
On Git 2.28, "git diff master..." (3 dots) no longer works when
"fetch --depth=1" is used, whereas it works on Git 2.26.
Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command
computing the list of modified files between the base branch and the
PR branch.
https://bugs.python.org/issue40548