Skip to content

Commit 9b0a252

Browse files
clubandersonclaude
andcommitted
ci: add minimal permission gate for e2e tests
Add a simple gate job that checks if the PR author is privileged (admin/maintain/write). E2E tests only run for privileged users. External contributors will need the full /ok-to-test flow which will be enabled once the gate workflow is merged to main. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 78a73c7 commit 9b0a252

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

.github/workflows/ci-e2e-openshift.yaml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,39 @@ on:
4242
default: '30'
4343

4444
jobs:
45+
# Gate: Check if PR author is privileged (admin/maintain/write)
46+
# External contributors need maintainer approval via /ok-to-test (handled by gate workflow after merge)
47+
gate:
48+
runs-on: ubuntu-latest
49+
outputs:
50+
should_run: ${{ steps.check.outputs.should_run }}
51+
steps:
52+
- name: Check permissions
53+
id: check
54+
uses: actions/github-script@v7
55+
with:
56+
script: |
57+
// Always run for workflow_dispatch
58+
if (context.eventName === 'workflow_dispatch') {
59+
core.setOutput('should_run', 'true');
60+
return;
61+
}
62+
63+
// Check PR author permission
64+
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
username: context.payload.pull_request.user.login
68+
});
69+
const privilegedRoles = ['admin', 'maintain', 'write'];
70+
const isPrivileged = privilegedRoles.includes(permission.permission);
71+
console.log(`PR author ${context.payload.pull_request.user.login}: ${permission.permission}, privileged: ${isPrivileged}`);
72+
core.setOutput('should_run', isPrivileged ? 'true' : 'false');
73+
4574
# Build the WVA controller image on GitHub-hosted runner (has proper Docker setup)
4675
build-image:
76+
needs: gate
77+
if: needs.gate.outputs.should_run == 'true'
4778
runs-on: ubuntu-latest
4879
outputs:
4980
image_tag: ${{ steps.build.outputs.image_tag }}
@@ -86,7 +117,8 @@ jobs:
86117
# Run e2e tests on OpenShift self-hosted runner
87118
e2e-openshift:
88119
runs-on: [self-hosted, openshift]
89-
needs: build-image
120+
needs: [gate, build-image]
121+
if: needs.gate.outputs.should_run == 'true'
90122
env:
91123
MODEL_ID: ${{ github.event.inputs.model_id || 'unsloth/Meta-Llama-3.1-8B' }}
92124
ACCELERATOR_TYPE: ${{ github.event.inputs.accelerator_type || 'H100' }}

0 commit comments

Comments
 (0)