-
Notifications
You must be signed in to change notification settings - Fork 5
140 lines (134 loc) · 5.73 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: test base images
on:
pull_request_target:
types:
- labeled
- opened
- synchronize
pull_request_review:
types: [submitted]
# Enable manual invocation of this workflow GitHub Actions GUI
workflow_dispatch:
inputs:
os:
description: "The OS to run the integration test with"
type: choice
required: true
options:
- all
- ubuntu-20
- ubuntu-22
- os-ubuntu
- rocky-8.7
- rocky-9.1
- os-rocky
- centos-7.9
- os-centos
- rhel-7.9
- rhel-8.4
- rhel-8.6
- rhel-8.8
- rhel-8.10
- rhel-9.4
- os-rhel
- oraclelinux-9.4
- os-oraclelinux
- flatcar-3033.3.16
- os-flatcar
env:
VSPHERE_USERNAME: ${{ secrets.VSPHERE_NKP_SRE_USERNAME }}
VSPHERE_PASSWORD: ${{ secrets.VSPHERE_SRE_PASSWORD }}
VSPHERE_SERVER: ${{ secrets.VSPHERE_NKP_SERVER }}
GOVC_URL: ${{ secrets.VSPHERE_NKP_SRE_USERNAME }}:${{ secrets.VSPHERE_SRE_PASSWORD }}@${{ secrets.VSPHERE_NKP_SERVER }}
PKR_VAR_vsphere_cluster: ${{ secrets.VSPHERE_CLUSTER }}
PKR_VAR_vsphere_datacenter: ${{ secrets.VSPHERE_DATACENTER }}
PKR_VAR_vsphere_datastore: ${{ secrets.VSPHERE_NKP_DATASTORE }}
PKR_VAR_vsphere_network: ${{ secrets.VSPHERE_NKP_NETWORK }}
PKR_VAR_vsphere_resource_pool: ${{ secrets.VSPHERE_RESOURCE_POOL }}
RHN_SUBSCRIPTION_ORG: ${{ secrets.RHN_SUBSCRIPTION_ORG }}
RHN_SUBSCRIPTION_KEY: ${{ secrets.RHN_SUBSCRIPTION_KEY }}
jobs:
check-approvals:
runs-on: self-hosted-nutanix-medium
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check for required approvals and integration_test label
id: check_approvals
uses: actions/github-script@v6
with:
script: |
const prNumber = context.payload.pull_request.number;
const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
const approvedReviews = reviews.filter(review => review.state === 'APPROVED');
const requiredApprovals = 1; // Set the number of required approvals here
const labels = context.payload.pull_request.labels.map(label => label.name);
const hasIntegrationTestLabel = labels.includes('integration_test');
core.setOutput('hasRequiredApprovals', approvedReviews.length >= requiredApprovals);
core.setOutput('hasIntegrationTestLabel', hasIntegrationTestLabel);
# Build matrix to test when label integration_test is added to PR or manually invoked.
build_list:
runs-on:
- self-hosted-nutanix-medium
needs: check-approvals
strategy:
fail-fast: false
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
if: needs.check-approvals.outputs.hasRequiredApprovals == 'true' && needs.check-approvals.outputs.hasIntegrationTestLabel == 'true' || contains(fromJson('["workflow_dispatch"]'), github.event_name)
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Build OS matrix for all OS
if: contains(github.event.pull_request.labels.*.name, 'integration_test') || contains(fromJson('["workflow_dispatch"]'), github.event_name) && github.event.inputs.os == 'all'
id: build-os-matrix
run: |
DYNAMICOSLIST=$(make list-os-versions | head -c -1 | tr '\n' ',')
echo "buildmatrix=$(jq -cn --arg os_list $DYNAMICOSLIST '{os: $os_list | split(",")}')" >> $GITHUB_ENV
- name: Build OS matrix for distro (os prefix)
if: contains(fromJson('["workflow_dispatch"]'), github.event_name) && contains(github.event.inputs.os, 'os-')
id: build-os-matrix-distro
run: |
OSPREFIX=$(echo ${{ github.event.inputs.os }} | cut -d '-' -f 2)
DYNAMICOSLIST=$(make list-os-versions | grep -E "$OSPREFIX" | head -c -1 | tr '\n' ',')
echo "buildmatrix=$(jq -cn --arg os_list $DYNAMICOSLIST '{os: $os_list | split(",")}')" >> $GITHUB_ENV
- name: Build OS matrix for single OS
if: contains(fromJson('["workflow_dispatch"]'), github.event_name) && github.event.inputs.os != 'all' && !contains(github.event.inputs.os, 'os-')
id: build-os-matrix-single
run: |
echo "buildmatrix=$(jq -cn --arg os_list '${{ github.event.inputs.os }}' '{os: $os_list | split(",")}')" >> $GITHUB_ENV
- name: Empty OS matrix
id: empty-os-matrix
if: ${{ !contains(fromJson('["workflow_dispatch"]'), github.event_name) }}
run: |
echo "buildmatrix=$(jq -cn --arg os_list '' '{os: $os_list | split(",")}')" >> $GITHUB_ENV
- name: Set matrix output
id: set-matrix
run: |
echo 'matrix=${{ env.buildmatrix }}' >> $GITHUB_OUTPUT
base_image_tests:
runs-on:
- self-hosted-nutanix-medium
needs: build_list
# if matrix os is empty, skip this job
if: ${{fromJson(needs.build_list.outputs.matrix)}}.os != []
strategy:
fail-fast: false
matrix: ${{fromJson(needs.build_list.outputs.matrix)}}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Setup requirements
run: |
sudo apt-get update && sudo apt-get -y install xorriso
curl -L -o - "https://github.com/vmware/govmomi/releases/latest/download/govc_$(uname -s)_$(uname -m).tar.gz" | sudo tar -C /usr/local/bin -xvzf - govc
- name: Run integration tests for ${{ matrix.os }}
run: make ${{ matrix.os }}-test