Skip to content

Commit e07f91a

Browse files
committed
Convert e2e to workflow_dispatch
* Fixed checkout of branch after merge in e2e Signed-off-by: kouki <[email protected]>
1 parent 2002045 commit e07f91a

File tree

4 files changed

+110
-5
lines changed

4 files changed

+110
-5
lines changed

.github/workflows/ci-e2e.yaml

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ on:
77
paths-ignore:
88
- '**.md'
99
- "containers/**"
10-
pull_request:
11-
types: [opened, synchronize]
12-
paths-ignore:
13-
- '**.md'
14-
- "containers/**"
10+
workflow_dispatch:
1511

1612
concurrency:
1713
group: ${{ github.workflow }}-${{ github.ref }}
@@ -26,17 +22,48 @@ env:
2622
#
2723
# NOTE: Current Cybozu internal use version is 8.0.28.
2824
jobs:
25+
commit-status-start:
26+
name: Commit status start
27+
runs-on: ubuntu-22.04
28+
steps:
29+
- name: Set pending to commit status
30+
uses: myrotvorets/set-commit-status-action@38f3f27c7d52fb381273e95542f07f0fba301307 # v2.0.0
31+
with:
32+
sha: ${{ github.sha }}
33+
extract-github-ref:
34+
name: extract github.ref
35+
runs-on: ubuntu-22.04
36+
outputs:
37+
github_ref: ${{ steps.extract.outputs.github_ref }}
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Extract github.ref
41+
id: extract
42+
env:
43+
GH_TOKEN: ${{ github.token }}
44+
run: |
45+
# if exists PR refs/pull/<pull_request_number>/merge
46+
# if not exists PR → github.ref
47+
PR_number=$(gh pr view --json number -q .number)
48+
if [ $? == 0 ];then
49+
echo "github_ref=refs/pull/${PR_number}/merge" >> $GITHUB_OUTPUT
50+
else
51+
echo "github_ref=${{ github.ref }}" >> $GITHUB_OUTPUT
52+
fi
2953
dbtest:
3054
name: Integration tests with MySQL
55+
needs: extract-github-ref
3156
strategy:
3257
matrix:
3358
mysql-version: ["8.0.28", "8.0.34", "8.0.35"]
3459
uses: ./.github/workflows/dbtest.yaml
3560
with:
3661
mysql-version: ${{ matrix.mysql-version }}
62+
ref: ${{ needs.extract-github-ref.outputs.github_ref }}
3763

3864
e2e:
3965
name: Supported Kubernetes versions End-to-End Tests
66+
needs: extract-github-ref
4067
strategy:
4168
matrix:
4269
mysql-version: ["8.0.35"]
@@ -45,9 +72,11 @@ jobs:
4572
with:
4673
k8s-version: ${{ matrix.k8s-version }}
4774
mysql-version: ${{ matrix.mysql-version }}
75+
ref: ${{ needs.extract-github-ref.outputs.github_ref }}
4876

4977
e2e-mysql:
5078
name: Supported MySQL versions End-to-End Tests
79+
needs: extract-github-ref
5180
strategy:
5281
matrix:
5382
mysql-version: ["8.0.28", "8.0.34", "8.0.35"]
@@ -56,13 +85,17 @@ jobs:
5685
with:
5786
k8s-version: ${{ matrix.k8s-version }}
5887
mysql-version: ${{ matrix.mysql-version }}
88+
ref: ${{ needs.extract-github-ref.outputs.github_ref }}
5989

6090
upgrade:
6191
name: Upgrade Test
92+
needs: extract-github-ref
6293
runs-on:
6394
group: moco
6495
steps:
6596
- uses: actions/checkout@v4
97+
with:
98+
ref: ${{ needs.extract-github-ref.outputs.github_ref }}
6699
- uses: actions/setup-go@v4
67100
with:
68101
go-version-file: go.mod
@@ -84,3 +117,26 @@ jobs:
84117
with:
85118
name: logs-upgrade.tar.gz
86119
path: e2e/logs.tar.gz
120+
commit-status-final:
121+
if: always()
122+
name: Commit Status Final
123+
needs:
124+
- dbtest
125+
- e2e
126+
- e2e-mysql
127+
- upgrade
128+
runs-on: ubuntu-latest
129+
steps:
130+
- name: Get final status
131+
id: final-status
132+
run: |
133+
if "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}"; then
134+
echo "result=failure" >> $GITHUB_OUTPUT
135+
else
136+
echo "result=success" >> $GITHUB_OUTPUT
137+
fi
138+
- name: Set final commit status
139+
uses: myrotvorets/set-commit-status-action@38f3f27c7d52fb381273e95542f07f0fba301307 # v2.0.0
140+
with:
141+
sha: ${{ github.sha }}
142+
status: ${{ steps.final-status.outputs.result }}

.github/workflows/dbtest.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ on:
66
mysql-version:
77
required: true
88
type: string
9+
ref:
10+
required: false
11+
type: string
12+
default: ${{ github.ref }}
913

1014
jobs:
1115
dbtest:
1216
runs-on: ubuntu-20.04
1317
steps:
1418
- uses: actions/checkout@v4
19+
with:
20+
ref: ${{ inputs.ref }}
1521
- uses: actions/setup-go@v4
1622
with:
1723
go-version-file: go.mod

.github/workflows/e2e.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ on:
99
k8s-version:
1010
required: true
1111
type: string
12+
ref:
13+
required: false
14+
type: string
15+
default: ${{ github.ref }}
1216

1317
jobs:
1418
e2e:
1519
runs-on:
1620
group: moco
1721
steps:
1822
- uses: actions/checkout@v4
23+
with:
24+
ref: ${{ inputs.ref }}
1925
- uses: actions/setup-go@v4
2026
with:
2127
go-version-file: go.mod
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: handle PR comments
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
actions: write
11+
12+
jobs:
13+
trigger_e2e:
14+
name: "Trigger e2e test"
15+
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/test') && contains('["OWNER", "COLLABORATOR", "CONTRIBUTOR"]', github.event.comment.author_association)
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- name: create reaction
19+
env:
20+
GH_TOKEN: ${{ github.token }}
21+
run: |
22+
# https://docs.github.com/ja/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-an-issue-comment
23+
# needs pull_requests:write permission
24+
gh api \
25+
--method POST \
26+
-H "Accept: application/vnd.github+json" \
27+
-H "X-GitHub-Api-Version: 2022-11-28" \
28+
/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \
29+
-f content='rocket'
30+
- uses: actions/checkout@v4
31+
- name: trigger e2e
32+
env:
33+
GH_TOKEN: ${{ github.token }}
34+
run: |
35+
BRANCH_NAME=$(gh pr view --json headRefName --jq .headRefName ${{ github.event.issue.number }})
36+
echo "triggering e2e"
37+
gh workflow run --ref ${BRANCH_NAME} ci-e2e.yaml

0 commit comments

Comments
 (0)