Skip to content

Commit 0b1e646

Browse files
committed
workflows: test improvements
1 parent b6b4a56 commit 0b1e646

File tree

6 files changed

+127
-101
lines changed

6 files changed

+127
-101
lines changed

.github/workflows/comment.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Comment
2+
3+
on:
4+
pull_request_target:
5+
types: ["opened"]
6+
branches: ["main"]
7+
8+
jobs:
9+
comment:
10+
runs-on: ubuntu-latest
11+
permissions: write-all
12+
steps:
13+
- uses: thollander/actions-comment-pull-request@v3
14+
with:
15+
message: |
16+
### Tests
17+
Please note that running unit and e2e tests requires manual approval from a team member.
18+
19+
### e2e tests
20+
We use labels to control which e2e tests contexts are run:
21+
22+
| Label | Behaviour |
23+
|--|--|
24+
| none | Run `Generic` tests only |
25+
| https://github.com/ionos-cloud/cluster-api-provider-proxmox/labels/e2e%2Fnone | Do not run any e2e tests |
26+
| https://github.com/ionos-cloud/cluster-api-provider-proxmox/labels/e2e%2Fflatcar | Add `Flatcar` tests |
27+
28+
ℹ️ Ask a team member to add the requested labels if you don't have enough permissions.
29+
comment_tag: comment
30+
mode: "recreate"

.github/workflows/e2e-comment.yml

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

.github/workflows/run-tests.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Run tests
2+
on:
3+
workflow_call:
4+
secrets:
5+
GITHUB_TOKEN:
6+
required: true
7+
SONAR_TOKEN:
8+
required: true
9+
10+
jobs:
11+
go_test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: checkout PR ${{ github.event.pull_request.number }}
16+
if: ${{ github.event_name == 'pull_request_target' }}
17+
uses: actions/[email protected]
18+
with:
19+
fetch-depth: 0 # for SonarQube
20+
repository: ${{ github.event.pull_request.head.repo.full_name }}
21+
ref: ${{ github.event.pull_request.head.ref }}
22+
23+
- name: checkout
24+
- uses: actions/[email protected]
25+
if: ${{ github.event_name == 'push' }}
26+
with:
27+
fetch-depth: 0 # for SonarQube
28+
29+
- uses: actions/setup-go@v5
30+
with:
31+
go-version-file: go.mod
32+
33+
- run: "make verify"
34+
- run: "make test"
35+
36+
- name: SonarQube for PR ${{ github.event.pull_request.number }}
37+
if: ${{ github.event_name == 'pull_request_target' }}
38+
uses: SonarSource/[email protected]
39+
with:
40+
args: >
41+
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
42+
-Dsonar.scm.revision=${{ github.event.pull_request.head.sha }}
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
46+
47+
- name: SonarQube
48+
if: ${{ github.event_name == 'push' }}
49+
uses: SonarSource/[email protected]
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/test-comment.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Test comment
2+
3+
on:
4+
pull_request_target:
5+
types: ["opened"]
6+
branches: ["main"]
7+
8+
jobs:
9+
comment:
10+
runs-on: ubuntu-latest
11+
permissions: write-all
12+
steps:
13+
- name: PR comment with file
14+
uses: thollander/actions-comment-pull-request@v3
15+
with:
16+
message: |
17+
### Tests
18+
Please note that running unit and e2e tests requires manual approval from a team member.
19+
20+
### e2e tests
21+
We use labels to control which e2e tests contexts are run:
22+
23+
| Label | Behaviour |
24+
|--|--|
25+
| none | Run `Generic` tests only |
26+
| https://github.com/ionos-cloud/cluster-api-provider-proxmox/labels/e2e%2Fnone | Do not run any e2e tests |
27+
| https://github.com/ionos-cloud/cluster-api-provider-proxmox/labels/e2e%2Fflatcar | Add `Flatcar` tests |
28+
29+
ℹ️ Ask a team member to add the requested labels if you don't have enough permissions.
30+
comment_tag: test-comment
31+
mode: "recreate"

.github/workflows/test-external.yml

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

.github/workflows/test.yml

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,20 @@ on:
66
branches: ["main"]
77

88
jobs:
9-
go_test:
10-
if: ${{ github.event_name == 'push' }}
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/[email protected]
14-
with:
15-
fetch-depth: 0 # for sonarcloud
16-
- uses: actions/setup-go@v5
17-
with:
18-
go-version-file: go.mod
19-
- run: "make verify"
20-
- run: "make test"
21-
- uses: SonarSource/[email protected]
22-
if: ${{ github.event_name == 'push' }}
23-
env:
24-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
269

27-
ext_pr:
10+
pr-test:
2811
if: ${{ github.event_name == 'pull_request_target' }}
29-
runs-on: ubuntu-latest
30-
permissions:
31-
pull-requests: write
32-
steps:
33-
- uses: actions/[email protected]
34-
with:
35-
fetch-depth: 2 # for diff
36-
repository: ${{ github.event.pull_request.head.repo.full_name }}
37-
ref: ${{ github.event.pull_request.head.ref }}
38-
39-
- name: generate comment message
40-
run: |
41-
printf '%s\n%s\n\n' '### External PR' 'Test runs on external PRs require manual approval.' >"${{ runner.temp }}/msg"
42-
git diff --name-only -z HEAD^1 HEAD | grep -Evz '\.go$|^docs/' | tr '\0' '\n' >"${{ runner.temp }}/diff"
43-
if [ -s '${{ runner.temp }}'/diff ]; then
44-
echo '**Note:** This PR changes the following non-go, non-docs files:' >>"${{ runner.temp }}/msg"
45-
cat "${{ runner.temp }}/diff" >>"${{ runner.temp }}/msg"
46-
fi
12+
environment: e2e # request confirmation
13+
uses: ./.github/workflows/run-tests.yml
14+
with:
15+
secrets:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4718

48-
- uses: thollander/actions-comment-pull-request@v3
49-
with:
50-
comment_tag: test
51-
mode: recreate
52-
file-path: ${{ runner.temp }}/msg
19+
main-test:
20+
if: ${{ github.event_name == 'push' }}
21+
uses: ./.github/workflows/run-tests.yml
22+
with:
23+
secrets:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)