Skip to content

Commit 465ad3c

Browse files
committed
Reworked fork PR status check reporting
The extra workflow did not work out because the workflow_dispatch inputs of the IT workflow are not accessible. Added a 'Report fork PR status' step to every IT which reports the IT status on the fork PR. Needed only for fork PRs because their ITs have to run in the context of the main repo to grant access to secrets.
1 parent 364817c commit 465ad3c

8 files changed

Lines changed: 117 additions & 79 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Report fork PR integration test status
2+
description: Post a GitHub commit status for a single job back to a fork PR head SHA
3+
4+
inputs:
5+
pr_ref:
6+
description: 'SHA of the fork PR head commit'
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Post commit status
13+
shell: bash
14+
env:
15+
GH_TOKEN: ${{ github.token }}
16+
run: |
17+
case "${{ job.status }}" in
18+
success) state="success" ;;
19+
cancelled|timed_out) state="error" ;;
20+
skipped) exit 0 ;;
21+
*) state="failure" ;;
22+
esac
23+
gh api --method POST "repos/${{ github.repository }}/statuses/${{ inputs.pr_ref }}" \
24+
-f state="$state" \
25+
-f context="${{ job.name }}" \
26+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
27+
-f description="${{ job.status }}"

.github/workflows/alioss-integration.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
github.event_name == 'push' ||
2626
github.event_name == 'workflow_dispatch' ||
2727
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
28+
permissions:
29+
statuses: write
2830
steps:
2931
- name: Checkout code
3032
uses: actions/checkout@v7
@@ -53,4 +55,9 @@ jobs:
5355
run: |
5456
export access_key_id="${{ secrets.ALI_ACCESS_KEY_ID }}"
5557
export access_key_secret="${{ secrets.ALI_ACCESS_KEY_SECRET }}"
56-
./.github/scripts/alioss/teardown.sh
58+
./.github/scripts/alioss/teardown.sh
59+
- name: Report fork PR status
60+
if: always() && inputs.pr_ref != ''
61+
uses: ./.github/actions/report-fork-status
62+
with:
63+
pr_ref: ${{ inputs.pr_ref }}

.github/workflows/azurebs-integration.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
github.event_name == 'push' ||
2626
github.event_name == 'workflow_dispatch' ||
2727
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
28+
permissions:
29+
statuses: write
2830
steps:
2931
- name: Checkout code
3032
uses: actions/checkout@v7
@@ -52,4 +54,8 @@ jobs:
5254
export azure_storage_account="${{ secrets.AZURE_STORAGE_ACCOUNT }}"
5355
export azure_storage_key="${{ secrets.AZURE_STORAGE_KEY }}"
5456
./.github/scripts/azurebs/teardown.sh
55-
57+
- name: Report fork PR status
58+
if: always() && inputs.pr_ref != ''
59+
uses: ./.github/actions/report-fork-status
60+
with:
61+
pr_ref: ${{ inputs.pr_ref }}

.github/workflows/dav-integration.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ jobs:
2424
github.event_name == 'push' ||
2525
github.event_name == 'workflow_dispatch' ||
2626
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
27-
27+
permissions:
28+
statuses: write
2829
steps:
2930
- name: Checkout code
3031
uses: actions/checkout@v7
@@ -41,3 +42,9 @@ jobs:
4142

4243
- name: Run DAV Integration Tests
4344
run: ginkgo -r dav/integration/
45+
46+
- name: Report fork PR status
47+
if: always() && inputs.pr_ref != ''
48+
uses: ./.github/actions/report-fork-status
49+
with:
50+
pr_ref: ${{ inputs.pr_ref }}

.github/workflows/fork-integration-status-reporter.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/fork-integration-trigger.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ jobs:
4545
-f content=rocket
4646
4747
- name: Trigger integration tests
48-
env:
49-
# need bot token, otherwise the IT workflows won't trigger fork-integration-status-reporter.yml
50-
GH_TOKEN: ${{ secrets.BOT_GH_TOKEN }}
5148
run: |
5249
# run all integration test workflows in context of main branch, passing the PR head SHA as an input
5350
for workflow in s3-integration.yml gcs-integration.yml alioss-integration.yml azurebs-integration.yml dav-integration.yml; do

.github/workflows/gcs-integration.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
github.event_name == 'push' ||
2626
github.event_name == 'workflow_dispatch' ||
2727
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
28+
permissions:
29+
statuses: write
2830
steps:
2931
- name: Checkout code
3032
uses: actions/checkout@v7
@@ -40,7 +42,7 @@ jobs:
4042
run: |
4143
echo "${{ secrets.GCP_SERVICE_ACCOUNT_BASE64 }}" | base64 -d > /tmp/gcp-key.json
4244
export google_json_key_data="$(cat /tmp/gcp-key.json)"
43-
./.github/scripts/gcs/setup.sh
45+
./.github/scripts/gcs/setup.sh
4446
- name: Run Fast Tests
4547
run: |
4648
echo "${{ secrets.GCP_SERVICE_ACCOUNT_BASE64 }}" | base64 -d > /tmp/gcp-key.json
@@ -53,6 +55,11 @@ jobs:
5355
echo "${{ secrets.GCP_SERVICE_ACCOUNT_BASE64 }}" | base64 -d > /tmp/gcp-key.json
5456
export google_json_key_data="$(cat /tmp/gcp-key.json)"
5557
./.github/scripts/gcs/teardown.sh
58+
- name: Report fork PR status
59+
if: always() && inputs.pr_ref != ''
60+
uses: ./.github/actions/report-fork-status
61+
with:
62+
pr_ref: ${{ inputs.pr_ref }}
5663

