Skip to content

Commit fa0291a

Browse files
committed
/run-integration comment for fork PRs
- approvers can trigger integration tests on PRs from forks AFTER reviewing the PR - green integration tests are required for merging a PR (status checks)
1 parent f73d94e commit fa0291a

7 files changed

Lines changed: 92 additions & 3 deletions

.github/workflows/alioss-integration.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Alioss Integration Tests
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
pr_ref:
7+
description: 'SHA of the PR head commit (for fork PRs)'
8+
required: false
9+
default: ''
510
pull_request:
611
push:
712
branches:
@@ -23,6 +28,8 @@ jobs:
2328
steps:
2429
- name: Checkout code
2530
uses: actions/checkout@v7
31+
with:
32+
ref: ${{ inputs.pr_ref || github.sha }}
2633
- name: Set up Go
2734
uses: actions/setup-go@v6
2835
with:

.github/workflows/azurebs-integration.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Azurebs Integration Tests
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
pr_ref:
7+
description: 'SHA of the PR head commit (for fork PRs)'
8+
required: false
9+
default: ''
510
pull_request:
611
push:
712
branches:
@@ -23,6 +28,8 @@ jobs:
2328
steps:
2429
- name: Checkout code
2530
uses: actions/checkout@v7
31+
with:
32+
ref: ${{ inputs.pr_ref || github.sha }}
2633
- name: Set up Go
2734
uses: actions/setup-go@v6
2835
with:

.github/workflows/dav-integration.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: DAV Integration Tests
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
pr_ref:
7+
description: 'SHA of the PR head commit (for fork PRs)'
8+
required: false
9+
default: ''
510
pull_request:
611
push:
712
branches:
@@ -23,6 +28,8 @@ jobs:
2328
steps:
2429
- name: Checkout code
2530
uses: actions/checkout@v7
31+
with:
32+
ref: ${{ inputs.pr_ref || github.sha }}
2633

2734
- name: Set up Go
2835
uses: actions/setup-go@v6

.github/workflows/dependabot-auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ permissions:
99
jobs:
1010
auto-merge:
1111
runs-on: ubuntu-latest
12-
if: ${{ github.actor == 'dependabot[bot]' }}
12+
if: github.actor == 'dependabot[bot]'
1313
steps:
1414
- name: Enable auto-merge
1515
run: gh pr merge --auto --rebase "${{ github.event.pull_request.number }}"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Trigger integration tests for fork PRs
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
trigger:
12+
name: Trigger integration tests
13+
runs-on: ubuntu-latest
14+
if: |
15+
github.event.issue.pull_request != null &&
16+
contains(github.event.comment.body, '/run-integration')
17+
steps:
18+
- name: Check commenter has write permission
19+
run: |
20+
permission=$(gh api repos/$GITHUB_REPOSITORY/collaborators/${{ github.actor }}/permission --jq '.permission')
21+
if [[ "$permission" != "write" && "$permission" != "admin" ]]; then
22+
echo "${{ github.actor }} does not have write permission (got: $permission)"
23+
exit 1
24+
fi
25+
26+
- name: Get PR head SHA and check for fork
27+
id: pr
28+
run: |
29+
pr=$(gh pr view ${{ github.event.issue.number }} --json headRefOid,isCrossRepository)
30+
read -r ref is_fork < <(echo "$pr" | jq -r '[.headRefOid, (.isCrossRepository | tostring)] | @tsv')
31+
if [[ "$is_fork" == "false" ]]; then
32+
echo "This command is only needed for fork PRs. Integration tests run automatically for PRs from this repository."
33+
exit 1
34+
fi
35+
echo "ref=$ref" >> $GITHUB_OUTPUT
36+
37+
- name: Add reaction to comment
38+
run: |
39+
gh api --method POST \
40+
repos/$GITHUB_REPOSITORY/issues/comments/${{ github.event.comment.id }}/reactions \
41+
-f content=rocket
42+
43+
- name: Trigger integration tests
44+
run: |
45+
for workflow in s3-integration.yml gcs-integration.yml alioss-integration.yml azurebs-integration.yml dav-integration.yml; do
46+
gh workflow run "$workflow" --ref ${{ github.event.repository.default_branch }} -f pr_ref=${{ steps.pr.outputs.ref }} &
47+
done
48+
wait

.github/workflows/gcs-integration.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: GCS Integration Tests
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
pr_ref:
7+
description: 'SHA of the PR head commit (for fork PRs)'
8+
required: false
9+
default: ''
510
pull_request:
611
push:
712
branches:
@@ -22,7 +27,9 @@ jobs:
2227
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
2328
steps:
2429
- name: Checkout code
25-
uses: actions/checkout@v7
30+
uses: actions/checkout@v7
31+
with:
32+
ref: ${{ inputs.pr_ref || github.sha }}
2633
- name: Set up Go
2734
uses: actions/setup-go@v6
2835
with:
@@ -57,7 +64,9 @@ jobs:
5764
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
5865
steps:
5966
- name: Checkout code
60-
uses: actions/checkout@v7
67+
uses: actions/checkout@v7
68+
with:
69+
ref: ${{ inputs.pr_ref || github.sha }}
6170
- name: Set up Go
6271
uses: actions/setup-go@v6
6372
with:

.github/workflows/s3-integration.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: S3 Integration Tests
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
pr_ref:
7+
description: 'SHA of the PR head commit (for fork PRs)'
8+
required: false
9+
default: ''
510
pull_request:
611
push:
712
branches:
@@ -27,6 +32,8 @@ jobs:
2732
steps:
2833
- name: Checkout code
2934
uses: actions/checkout@v7
35+
with:
36+
ref: ${{ inputs.pr_ref || github.sha }}
3037

3138
- name: Set up test environment
3239
uses: ./.github/actions/go-test-bootstrap
@@ -113,6 +120,8 @@ jobs:
113120
steps:
114121
- name: Checkout code
115122
uses: actions/checkout@v7
123+
with:
124+
ref: ${{ inputs.pr_ref || github.sha }}
116125

117126
- name: Set up test environment
118127
uses: ./.github/actions/go-test-bootstrap
@@ -156,6 +165,8 @@ jobs:
156165
steps:
157166
- name: Checkout code
158167
uses: actions/checkout@v7
168+
with:
169+
ref: ${{ inputs.pr_ref || github.sha }}
159170

160171
- name: Set up test environment
161172
uses: ./.github/actions/go-test-bootstrap

0 commit comments

Comments
 (0)