Skip to content

Commit e00f52c

Browse files
Cycloctanewebknjaz
authored andcommitted
Skip benchmarks in ci when running in fork repositories (aio-libs#11737)
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 <webknjaz@redhat.com> (cherry picked from commit f30f43e)
1 parent e03822d commit e00f52c

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

.github/workflows/ci-cd.yml

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,33 @@ env:
2323
FORCE_COLOR: 1 # Request colored output from CLI tools supporting it
2424
MYPY_FORCE_COLOR: 1
2525
PY_COLORS: 1
26+
UPSTREAM_REPOSITORY_ID: >-
27+
13258039
28+
29+
permissions: {}
2630

2731
jobs:
2832

33+
pre-setup:
34+
name: Pre-Setup global build settings
35+
runs-on: ubuntu-latest
36+
outputs:
37+
upstream-repository-id: ${{ env.UPSTREAM_REPOSITORY_ID }}
38+
release-requested: >-
39+
${{
40+
(
41+
github.event_name == 'push'
42+
&& github.ref_type == 'tag'
43+
)
44+
&& true
45+
|| false
46+
}}
47+
steps:
48+
- name: Dummy
49+
if: false
50+
run: |
51+
echo "Pre-setup step"
52+
2953
lint:
3054
name: Linter
3155
runs-on: ubuntu-latest
@@ -243,8 +267,11 @@ jobs:
243267

244268
benchmark:
245269
name: Benchmark
246-
needs: gen_llhttp
247-
270+
needs:
271+
- gen_llhttp
272+
- pre-setup # transitive, for accessing settings
273+
if: >-
274+
needs.pre-setup.outputs.upstream-repository-id == github.repository_id
248275
runs-on: ubuntu-latest
249276
timeout-minutes: 12
250277
steps:
@@ -279,7 +306,6 @@ jobs:
279306
uses: CodSpeedHQ/action@v4
280307
with:
281308
mode: instrumentation
282-
token: ${{ secrets.CODSPEED_TOKEN }}
283309
run: python -Im pytest --no-cov --numprocesses=0 -vvvvv --codspeed
284310

285311

@@ -301,9 +327,10 @@ jobs:
301327
pre-deploy:
302328
name: Pre-Deploy
303329
runs-on: ubuntu-latest
304-
needs: check
305-
# Run only on pushing a tag
306-
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
330+
needs:
331+
- check
332+
- pre-setup # transitive, for accessing settings
333+
if: fromJSON(needs.pre-setup.outputs.release-requested)
307334
steps:
308335
- name: Dummy
309336
run: |
@@ -443,8 +470,13 @@ jobs:
443470

444471
deploy:
445472
name: Deploy
446-
needs: [build-tarball, build-wheels]
473+
needs:
474+
- build-tarball
475+
- build-wheels
476+
- pre-setup # transitive, for accessing settings
447477
runs-on: ubuntu-latest
478+
if: >-
479+
needs.pre-setup.outputs.upstream-repository-id == github.repository_id
448480
449481
permissions:
450482
contents: write # IMPORTANT: mandatory for making GitHub Releases

CHANGES/11737.contrib.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The benchmark CI job now runs only in the upstream repository -- by :user:`Cycloctane`.
2+
3+
It used to always fail in forks, which this change fixed.

0 commit comments

Comments
 (0)