GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-40548: Fix "Check for source changes (pull_request)" GH Action job by vstinner · Pull Request #21806 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Aug 10, 2020 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
Fix "Check for source changes (pull_request)" GH Action job
9a4c8ba
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 vstinner added skip issue skip news labels Aug 10, 2020
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Aug 10, 2020
@bedevere-bot bedevere-bot added the awaiting core review label Aug 10, 2020
@vstinner vstinner mentioned this pull request Aug 10, 2020
GitHub Actions issues not triggering python/core-workflow#373
Closed
@vstinner

vstinner commented Aug 10, 2020

Copy link
Copy Markdown
Member Author

cc @brettcannon @Mariatta @FFY00 @zooba @pablogsal

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Complete the comment
e21df38
@vstinner vstinner mentioned this pull request Aug 10, 2020
Debug https://github.com/python/core-workflow/issues/373 #21805
Closed
@vstinner

vstinner commented Aug 10, 2020

Copy link
Copy Markdown
Member Author

The macOS failure is unrelated and can be ignored: https://bugs.python.org/issue40275#msg375122

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner changed the title Fix "Check for source changes (pull_request)" GH Action job bpo-40548: Fix "Check for source changes (pull_request)" GH Action job Aug 10, 2020
@vstinner vstinner removed the skip issue label Aug 10, 2020
@vstinner

vstinner commented Aug 10, 2020

Copy link
Copy Markdown
Member Author

This change can be associated to https://bugs.python.org/issue40548 which introduced the "Check for source changes" job.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Aug 10, 2020
bpo-40275: Fix failed test cases by using test helpers #21811
Merged
@shihai1991

shihai1991 commented Aug 10, 2020

Copy link
Copy Markdown
Member

Oh, you are so quick. I try to fix it a minute ago: shihai1991#30 it) Lol~

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

shihai1991
shihai1991 reviewed Aug 10, 2020
View reviewed changes
Comment thread .github/workflows/build.yml
# 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

@shihai1991 shihai1991 Aug 10, 2020

Copy link
Copy Markdown
Member

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 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner

vstinner commented Aug 10, 2020

Copy link
Copy Markdown
Member Author

I guess depth=1 is not enough deep to find the merge base.

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 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Aug 10, 2020
bpo-1635741: port winapi to multi-stage init #21371
Merged
shihai1991
shihai1991 approved these changes Aug 10, 2020
View reviewed changes

@shihai1991 shihai1991 left a comment

Copy link
Copy Markdown
Member

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.

Thanks, It's can work for me. so LGTM.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
brettcannon
brettcannon approved these changes Aug 10, 2020
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Aug 10, 2020
@vstinner
vstinner merged commit eaa5517 into python:master Aug 10, 2020
@bedevere-bot bedevere-bot removed the awaiting merge label Aug 10, 2020
@vstinner
vstinner deleted the fix_workflow_diff branch August 10, 2020 16:37
@vstinner vstinner mentioned this pull request Aug 10, 2020
bpo-40548: [WIP] Documentation only PR #21812
Closed
@vstinner

vstinner commented Aug 10, 2020

Copy link
Copy Markdown
Member Author

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.

shihai1991 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Aug 10, 2020
Travis CI doesn't report its status or doesn't run on Python pull requests python/core-workflow#371
Closed
@vstinner

vstinner commented Aug 10, 2020

Copy link
Copy Markdown
Member Author

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner added the needs backport to 3.8 label Aug 10, 2020
@vstinner vstinner added the needs backport to 3.9 label Aug 10, 2020
@miss-islington

miss-islington commented Aug 10, 2020

Copy link
Copy Markdown
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Aug 10, 2020

Copy link
Copy Markdown
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Aug 10, 2020

Copy link
Copy Markdown

