Why the ci gate in fork repo has been disabled

Hi, all.
Anybody know why the ci gate in fork repo has been disabled?

Which PR is this from?
It should done for documentation PRs: if the code isn’t modified, it doesn’t make sense to run tests.

Hi, petr. I created a PR in https://github.com/shihai1991/cpython/pull/26.
In this PR, I depend the ci gate to do some regrtests, but it’s can not be triggered in fact :frowning:
The ci gate of this PR in official repo can be triggered: https://github.com/python/cpython/runs/949786331

So I am not sure what have changed~

The reason is in your action logs.

I don’t think this is specifically done to prevent forks from running CI (and I don’t even know why it failed). I’m afraid you will have to dig into it to find out why it didn’t work in your fork.

Got it. I will try to take a look.

Hi, some pointers.

https://github.com/python/cpython/blob/master/.github/workflows/build.yml has an initial step check_source / “Check for source changes”, which does a git diff to check the changes are NOT only .rst, Doc or Misc (this is running in your PR).

        run: |
          if [ -z "GITHUB_BASE_REF" ]; then
            echo '::set-output name=run_tests::true'
          else
            git fetch origin $GITHUB_BASE_REF --depth=1
            git diff --name-only origin/$GITHUB_BASE_REF... | grep -qvE '(\.rst$|^Doc|^Misc)' && echo '::set-output name=run_tests::true' || true
          fi

If that passes, it sets a variable called run_tests to true, and the other build_[OS] steps only run when it’s true.

    if: needs.check_source.outputs.run_tests == 'true'

Your PR doesn’t set this for some reason, so the build steps are skipped.

Looking at your logs from https://github.com/shihai1991/cpython/pull/26/checks:

Run if [ -z "GITHUB_BASE_REF" ]; then
  if [ -z "GITHUB_BASE_REF" ]; then
    echo '::set-output name=run_tests::true'
  else
    git fetch origin $GITHUB_BASE_REF --depth=1
    git diff --name-only origin/$GITHUB_BASE_REF... | grep -qvE '(\.rst$|^Doc|^Misc)' && echo '::set-output name=run_tests::true' || true
  fi
  shell: /bin/bash -e {0}
From https://github.com/shihai1991/cpython
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
fatal: origin/master...HEAD: no merge base

So it’s failing to even do the diff. I’m not sure why.


I did a couple of test PRs in my own fork and they triggered builds as expected (#1, #2).

The second one is basically the same and has no error:

Run if [ -z "GITHUB_BASE_REF" ]; then
  if [ -z "GITHUB_BASE_REF" ]; then
    echo '::set-output name=run_tests::true'
  else
    git fetch origin $GITHUB_BASE_REF --depth=1
    git diff --name-only origin/$GITHUB_BASE_REF... | grep -qvE '(\.rst$|^Doc|^Misc)' && echo '::set-output name=run_tests::true' || true
  fi
  shell: /bin/bash -e {0}
From https://github.com/hugovk/cpython
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master

Perhaps git fetch origin $GITHUB_BASE_REF --depth=1 needs a greater depth or something?

(These checks were added in https://github.com/python/cpython/pull/19983 / https://bugs.python.org/issue40548).


If you want to see the output of the git diff, add a new line without the -q:

git diff --name-only origin/$GITHUB_BASE_REF... | grep -vE '(\.rst$|^Doc|^Misc)'

But that’s not going to show anything when it has a fatal error.


As a temporary workaround, you could force a build every time:

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5649a6670e..d0cefcc433 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -28,12 +28,7 @@ jobs:
       - name: Check for source changes
         id: check
         run: |
-          if [ -z "GITHUB_BASE_REF" ]; then
-            echo '::set-output name=run_tests::true'
-          else
-            git fetch origin $GITHUB_BASE_REF --depth=1
-            git diff --name-only origin/$GITHUB_BASE_REF... | grep -qvE '(\.rst$|^Doc|^Misc)' && echo '::set-output name=run_tests::true' || true
-          fi
+          echo '::set-output name=run_tests::true'
   build_win32:
     name: 'Windows (x86)'
     runs-on: windows-latest
1 Like

Wow, thanks hugo for your details :wink:

Hi, hugo. You are right. I have test it in my vm. Maybe you can create a PR to fix it :wink:

victor’s fix PR: https://github.com/python/cpython/pull/21806 (it’s not merged now, but it can fix this problem), thanks.

1 Like

It’s now merged.

2 Likes