Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ on:
description: "1Password vault name or UUID"
required: true

permissions:
contents: read

jobs:
# Full secret-resolution coverage (ubuntu only): all shapes, both delivery paths, both export-env branches. Per-OS resolution is covered by the smoke job below.
test-service-account:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ok-to-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Write comments "/ok-to-test sha=<hash>" on a pull request. This will emit a repository_dispatch event.
# Write comments "/ok-to-test sha=<full 40-character commit SHA>" on a pull request. This will emit a repository_dispatch event.
# Short or partial SHAs are rejected; E2E runs check out exactly the approved SHA.
name: Ok To Test

on:
Expand Down
29 changes: 21 additions & 8 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ concurrency:
format('e2e-{0}', github.ref) }}
cancel-in-progress: true

permissions:
contents: read

jobs:
check-external-pr:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -55,20 +58,23 @@ jobs:
fi
elif [ "${{ github.event_name }}" == "repository_dispatch" ]; then
# For repository_dispatch events (ok-to-test), check if sha matches
SHA_PARAM="${{ github.event.client_payload.slash_command.args.named.sha }}"
PR_HEAD_SHA="${{ github.event.client_payload.pull_request.head.sha }}"

# SHA_PARAM is the full commit SHA the maintainer approved in the comment.
# Only that exact commit is ever checked out; the PR head is used solely to
# confirm the approved commit is still the head.
echo "Checking dispatch event conditions..."
echo "SHA from command: $SHA_PARAM"
echo "PR head SHA: $PR_HEAD_SHA"

if [ -n "$SHA_PARAM" ] && [[ "$PR_HEAD_SHA" == *"$SHA_PARAM"* ]]; then
if [[ ! "$SHA_PARAM" =~ ^[0-9a-f]{40}$ ]]; then
echo "condition=skip" >> $GITHUB_OUTPUT
echo "Setting condition=skip (sha must be the full 40-character lowercase commit SHA)"
elif [ "$PR_HEAD_SHA" != "$SHA_PARAM" ]; then
echo "condition=skip" >> $GITHUB_OUTPUT
echo "Setting condition=skip (sha does not match PR head)"
else
echo "condition=dispatch-event" >> $GITHUB_OUTPUT
echo "Setting condition=dispatch-event (sha matches)"
echo "ref=$PR_HEAD_SHA" >> $GITHUB_OUTPUT
else
echo "condition=skip" >> $GITHUB_OUTPUT
echo "Setting condition=skip (sha does not match or empty)"
echo "ref=$SHA_PARAM" >> $GITHUB_OUTPUT
fi
elif [ "${{ github.event_name }}" == "push" ] && [ "${REF_NAME}" == "main" ]; then
echo "condition=push-to-main" >> $GITHUB_OUTPUT
Expand All @@ -82,8 +88,15 @@ jobs:

env:
REF_NAME: ${{ github.ref_name }}
SHA_PARAM: ${{ github.event.client_payload.slash_command.args.named.sha }}
PR_HEAD_SHA: ${{ github.event.client_payload.pull_request.head.sha }}
e2e:
needs: check-external-pr
# Upper bound for the called workflow's jobs. Never grant write access to
# contents here: this job runs approved fork code.
permissions:
contents: read
id-token: write # For the Workload Identity test job
if: |
(needs.check-external-pr.outputs.condition == 'pr-creation-maintainer')
||
Expand Down
4 changes: 2 additions & 2 deletions docs/fork-pr-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This document explains how testing works for external pull requests from forks.
The testing system consists of two main workflows:

1. **E2E Tests** (`test-e2e.yml`) - Runs automatically for internal PRs, need manual trigger on external PRs.
2. **Ok To Test** (`ok-to-test.yml`) - Dispatches `repository_dispatch` event when maintainer puts the `/ok-to-test sha=<commit hash>` comment in the forked PR thread.
2. **Ok To Test** (`ok-to-test.yml`) - Dispatches `repository_dispatch` event when maintainer puts the `/ok-to-test sha=<full commit SHA>` comment in the forked PR thread.

## How It Works

Expand All @@ -20,7 +20,7 @@ For the PR created by maintainer `E2E Test` workflow starts automatically. The P
For the PR created by external contributor `E2E Test` workflow **won't** start automatically.
Maintainer should make a sanity check of the changes and run it manually by:

1. Putting a comment `/ok-to-test sha=<latest commit hash>` in the PR thread.
1. Putting a comment `/ok-to-test sha=<latest commit hash>` in the PR thread. The SHA must be the **full 40-character** commit SHA of the PR head you reviewed; short SHAs are rejected, and only that exact commit is tested.
2. `E2E Test` workflow starts.
3. After `E2E Test` workflow finishes, a comment with a link to the workflow, along with its status will be posted in the PR.
4. Maintainer can merge PR or request the changes based on the `E2E Test` results.
Expand Down
Loading