forked from vmware-tanzu/tanzu-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (188 loc) · 7.26 KB
/
tkg_integration_tests.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
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
213
name: TKG Integration Tests
on:
pull_request:
branches: [ main, release-* ]
paths:
- 'pkg/v1/tkg/**'
- '!packageclients/**'
- '!cmd/cli/plugin/package/test/**'
- 'pkg/v1/providers/**'
- '.github/workflows/tkg_integration_tests.yaml'
concurrency:
group: ${{ format('integration-tests-{0}', github.head_ref) }}
cancel-in-progress: true
jobs:
integ-tests-docker:
name: TKG Integration Tests CAPD
runs-on: tkg
steps:
- name: Free disk space and clean up installed plugins on runner
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /home/tanzu/.cache
sudo rm -rf /home/tanzu/.kube
sudo rm -rf /home/tanzu/.local/share/tanzu-cli/*
sudo sh -c 'find /tmp -type d -name "go-build*" -mtime +3 | xargs rm -rf'
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: '1.17'
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: go cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build Tools
run: make tools
- name: Extract PR Number
uses: Dovyski/payload-info-action@master
id: get_pr_num
with:
# when event is a pull request, obtaining the PR number is obvious
filter_pull_request: '.number'
# when event is a push (merge of PR), since we require linear history,
# we are not even generating a merge commit that can help identify the
# PR number, so don't even try. Instead we just hard-code to a dummy
# value.
filter_push: 1009
- name: Find Comment
uses: peter-evans/find-comment@v1
id: findcomment
with:
issue-number: ${{ steps.get_pr_num.outputs.value }}
body-includes: //usebom
direction: last
- name: Extract Alternate BOM
shell: bash
run: |
export BOMCOMMENT=$(echo -e "${{ steps.findcomment.outputs.comment-body }}" | tr -d "[:space:]")
echo "##[set-output name=bompath;]$(echo "$BOMCOMMENT" | awk -F : '{print $2}')"
id: extract_bom
- name: Cleanup
run: rm -rf ~/.tanzu ~/.tkg ~/.config; docker kill $(docker ps -q) | true; docker system prune -a --volumes -f
- name: Run TKG integration tests
run: |
if [[ ! -z "${{ steps.extract_bom.outputs.bompath }}" ]]; then
export TKG_DEFAULT_COMPATIBILITY_IMAGE_PATH=${{ steps.extract_bom.outputs.bompath }}
fi
make configure-bom
make generate-embedproviders
E2E_CONFIG=$PWD/pkg/v1/tkg/test/config/docker.yaml hack/tools/bin/ginkgo -nodes=3 -v -trace -tags embedproviders pkg/v1/tkg/test/tkgctl/docker
integ-tests-azure:
name: TKG Integration Tests CAPZ
runs-on: ubuntu-latest
env:
azure_client_id: ${{secrets.AZURE_CLIENT_ID_SAIB}}
steps:
- name: Free disk space and clean up installed plugins on runner
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /home/tanzu/.cache
sudo rm -rf /home/tanzu/.kube
sudo rm -rf /home/tanzu/.local/share/tanzu-cli/*
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: '1.17'
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: go cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build Tools
run: make tools
- name: Extract PR Number
uses: Dovyski/payload-info-action@master
id: get_pr_num
with:
# when event is a pull request, obtaining the PR number is obvious
filter_pull_request: '.number'
# when event is a push (merge of PR), since we require linear history,
# we are not even generating a merge commit that can help identify the
# PR number, so don't even try. Instead we just hard-code to a dummy
# value.
filter_push: 1009
- name: Find Comment
uses: peter-evans/find-comment@v1
id: findcomment
with:
issue-number: ${{ steps.get_pr_num.outputs.value }}
body-includes: //usebom
direction: last
- name: Extract Alternate BOM
shell: bash
run: |
export BOMCOMMENT=$(echo -e "${{ steps.findcomment.outputs.comment-body }}" | tr -d "[:space:]")
echo "##[set-output name=bompath;]$(echo "$BOMCOMMENT" | awk -F : '{print $2}')"
id: extract_bom
- name: Cleanup
run: rm -rf ~/.tanzu ~/.tkg ~/.config; docker kill $(docker ps -q) | true; docker system prune -a --volumes -f
- name: Generate cluster prefix
if: ${{ env.azure_client_id != '' }}
env:
NUM: ${{ github.run_number }}
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
echo ::set-env name=CLUSTER_PREFIX::"github-$NUM-"
- uses: microsoft/variable-substitution@v1
if: ${{ env.azure_client_id != '' }}
with:
files: 'pkg/v1/tkg/test/config/azure.yaml'
env:
tkg_config_variables.AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID_SAIB }}
tkg_config_variables.AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID_SAIB }}
tkg_config_variables.AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID_SAIB }}
tkg_config_variables.AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET_SAIB }}
cluster_prefix: ${{ env.CLUSTER_PREFIX }}
- run: |
cat pkg/v1/tkg/test/config/azure.yaml
- name: Run TKG integration tests
if: ${{ env.azure_client_id != '' }}
run: |
if [[ ! -z "${{ steps.extract_bom.outputs.bompath }}" ]]; then
export TKG_DEFAULT_COMPATIBILITY_IMAGE_PATH=${{ steps.extract_bom.outputs.bompath }}
fi
make configure-bom
make generate-embedproviders
E2E_CONFIG=$PWD/pkg/v1/tkg/test/config/azure.yaml hack/tools/bin/ginkgo -nodes=3 -v -trace -tags embedproviders pkg/v1/tkg/test/tkgctl/azure
- uses: Azure/[email protected]
if: ${{ always() && env.azure_client_id != '' }}
with:
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID_SAIB }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET_SAIB }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID_SAIB }}","tenantId":"${{ secrets.AZURE_TENANT_ID_SAIB }}"}'
- name: Cleanup Azure resources
if: ${{ always() }}
run: |
for rgname in `az group list --query "[? contains(name,'${cluster_prefix}')][].{name:name}" -o tsv`; do
echo Deleting ${rgname}
az group delete -n ${rgname} --yes --no-wait
done
env:
cluster_prefix: ${{ env.CLUSTER_PREFIX }}