5764
gcs-integration-all-tests:
5865
name: GCS Integation All Tests
@@ -62,11 +69,13 @@ jobs:
6269
github.event_name == 'push' ||
6370
github.event_name == 'workflow_dispatch' ||
6471
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
72+
permissions:
73+
statuses: write
6574
steps:
6675
- name: Checkout code
6776
uses: actions/checkout@v7
6877
with:
69-
ref: ${{ inputs.pr_ref || github.sha }}
78+
ref: ${{ inputs.pr_ref || github.sha }}
7079
- name: Set up Go
7180
uses: actions/setup-go@v6
7281
with:
@@ -77,7 +86,7 @@ jobs:
7786
run: |
7887
echo "${{ secrets.GCP_SERVICE_ACCOUNT_BASE64 }}" | base64 -d > /tmp/gcp-key.json
7988
export google_json_key_data="$(cat /tmp/gcp-key.json)"
80-
./.github/scripts/gcs/setup.sh
89+
./.github/scripts/gcs/setup.sh
8190
- name: Run All Tests
8291
run: |
8392
echo "${{ secrets.GCP_SERVICE_ACCOUNT_BASE64 }}" | base64 -d > /tmp/gcp-key.json
@@ -89,4 +98,8 @@ jobs:
8998
echo "${{ secrets.GCP_SERVICE_ACCOUNT_BASE64 }}" | base64 -d > /tmp/gcp-key.json
9099
export google_json_key_data="$(cat /tmp/gcp-key.json)"
91100
./.github/scripts/gcs/teardown.sh
92-
101+
- name: Report fork PR status
102+
if: always() && inputs.pr_ref != ''
103+
uses: ./.github/actions/report-fork-status
104+
with:
105+
pr_ref: ${{ inputs.pr_ref }}

.github/workflows/s3-integration.yml

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
github.event_name == 'push' ||
2626
github.event_name == 'workflow_dispatch' ||
2727
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
28+
permissions:
29+
statuses: write
2830
env:
2931
REGION_NAME: us-east-1
3032
STACK_NAME: s3cli-iam
@@ -87,6 +89,12 @@ jobs:
8789
region_name: ${{ env.REGION_NAME }}
8890
stack_name: ${{ env.STACK_NAME }}
8991

92+
- name: Report fork PR status
93+
if: always() && inputs.pr_ref != ''
94+
uses: ./.github/actions/report-fork-status
95+
with:
96+
pr_ref: ${{ inputs.pr_ref }}
97+
9098
aws-s3-regional-integration:
9199
name: AWS S3 ${{ matrix.name }} Integration
92100
runs-on: ubuntu-latest
@@ -95,6 +103,8 @@ jobs:
95103
github.event_name == 'push' ||
96104
github.event_name == 'workflow_dispatch' ||
97105
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
106+
permissions:
107+
statuses: write
98108
strategy:
99109
fail-fast: false
100110
matrix:
@@ -154,29 +164,44 @@ jobs:
154164
region_name: ${{ matrix.region_name }}
155165
stack_name: ${{ matrix.stack_name }}
156166

167+
- name: Report fork PR status
168+
if: always() && inputs.pr_ref != ''
169+
uses: ./.github/actions/report-fork-status
170+
with:
171+
pr_ref: ${{ inputs.pr_ref }}
172+
157173
s3-compatible-integration:
158-
name: S3 Compatible Integration
159-
runs-on: ubuntu-latest
160-
# Run on push/workflow_dispatch, skip fork PRs
161-
if: |
162-
github.event_name == 'push' ||
163-
github.event_name == 'workflow_dispatch' ||
164-
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
165-
steps:
166-
- name: Checkout code
167-
uses: actions/checkout@v7
168-
with:
169-
ref: ${{ inputs.pr_ref || github.sha }}
170-
171-
- name: Set up test environment
172-
uses: ./.github/actions/go-test-bootstrap
173-
174-
- name: Run GCS S3 compatible tests
175-
run: |
176-
export access_key_id="${{ secrets.GCP_ACCESS_KEY_ID }}"
177-
export secret_access_key="${{ secrets.GCP_SECRET_ACCESS_KEY }}"
178-
export bucket_name=storage-cli-test-aws-compat
179-
export s3_endpoint_host=storage.googleapis.com
180-
export s3_endpoint_port=443
181-
export label_filter='s3-compatible'
182-
./.github/scripts/s3/run-integration-s3-compat.sh
174+
name: S3 Compatible Integration
175+
runs-on: ubuntu-latest
176+
# Run on push/workflow_dispatch, skip fork PRs
177+
if: |
178+
github.event_name == 'push' ||
179+
github.event_name == 'workflow_dispatch' ||
180+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
181+
permissions:
182+
statuses: write
183+
steps:
184+
- name: Checkout code
185+
uses: actions/checkout@v7
186+
with:
187+
ref: ${{ inputs.pr_ref || github.sha }}
188+
189+
- name: Set up test environment
190+
uses: ./.github/actions/go-test-bootstrap
191+
192+
- name: Run GCS S3 compatible tests
193+
run: |
194+
export access_key_id="${{ secrets.GCP_ACCESS_KEY_ID }}"
195+
export secret_access_key="${{ secrets.GCP_SECRET_ACCESS_KEY }}"
196+
export bucket_name=storage-cli-test-aws-compat
197+
export s3_endpoint_host=storage.googleapis.com
198+
export s3_endpoint_port=443
199+
export label_filter='s3-compatible'
200+
./.github/scripts/s3/run-integration-s3-compat.sh
201+
202+
- name: Report fork PR status
203+
if: always() && inputs.pr_ref != ''
204+
uses: ./.github/actions/report-fork-status
205+
with:
206+
pr_ref: ${{ inputs.pr_ref }}
207+

0 commit comments

Comments
 (0)