From fe5d064116b284e89f16a68dc0f21742589d476d Mon Sep 17 00:00:00 2001 From: Rui Xi Date: Tue, 20 Jan 2026 01:12:26 +0800 Subject: [PATCH] Skip benchmarks in ci when running in fork repositories (#11737) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forks cannot use codspeed account, which can make benchmark job in ci fail if aiohttp contributors want to run test workflow on their forks. This pr make unnecessary steps skip if triggered workflow is not in the main repository. aiohttp contributors can now run github action workflows to test changes in their forks without unnecessary errors. Co-authored-by: πŸ‡ΊπŸ‡¦ Sviatoslav Sydorenko (cherry picked from commit f30f43e61a015daa81db5220eb52c8201c71ffc9) --- .github/workflows/ci-cd.yml | 46 +++++++++++++++++++++++++++++++------ CHANGES/11737.contrib.rst | 3 +++ 2 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 CHANGES/11737.contrib.rst diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 4ebed113f06..2e78b5080eb 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -23,9 +23,33 @@ env: FORCE_COLOR: 1 # Request colored output from CLI tools supporting it MYPY_FORCE_COLOR: 1 PY_COLORS: 1 + UPSTREAM_REPOSITORY_ID: >- + 13258039 + +permissions: {} jobs: + pre-setup: + name: Pre-Setup global build settings + runs-on: ubuntu-latest + outputs: + upstream-repository-id: ${{ env.UPSTREAM_REPOSITORY_ID }} + release-requested: >- + ${{ + ( + github.event_name == 'push' + && github.ref_type == 'tag' + ) + && true + || false + }} + steps: + - name: Dummy + if: false + run: | + echo "Pre-setup step" + lint: name: Linter runs-on: ubuntu-latest @@ -243,8 +267,11 @@ jobs: benchmark: name: Benchmark - needs: gen_llhttp - + needs: + - gen_llhttp + - pre-setup # transitive, for accessing settings + if: >- + needs.pre-setup.outputs.upstream-repository-id == github.repository_id runs-on: ubuntu-latest timeout-minutes: 12 steps: @@ -279,7 +306,6 @@ jobs: uses: CodSpeedHQ/action@v4 with: mode: instrumentation - token: ${{ secrets.CODSPEED_TOKEN }} run: python -Im pytest --no-cov --numprocesses=0 -vvvvv --codspeed @@ -301,9 +327,10 @@ jobs: pre-deploy: name: Pre-Deploy runs-on: ubuntu-latest - needs: check - # Run only on pushing a tag - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + needs: + - check + - pre-setup # transitive, for accessing settings + if: fromJSON(needs.pre-setup.outputs.release-requested) steps: - name: Dummy run: | @@ -443,8 +470,13 @@ jobs: deploy: name: Deploy - needs: [build-tarball, build-wheels] + needs: + - build-tarball + - build-wheels + - pre-setup # transitive, for accessing settings runs-on: ubuntu-latest + if: >- + needs.pre-setup.outputs.upstream-repository-id == github.repository_id permissions: contents: write # IMPORTANT: mandatory for making GitHub Releases diff --git a/CHANGES/11737.contrib.rst b/CHANGES/11737.contrib.rst new file mode 100644 index 00000000000..2b793f41d6c --- /dev/null +++ b/CHANGES/11737.contrib.rst @@ -0,0 +1,3 @@ +The benchmark CI job now runs only in the upstream repository -- by :user:`Cycloctane`. + +It used to always fail in forks, which this change fixed.