From 1493494ff3f6e913fb454d424fb8fc0887ef058f Mon Sep 17 00:00:00 2001 From: bhimrazy Date: Wed, 19 Nov 2025 13:52:46 +0545 Subject: [PATCH 1/4] fix: update pytester job conditions to optimize PR handling --- .github/workflows/cpu-tests.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cpu-tests.yml b/.github/workflows/cpu-tests.yml index fbe8fb21d7..8a42e93a4c 100644 --- a/.github/workflows/cpu-tests.yml +++ b/.github/workflows/cpu-tests.yml @@ -67,13 +67,14 @@ jobs: python -c "$modules" pytester: - # skip PR trigger if secrets are not shared as for all forked PRs + # Route PRs based on contributor type to avoid duplicate runs: + # - Collaborators: use pull_request (tests workflow changes from PR) + # - External forks: use pull_request_target (uses trusted workflow from main) + # - Always run for push to main and workflow_dispatch if: | - github.event_name != 'pull_request' || - ( - github.event_name == 'pull_request' && - contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association) - ) + (github.event_name == 'pull_request' && contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) || + (github.event_name == 'pull_request_target' && !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) || + (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -137,11 +138,8 @@ jobs: runs-on: ubuntu-latest needs: [pytester, testing-imports] if: | - github.event_name == 'pull_request_target' || - ( - github.event_name == 'pull_request' && - contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association) - ) + (github.event_name == 'pull_request_target' && !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) || + (github.event_name == 'pull_request' && contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) steps: - run: echo "${{ needs.pytester.result }}" - name: failing... From 5520f23964c58e4c6275dfb459d5ed939e66a331 Mon Sep 17 00:00:00 2001 From: Bhimraj Yadav Date: Wed, 19 Nov 2025 14:45:16 +0545 Subject: [PATCH 2/4] Apply suggestions Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/cpu-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpu-tests.yml b/.github/workflows/cpu-tests.yml index 8a42e93a4c..bfb7f5f6d0 100644 --- a/.github/workflows/cpu-tests.yml +++ b/.github/workflows/cpu-tests.yml @@ -72,8 +72,8 @@ jobs: # - External forks: use pull_request_target (uses trusted workflow from main) # - Always run for push to main and workflow_dispatch if: | - (github.event_name == 'pull_request' && contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) || - (github.event_name == 'pull_request_target' && !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) || + (github.event_name == 'pull_request' && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)) || + (github.event_name == 'pull_request_target' && !contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)) || (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') runs-on: ${{ matrix.os }} strategy: From dc4bb68d267504b978ecc3e35685c784524454e1 Mon Sep 17 00:00:00 2001 From: Bhimraj Yadav Date: Wed, 19 Nov 2025 14:45:35 +0545 Subject: [PATCH 3/4] Apply suggestions Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/cpu-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpu-tests.yml b/.github/workflows/cpu-tests.yml index bfb7f5f6d0..bc513943ff 100644 --- a/.github/workflows/cpu-tests.yml +++ b/.github/workflows/cpu-tests.yml @@ -139,7 +139,7 @@ jobs: needs: [pytester, testing-imports] if: | (github.event_name == 'pull_request_target' && !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) || - (github.event_name == 'pull_request' && contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) + (github.event_name == 'pull_request' && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)) steps: - run: echo "${{ needs.pytester.result }}" - name: failing... From ee972593cea3e65f9326ec629a1025ade59fa4a1 Mon Sep 17 00:00:00 2001 From: bhimrazy Date: Wed, 19 Nov 2025 14:58:00 +0545 Subject: [PATCH 4/4] condition doesn't seem to work properly --- .github/workflows/cpu-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cpu-tests.yml b/.github/workflows/cpu-tests.yml index bc513943ff..8a42e93a4c 100644 --- a/.github/workflows/cpu-tests.yml +++ b/.github/workflows/cpu-tests.yml @@ -72,8 +72,8 @@ jobs: # - External forks: use pull_request_target (uses trusted workflow from main) # - Always run for push to main and workflow_dispatch if: | - (github.event_name == 'pull_request' && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)) || - (github.event_name == 'pull_request_target' && !contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)) || + (github.event_name == 'pull_request' && contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) || + (github.event_name == 'pull_request_target' && !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) || (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') runs-on: ${{ matrix.os }} strategy: @@ -139,7 +139,7 @@ jobs: needs: [pytester, testing-imports] if: | (github.event_name == 'pull_request_target' && !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) || - (github.event_name == 'pull_request' && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)) + (github.event_name == 'pull_request' && contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) steps: - run: echo "${{ needs.pytester.result }}" - name: failing...