Skip to content

Commit 7f5d48c

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

File tree

3 files changed

+67
-18
lines changed

3 files changed

+67
-18
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ on:
2828
pool-namespace:
2929
type: string
3030
default: 'official'
31+
gitRef:
32+
type: string
33+
default: ${{github.event.workflow_run.head_sha}}
3134

3235
jobs:
3336
run-integration-tests:
@@ -40,7 +43,7 @@ jobs:
4043
- name: Checkout cli
4144
uses: actions/checkout@v4
4245
with:
43-
ref: ${{github.event.workflow_run.head_sha}}
46+
ref: ${{inputs.gitRef}}
4447

4548
- name: Checkout cli-ci
4649
uses: actions/checkout@v4
Lines changed: 63 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +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
1915
- run-integration-tests-cf-env-with-client-creds
2016
# - run-integration-tests-cf-env-with-min-capi
2117
- run-cats-cf-env
22-
workflow_run:
23-
workflows:
24-
- "Tests"
25-
types:
26-
- completed
2718
push:
19+
tags:
20+
- "v9.*"
21+
- "v8.*"
22+
- "v7.*"
23+
pull_request_target:
2824
branches:
2925
- main
26+
- v9
3027
- v8
3128
- v7
32-
29+
paths-ignore:
30+
- "doc/**"
31+
- ".gitpod.yml"
32+
- "README.md"
3333
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
3468
run-integration-tests-cf-env:
3569
name: Integration tests
36-
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' }}
3774
uses: ./.github/workflows/tests-integration-reusable.yml
3875
with:
3976
capi-version: edge
4077
run-with-client-creds: false
4178
os: ubuntu-latest
4279
name: Integration
80+
gitRef: ${{needs.get-sha.outputs.gitRef}}
4381
secrets: inherit
4482

4583
run-integration-tests-cf-env-with-client-creds:
4684
name: client creds
47-
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' }}
4889
uses: ./.github/workflows/tests-integration-reusable.yml
4990
with:
5091
capi-version: edge
5192
run-with-client-creds: true
5293
os: ubuntu-latest
5394
name: Integration client creds
95+
gitRef: ${{needs.get-sha.outputs.gitRef}}
5496
secrets: inherit
5597

5698
# run-integration-tests-cf-env-with-min-capi:
5799
# name: MIN CAPI
58-
# 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' }}
59104
# uses: ./.github/workflows/tests-integration-reusable.yml
60105
# with:
61106
# capi-version: min
@@ -70,13 +115,15 @@ jobs:
70115
run-cats-cf-env:
71116
name: CATS
72117
needs:
118+
- get-sha
73119
- run-integration-tests-cf-env
74120
- run-integration-tests-cf-env-with-client-creds
75-
if: ${{ inputs.workflow == 'all' || inputs.workflow == 'run-cats-cf-env' }}
121+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.workflow == 'all' || inputs.workflow == 'run-cats-cf-env' }}
76122
uses: ./.github/workflows/tests-integration-reusable.yml
77123
with:
78124
capi-version: edge
79125
run-with-client-creds: false
80126
os: ubuntu-latest
81127
name: cats
128+
gitRef: ${{needs.get-sha.outputs.gitRef}}
82129
secrets: inherit

.github/workflows/tests-unit.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,4 @@ jobs:
8383
Get-Command make
8484
Get-Item Makefile
8585
make units
86-
8786
# vim: set sw=2 ts=2 sts=2 et tw=78 foldlevel=2 fdm=indent nospell:

0 commit comments

Comments
 (0)