From fd695d5a91e12b1aa0eb05bf0e616c2f04d07e86 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 19:48:29 +0300 Subject: [PATCH 01/13] gh-109408: Run `patchcheck` in GitHub Actions --- .github/workflows/lint.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 89f65816b6969d..f964bd054bca5a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,3 +24,14 @@ jobs: with: python-version: "3.x" - uses: pre-commit/action@v3.0.0 + + patchcheck: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: "3.11" + - run: python Tools/patchcheck/patchcheck.py --ci true From 7bc19977d36a5a2dc57899153b0a749329c00cf9 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 19:51:02 +0300 Subject: [PATCH 02/13] try to fix ci --- .github/workflows/lint.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f964bd054bca5a..0e83f884994b83 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -34,4 +34,6 @@ jobs: - uses: actions/setup-python@v4 with: python-version: "3.11" - - run: python Tools/patchcheck/patchcheck.py --ci true + - run: | + git fetch origin + python Tools/patchcheck/patchcheck.py --ci true From 86622a888e60685b8622283b2c9447b18825883c Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 19:56:30 +0300 Subject: [PATCH 03/13] try to fix ci --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0e83f884994b83..6216d08ef337f3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,5 +35,5 @@ jobs: with: python-version: "3.11" - run: | - git fetch origin - python Tools/patchcheck/patchcheck.py --ci true + git fetch origin + python Tools/patchcheck/patchcheck.py --ci true From 47da9c339f6c1c2a9be07794eacc702c25b0e047 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 20:09:46 +0300 Subject: [PATCH 04/13] try to fix ci --- .github/workflows/lint.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6216d08ef337f3..83016031814bb2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -26,14 +26,18 @@ jobs: - uses: pre-commit/action@v3.0.0 patchcheck: + if: "github.repository == 'python/cpython' && github.event_name == 'pull_request'" runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.ref_name }} - uses: actions/setup-python@v4 with: python-version: "3.11" - - run: | + - name: "Run patchcheck" + run: | git fetch origin python Tools/patchcheck/patchcheck.py --ci true From 073d8ee2e27bd5f2fbc748f2f93a139a09a8d05d Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 20:13:30 +0300 Subject: [PATCH 05/13] try to fix ci --- .github/workflows/lint.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 83016031814bb2..dfb9c707419e58 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -33,7 +33,8 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.ref_name }} + ref: ${{ github.head_ref }} + fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: "3.11" From 3c0630fc6fb1404f6e995b8b5157e6a28adaee90 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 20:16:48 +0300 Subject: [PATCH 06/13] try to fix ci --- .github/workflows/lint.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dfb9c707419e58..1df9d6e38cdbb2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,13 +32,11 @@ jobs: steps: - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: "3.11" - name: "Run patchcheck" run: | git fetch origin + git checkout "${{ github.head_ref }}" python Tools/patchcheck/patchcheck.py --ci true From dbdc48af9ce1307c2c3a2e2e3f908bc060d8fef2 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 20:25:47 +0300 Subject: [PATCH 07/13] try to fix ci --- .github/workflows/lint.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1df9d6e38cdbb2..9db2dcf8dc0431 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,11 +32,13 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: actions/setup-python@v4 with: python-version: "3.11" - name: "Run patchcheck" run: | - git fetch origin - git checkout "${{ github.head_ref }}" python Tools/patchcheck/patchcheck.py --ci true From c6e2717ed6f95a50a95ca667a4ac55068b66cc26 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 20:29:28 +0300 Subject: [PATCH 08/13] try to fix ci --- .github/workflows/lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9db2dcf8dc0431..3a706a46200026 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -41,4 +41,5 @@ jobs: python-version: "3.11" - name: "Run patchcheck" run: | + git status && git branch python Tools/patchcheck/patchcheck.py --ci true From 375cff963fee6341f0cc793500f2a8e53f8b147b Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 20:34:06 +0300 Subject: [PATCH 09/13] debug --- Tools/patchcheck/patchcheck.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tools/patchcheck/patchcheck.py b/Tools/patchcheck/patchcheck.py index fa3a43af6e6048..f6418253c67cfa 100755 --- a/Tools/patchcheck/patchcheck.py +++ b/Tools/patchcheck/patchcheck.py @@ -99,6 +99,7 @@ def get_git_remote_default_branch(remote_name): info=lambda x: x if x is not None else "not a PR branch") def get_base_branch(): if not os.path.exists(os.path.join(SRCDIR, '.git')): + print('No', SRCDIR) # Not a git checkout, so there's no base branch return None upstream_remote = get_git_upstream_remote() @@ -108,6 +109,7 @@ def get_base_branch(): else: base_branch = "{0.major}.{0.minor}".format(version) this_branch = get_git_branch() + print(locals()) if this_branch is None or this_branch == base_branch: # Not on a git PR branch, so there's no base branch return None From 89ff09ed35dc474b8a816e7d41a3f73a967ea870 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 22:56:02 +0300 Subject: [PATCH 10/13] Run patchcheck as a part of "Check generated files" job --- .github/workflows/build.yml | 5 +++++ .github/workflows/lint.yml | 19 ------------------- Tools/patchcheck/patchcheck.py | 2 -- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cbe5c841a433cf..c74700d7050d0f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -164,6 +164,11 @@ jobs: - name: Check for unsupported C global variables if: github.event_name == 'pull_request' # $GITHUB_EVENT_NAME run: make check-c-globals + - name: Run patchcheck + if: github.event_name == 'pull_request' # $GITHUB_EVENT_NAME + run: | + git fetch origin + ./python Tools/patchcheck/patchcheck.py --ci true build_win32: name: 'Windows (x86)' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3a706a46200026..89f65816b6969d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,22 +24,3 @@ jobs: with: python-version: "3.x" - uses: pre-commit/action@v3.0.0 - - patchcheck: - if: "github.repository == 'python/cpython' && github.event_name == 'pull_request'" - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - name: "Run patchcheck" - run: | - git status && git branch - python Tools/patchcheck/patchcheck.py --ci true diff --git a/Tools/patchcheck/patchcheck.py b/Tools/patchcheck/patchcheck.py index f6418253c67cfa..fa3a43af6e6048 100755 --- a/Tools/patchcheck/patchcheck.py +++ b/Tools/patchcheck/patchcheck.py @@ -99,7 +99,6 @@ def get_git_remote_default_branch(remote_name): info=lambda x: x if x is not None else "not a PR branch") def get_base_branch(): if not os.path.exists(os.path.join(SRCDIR, '.git')): - print('No', SRCDIR) # Not a git checkout, so there's no base branch return None upstream_remote = get_git_upstream_remote() @@ -109,7 +108,6 @@ def get_base_branch(): else: base_branch = "{0.major}.{0.minor}".format(version) this_branch = get_git_branch() - print(locals()) if this_branch is None or this_branch == base_branch: # Not on a git PR branch, so there's no base branch return None From 703be97e3305e2c3026e9902abb9b843f78223fb Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 15 Sep 2023 23:13:10 +0300 Subject: [PATCH 11/13] Use `make` --- .github/workflows/build.yml | 10 +++++----- Makefile.pre.in | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c74700d7050d0f..0aaccb6d8bcefe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -143,6 +143,11 @@ jobs: make regen-deepfreeze make -j4 regen-all make regen-stdlib-module-names + - name: Run patchcheck + if: github.event_name == 'pull_request' + run: | + git fetch origin + make ARGS="--ci true" patchcheck - name: Check for changes run: | git add -u @@ -164,11 +169,6 @@ jobs: - name: Check for unsupported C global variables if: github.event_name == 'pull_request' # $GITHUB_EVENT_NAME run: make check-c-globals - - name: Run patchcheck - if: github.event_name == 'pull_request' # $GITHUB_EVENT_NAME - run: | - git fetch origin - ./python Tools/patchcheck/patchcheck.py --ci true build_win32: name: 'Windows (x86)' diff --git a/Makefile.pre.in b/Makefile.pre.in index ba35e1b563ce26..853dbf946dd12c 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -2764,7 +2764,7 @@ funny: # Perform some verification checks on any modified files. .PHONY: patchcheck patchcheck: all - $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/patchcheck/patchcheck.py + $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/patchcheck/patchcheck.py $(ARGS) .PHONY: check-limited-abi check-limited-abi: all From 0f33871c4cd5305480f65dedaef36cb2fcd712ae Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 16 Sep 2023 10:24:09 +0300 Subject: [PATCH 12/13] Try without `git fetch origin` --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0aaccb6d8bcefe..71a531dc0abce7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -146,7 +146,7 @@ jobs: - name: Run patchcheck if: github.event_name == 'pull_request' run: | - git fetch origin + # git fetch origin make ARGS="--ci true" patchcheck - name: Check for changes run: | From e6304160422d542a06f512730e7ce91d38c18941 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 16 Sep 2023 10:34:22 +0300 Subject: [PATCH 13/13] Return `git fetch origin` back --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 71a531dc0abce7..0aaccb6d8bcefe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -146,7 +146,7 @@ jobs: - name: Run patchcheck if: github.event_name == 'pull_request' run: | - # git fetch origin + git fetch origin make ARGS="--ci true" patchcheck - name: Check for changes run: |