-
Notifications
You must be signed in to change notification settings - Fork 19
212 lines (185 loc) · 6.85 KB
/
kind.yml
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Framework KinD Workflow
on:
workflow_call:
inputs:
hub_only_component:
required: false
type: string
default: 'false'
env:
RELEASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name || 'main' }}
defaults:
run:
shell: bash
jobs:
tests:
name: Tests # Part of the check name, be careful when changing.
runs-on: ubuntu-latest
env:
REGISTRY: localhost:5000
KIND_VERSION: ${{ matrix.kind }}
HOSTED: ${{ matrix.hosted }}
deployOnHub: ${{ matrix.deployOnHub }}
strategy:
# Don't skip all tests if one fails - others may still have useful info
fail-fast: false
matrix:
# Run tests against an old and a new version of kubernetes
# (for reference, OCP 4.6 runs Kubernetes v1.19)
# KinD tags are listed at https://hub.docker.com/r/kindest/node/tags
kind:
- 'minimum' # defined in the common makefile
- 'latest'
deployOnHub:
- 'true'
- 'false'
hosted:
- 'hosted'
- '' # empty strings won't appear in the check name
# Just add one hosted mode test.
exclude:
- hosted: 'hosted'
include:
- kind: 'latest'
deployOnHub: 'false'
hosted: 'hosted'
steps:
- name: Checkout Component Repository
# Checkout a specific component when called from another repository
if: ${{ github.event.repository.name != 'governance-policy-framework' }}
uses: actions/checkout@v4
with:
# `repository` is inferred as the "caller" repository
path: component
# `ref` is inferred as the new commit in the "caller" repository
- name: Checkout Policy Framework
# Checkout a stable branch when called from another repository
if: ${{ github.event.repository.name != 'governance-policy-framework' }}
uses: actions/checkout@v4
with:
repository: stolostron/governance-policy-framework
path: framework
ref: ${{ env.RELEASE_BRANCH }} # like main or release-*
- name: Checkout Policy Framework
# Checkout like "usual" when called from this repository
if: ${{ github.event.repository.name == 'governance-policy-framework' }}
uses: actions/checkout@v4
with:
# `repository` is inferred as the "caller" repository
path: framework
# `ref` is inferred as the new commit
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: framework/go.mod
cache-dependency-path: framework/go.sum
- name: Verify modules
if: ${{ github.event.repository.name == 'governance-policy-framework' }}
working-directory: framework
run: |
go mod verify
- name: Verify format
if: ${{ github.event.repository.name == 'governance-policy-framework' }}
working-directory: framework
run: |
make fmt
git diff --exit-code
make lint
- name: Bootstrap the KinD Cluster
working-directory: framework
env:
CALLER_REPO: ${{ github.event.organization.login }}
run: |
echo "::group::make e2e-dependencies"
./build/download-clis.sh
make e2e-dependencies
echo "::endgroup::"
echo "::group::bootstrap"
if [[ "${HOSTED}" == "hosted" ]]; then
make kind-bootstrap-hosted
else
make kind-bootstrap-cluster
fi
echo "::endgroup::"
echo "::group::pods on hub"
KUBECONFIG=$(pwd)/kubeconfig_hub kubectl get pods -A
echo "::endgroup::"
echo "::group::pods on managed"
KUBECONFIG=$(pwd)/kubeconfig_managed kubectl get pods -A
echo "::endgroup::"
echo "::group::Saving kubeconfig paths for use in other steps"
echo "MANAGED_KUBECONFIG=$(pwd)/kubeconfig_managed" | tee -a $GITHUB_ENV
echo "HUB_KUBECONFIG=$(pwd)/kubeconfig_hub" | tee -a $GITHUB_ENV
echo "HUB_INTERNAL_KUBECONFIG=$(pwd)/kubeconfig_hub_internal" | tee -a $GITHUB_ENV
echo "::endgroup::"
- name: Patch Component Image
if: ${{ github.event.repository.name != 'governance-policy-framework' }}
working-directory: component
env:
HUB_ONLY: ${{ inputs.hub_only_component }}
run: |
export MANAGED_CONFIG=${MANAGED_KUBECONFIG}
export HUB_CONFIG=${HUB_KUBECONFIG}
export HUB_CONFIG_INTERNAL=${HUB_INTERNAL_KUBECONFIG}
if [[ "${HOSTED}" == "hosted" ]]; then
if [[ "${HUB_ONLY}" == "true" ]]; then
export KIND_NAMESPACE=open-cluster-management
else
export KIND_NAMESPACE=cluster2-hosted
fi
export WATCH_NAMESPACE=cluster2-hosted
export KIND_NAME=policy-addon-ctrl1
export KUBECONFIG=${HUB_KUBECONFIG}
elif [[ "${deployOnHub}" == "true" ]] || [[ "${HUB_ONLY}" == "true" ]]; then
export WATCH_NAMESPACE=managed
export KIND_NAME=hub
export KUBECONFIG=${HUB_KUBECONFIG}
else
export WATCH_NAMESPACE=managed
export KIND_NAME=managed
export KUBECONFIG=${MANAGED_KUBECONFIG}
fi
echo "Using TAG=${TAG}, WATCH_NAMESPACE=${WATCH_NAMESPACE}, KIND_NAME=${KIND_NAME}, KUBECONFIG=${KUBECONFIG}"
echo "::group::make build-images"
make build-images
echo "::endgroup::"
echo "::group::make kind-deploy-controller-dev"
make kind-deploy-controller-dev
echo "::endgroup::"
- name: Run e2e tests
working-directory: framework
env:
TEST_ARGS: --fail-fast --json-report=report.json --junit-report=report.xml --output-dir=test-output
UPSTREAM_TEST: ${{ github.event.organization.login == 'open-cluster-management-io' }}
run: |
if [[ "${HOSTED}" == "hosted" ]]; then
make e2e-test-hosted
else
make e2e-test
fi
- name: Debug
if: ${{ failure() }}
working-directory: framework
run: |
if [[ "${HOSTED}" == "hosted" ]]; then
KIND_MANAGED_NAMESPACE=cluster2-hosted \
MANAGED_CLUSTER_NAME=hub \
make e2e-debug-acm
else
make e2e-debug-kind
fi
tar -czvf e2e-debug.tar.gz test-output/debug
- name: Upload Debug Artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: fw-kind-debug-${{ matrix.kind }}-${{ matrix.deployOnHub }}${{ matrix.hosted == 'hosted' && '-hosted' || '' }}
path: framework/e2e-debug.tar.gz
- name: Upload Test Reports
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: fw-kind-report-${{ matrix.kind }}-${{ matrix.deployOnHub }}${{ matrix.hosted == 'hosted' && '-hosted' || '' }}
path: |
framework/test-output/report.xml
framework/test-output/report.json