From f30f43e61a015daa81db5220eb52c8201c71ffc9 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 --- .github/workflows/ci-cd.yml | 45 +++++++++++++++++++++++++++++++------ CHANGES/11737.contrib.rst | 3 +++ 2 files changed, 41 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 ffa901a3d97..5913a2ce238 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -23,10 +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: permissions: contents: read # to fetch code (actions/checkout) @@ -259,8 +282,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: @@ -295,7 +321,6 @@ jobs: uses: CodSpeedHQ/action@v4 with: mode: instrumentation - token: ${{ secrets.CODSPEED_TOKEN }} run: python -Im pytest --no-cov --numprocesses=0 -vvvvv --codspeed @@ -317,9 +342,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: | @@ -465,8 +491,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.