Skip to content

Commit 5f172c4

Browse files
authored
Use head ref for release PR as base (#1239)
1 parent 96d68b8 commit 5f172c4

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Jobs defined in this file are responsible for things that do not require container image
2+
# but still relevant to the codebase such as unit tests, linting etc
3+
4+
name: Pull Request unit & lint
5+
on:
6+
workflow_call:
7+
8+
jobs:
9+
changed-files:
10+
outputs:
11+
any_modified: ${{ steps.changed-files.outputs.any_modified }}
12+
name: Check whether unit test & lint should run based on the changed files
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.event.pull_request.head.sha }}
18+
fetch-depth: 0
19+
- uses: tj-actions/changed-files@e9772d140489982e0e3704fea5ee93d536f1e275
20+
id: changed-files
21+
with:
22+
files_ignore: |
23+
docs/**
24+
**/*.md
25+
tests/performance/**
26+
OWNERS
27+
CODEOWNERS
28+
sec-scanners-config.yaml
29+
.reuse/**
30+
external-images.yaml
31+
32+
lint:
33+
name: Lint
34+
runs-on: ubuntu-latest
35+
needs: [ changed-files ]
36+
if: ${{ needs.changed-files.outputs.any_modified }}
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
ref: ${{ github.event.pull_request.head.sha }}
41+
fetch-depth: 0
42+
- uses: actions/setup-go@v5
43+
with:
44+
go-version-file: "go.mod"
45+
cache: false # We need to disable caching here, since this is handled by the golangci-lint action
46+
- name: golangci-lint
47+
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 #v6.1.0
48+
with:
49+
version: 'latest'
50+
args: --timeout=10m --verbose
51+
52+
run-unit-tests:
53+
name: Run unit tests
54+
runs-on: ubuntu-latest
55+
needs: [ changed-files ]
56+
if: ${{ needs.changed-files.outputs.any_modified }}
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
ref: ${{ github.event.pull_request.head.sha }}
61+
fetch-depth: 0
62+
- uses: actions/setup-go@v5
63+
with:
64+
go-version-file: "go.mod"
65+
- name: Run tests
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
run: |
69+
PULL_PULL_SHA=${{ github.event.pull_request.head.sha}} \
70+
PULL_BASE_SHA=${{ github.event.pull_request.base.sha}} \
71+
PULL_NUMBER=${{ github.event.number }} \
72+
./tests/integration/scripts/code-coverage-guard.sh
73+
74+
run-unit-tests-experimental:
75+
name: Run unit tests with experimental build tag
76+
if: ${{ needs.changed-files.outputs.any_modified }}
77+
needs: [ changed-files ]
78+
runs-on: ubuntu-latest
79+
steps:
80+
- uses: actions/checkout@v4
81+
with:
82+
ref: ${{ github.event.pull_request.head.sha }}
83+
fetch-depth: 0
84+
- uses: actions/setup-go@v5
85+
with:
86+
go-version-file: "go.mod"
87+
- name: Run tests
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
run: make test-experimental-tag

.github/workflows/release-pr.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
unit-tests:
3838
name: Dispatch unit test
39-
uses: ./.github/workflows/call-unit-lint.yaml
39+
uses: ./.github/workflows/call-unit-lint-head-ref.yaml
4040
if: github.event.pull_request.draft == false
4141
secrets: inherit
4242

0 commit comments

Comments
 (0)