Skip to content

Commit b9a3ff0

Browse files
Choose the correct commit sha when running unit tests (#3078)
Signed-off-by: João Pereira <[email protected]>
1 parent feadf1a commit b9a3ff0

File tree

3 files changed

+70
-22
lines changed

3 files changed

+70
-22
lines changed

.github/workflows/tests-integration-reusable.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ on:
2828
pool-namespace:
2929
type: string
3030
default: 'official'
31+
gitRef:
32+
type: string
33+
default: ${{github.event.workflow_run.head_sha}}
34+
3135
jobs:
3236
run-integration-tests:
3337
defaults:
@@ -39,7 +43,7 @@ jobs:
3943
- name: Checkout cli
4044
uses: actions/checkout@v4
4145
with:
42-
ref: ${{github.event.workflow_run.head_sha}}
46+
ref: ${{inputs.gitRef}}
4347

4448
- name: Checkout cli-ci
4549
uses: actions/checkout@v4

.github/workflows/tests-integration.yml

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,106 @@
11
name: "Tests: Integration"
22

3-
run-name: "Integration [${{ github.event.workflow_run.head_branch }}]: ${{ github.event.workflow_run.head_commit.message }}"
3+
run-name: "Integration [${{ github.event_name }}: ${{ github.event.pull_request.head.sha || github.event.push.after || github.event.workflow_run.head_sha}}]: ${{ github.event.workflow_run.head_commit.message }}"
44

55
on:
6-
workflow_call:
7-
inputs:
8-
workflow:
9-
default: all
10-
type: string
116
workflow_dispatch:
127
inputs:
138
workflow:
149
description: Tests to run
1510
required: true
1611
type: choice
1712
options:
13+
- all
1814
- run-integration-tests-cf-env
19-
- run-integration-tests-cf-env-with-client-creds
2015
# - run-integration-tests-cf-env-with-min-capi
2116
# - run-integration-windows
2217
# - run-integration-windows-client-credentials
18+
push:
19+
tags:
20+
- "v9.*"
21+
- "v8.*"
22+
- "v7.*"
23+
pull_request_target:
24+
branches:
25+
- main
26+
- v9
27+
- v8
28+
- v7
29+
paths-ignore:
30+
- "doc/**"
31+
- ".gitpod.yml"
32+
- "README.md"
2333
jobs:
34+
get-sha:
35+
runs-on: ubuntu-latest
36+
outputs:
37+
gitRef: ${{steps.calculate.outputs.ref}}
38+
steps:
39+
- id: calculate
40+
run: |
41+
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
42+
echo "checkout pull request head ${{ github.event.pull_request.head.sha }}"
43+
echo "ref=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
44+
elif [[ "${{ github.event_name }}" == "push" ]]; then
45+
echo "checkout push request ${{github.event.push.after}}"
46+
echo "ref=${{github.event.push.after}}" >> $GITHUB_OUTPUT
47+
else
48+
echo "checkout else ${{ github.event.workflow_run.head_sha }}"
49+
echo "ref=${{github.event.workflow_run.head_sha}}" >> $GITHUB_OUTPUT
50+
fi
51+
units:
52+
name: Basic units to gate for integration tests
53+
runs-on: ubuntu-latest
54+
needs:
55+
- get-sha
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
with:
60+
ref: ${{needs.get-sha.outputs.gitRef}}
61+
- name: Set Up Go
62+
uses: actions/setup-go@v5
63+
with:
64+
go-version-file: go.mod
65+
check-latest: true
66+
- name: Run Units
67+
run: make units
2468
run-integration-tests-cf-env:
2569
name: Integration tests
26-
if: ${{ inputs.workflow == 'all' || inputs.workflow == 'run-integration-tests-cf-env' }}
70+
needs:
71+
- get-sha
72+
- units
73+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.workflow == 'all' || inputs.workflow == 'run-integration-tests-cf-env' }}
2774
uses: ./.github/workflows/tests-integration-reusable.yml
2875
with:
2976
capi-version: edge
3077
run-with-client-creds: false
3178
os: ubuntu-latest
3279
name: Integration
80+
gitRef: ${{needs.get-sha.outputs.gitRef}}
3381
secrets: inherit
3482

3583
run-integration-tests-cf-env-with-client-creds:
3684
name: client creds
37-
if: ${{ inputs.workflow == 'all' || inputs.workflow == 'run-integration-tests-cf-env-with-client-creds' }}
85+
needs:
86+
- get-sha
87+
- units
88+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.workflow == 'all' || inputs.workflow == 'run-integration-tests-cf-env-with-client-creds' }}
3889
uses: ./.github/workflows/tests-integration-reusable.yml
3990
with:
4091
capi-version: edge
4192
run-with-client-creds: true
4293
os: ubuntu-latest
4394
name: Integration client creds
95+
gitRef: ${{needs.get-sha.outputs.gitRef}}
4496
secrets: inherit
4597

4698
#run-integration-tests-cf-env-with-min-capi:
4799
# name: MIN CAPI
48-
# if: ${{ inputs.workflow == 'all' || inputs.workflow == 'run-integration-tests-cf-env-with-min-capi' }}
100+
# needs:
101+
# - get-sha
102+
# - units
103+
# if: ${{ github.event_name != 'workflow_dispatch' ||inputs.workflow == 'all' || inputs.workflow == 'run-integration-tests-cf-env-with-min-capi' }}
49104
# uses: ./.github/workflows/tests-integration-reusable.yml
50105
# with:
51106
# capi-version: min

.github/workflows/tests-unit.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,4 @@ jobs:
8383
Get-Command make
8484
Get-Item Makefile
8585
make units
86-
87-
88-
89-
integration:
90-
needs:
91-
- units
92-
- units-windows
93-
name: Integration tests
94-
if: ${{ github.event != 'workflow_dispatch' }}
95-
uses: ./.github/workflows/tests-integration.yml
96-
secrets: inherit
9786
# vim: set sw=2 ts=2 sts=2 et tw=78 foldlevel=2 fdm=indent nospell:

0 commit comments

Comments
 (0)