GH-21813 is a backport of this pull request to the 3.8 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.8 label Aug 10, 2020
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 10, 2020
@vstinner @miss-islington
bpo-40548: Fix "Check for source changes (pull_request)" GH Action job (
e18b241
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 <[email protected]>
@bedevere-bot

bedevere-bot commented Aug 10, 2020

Copy link
Copy Markdown

GH-21814 is a backport of this pull request to the 3.9 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 label Aug 10, 2020
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 10, 2020
@vstinner @miss-islington
bpo-40548: Fix "Check for source changes (pull_request)" GH Action job (
ee62802
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 <[email protected]>
miss-islington added a commit that referenced this pull request Aug 10, 2020
@miss-islington @vstinner
bpo-40548: Fix "Check for source changes (pull_request)" GH Action job (
09d8260
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 <[email protected]>
miss-islington added a commit that referenced this pull request Aug 10, 2020
@miss-islington @vstinner
bpo-40548: Fix "Check for source changes (pull_request)" GH Action job (
2cd58d8
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 <[email protected]>
@FFY00

FFY00 commented Aug 10, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@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:

https://github.com/FFY00/arch-python-repo/blob/9cf94335c441638a5a7fbed5b58e4852fbdd5792/.github/workflows/build.yml#L39

      - name: Check for source changes
        id: check
        env:
          PREVIOUS: ${{ github.event.before }}
          CURRENT: ${{ github.sha }}
        run: |
          git fetch origin $PREVIOUS
          git diff --name-only $PREVIOUS $CURRENT | grep -q ... || true

Turns 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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Aug 10, 2020

Copy link
Copy Markdown
Member Author

Turns 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?

I tried git diff origin/$GITHUB_BASE_REF..$GITHUB_SHA: it avoids the "git checkout", but the checkout is part of actions/checkout@v2, we cannot avoid it. With the checkout, origin/$GITHUB_BASE_REF..$GITHUB_SHA is the same than origin/$GITHUB_BASE_REF..HEAD which is the same than origin/$GITHUB_BASE_REF...

From what I understood, in practice, git diff $PREVIOUS $CURRENT is the same than git diff origin/$GITHUB_BASE_REF...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@FFY00

FFY00 commented Aug 10, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

No, GITHUB_BASE_REF (also github.base_ref) is different from github.event.before.

github.base_ref:

The base_ref or target branch of the pull request in a workflow run. This property is only available when the event that triggers a workflow run is a pull_request.

github.event.before is the SHA of the top commit before the event.

It is documented in the webhooks documentation, see https://docs.github.com/en/actions/reference/events-that-trigger-workflows for context.

github.event.before:

The SHA of the most recent commit on ref before the push.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Aug 20, 2020
@vstinner @shihai1991
bpo-40548: Fix "Check for source changes (pull_request)" GH Action job (
450f4ea
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.
xzy3 pushed a commit to xzy3/cpython that referenced this pull request Oct 18, 2020
@vstinner @xzy3-cdc
bpo-40548: Fix "Check for source changes (pull_request)" GH Action job (
f400fbc
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.
@erlend-aasland erlend-aasland mentioned this pull request May 5, 2022
[3.7] gh-80254: Disallow recursive usage of cursors in sqlite3 converters #92334
Merged
@JelleZijlstra JelleZijlstra added the needs backport to 3.7 label May 5, 2022
@miss-islington

miss-islington commented May 5, 2022

Copy link
Copy Markdown
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 5, 2022
@vstinner @miss-islington
bpo-40548: Fix "Check for source changes (pull_request)" GH Action job (
5097cd4
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 <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.7 label May 5, 2022
@bedevere-bot

bedevere-bot commented May 5, 2022

Copy link
Copy Markdown

GH-92342 is a backport of this pull request to the 3.7 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ned-deily pushed a commit that referenced this pull request Sep 2, 2022
@miss-islington @vstinner
bpo-40548: Fix "Check for source changes (pull_request)" GH Action job (
9d58933
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 <[email protected]>
@AA-Turner AA-Turner mentioned this pull request Feb 3, 2025
Convert change detection to a Python script #129627
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@brettcannon brettcannon brettcannon approved these changes
@shihai1991 shihai1991 shihai1991 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@vstinner @shihai1991 @miss-islington @bedevere-bot @FFY00 @brettcannon @JelleZijlstra @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.