generated from crossplane/upjet-provider-template
-
Notifications
You must be signed in to change notification settings - Fork 19
180 lines (155 loc) · 6.66 KB
/
uptest-trigger.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
# SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
#
# SPDX-License-Identifier: CC0-1.0
name: End to End Testing
on:
issue_comment:
types: [created]
env:
GO_VERSION: "1.23"
jobs:
debug:
runs-on: ubuntu-latest
steps:
- name: Debug
run: |
echo "Trigger keyword: '/test-examples'"
echo "Go version: ${{ env.GO_VERSION }}"
echo "github.event.comment.author_association: ${{ github.event.comment.author_association }}"
get-example-list:
if: ${{ (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' ) &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '/test-examples' ) }}
runs-on: ubuntu-latest
outputs:
example_list: ${{ steps.get-example-list-name.outputs.example-list }}
example_hash: ${{ steps.get-example-list-name.outputs.example-hash }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
- name: Checkout PR
id: checkout-pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout ${{ github.event.issue.number }}
git submodule update --init --recursive
OUTPUT=$(git log -1 --format='%H')
echo "commit-sha=$OUTPUT" >> $GITHUB_OUTPUT
- name: Prepare The Example List
env:
COMMENT: ${{ github.event.comment.body }}
id: get-example-list-name
run: |
PATHS=$(echo $COMMENT | sed 's/^.*\/test-examples="//g' | cut -d '"' -f 1 | sed 's/,/ /g')
EXAMPLE_LIST=""
for P in $PATHS; do EXAMPLE_LIST="${EXAMPLE_LIST},$(find $P -name '*.yaml' | tr '\n' ',')"; done
sudo apt-get -y install coreutils
COUNT=$(echo ${EXAMPLE_LIST:1} | grep -o ".yaml" | wc -l)
if [ $COUNT -gt 1 ]; then EXAMPLE_HASH=$(echo ${EXAMPLE_LIST} | md5sum | cut -f1 -d" "); else EXAMPLE_HASH=$(echo ${EXAMPLE_LIST:1} | sed 's/.$//'); fi
echo "Examples: ${EXAMPLE_LIST:1}"
echo "Example Hash: ${EXAMPLE_HASH}"
echo "example-list=${EXAMPLE_LIST:1}" >> $GITHUB_OUTPUT
echo "example-hash=${EXAMPLE_HASH}" >> $GITHUB_OUTPUT
- name: Create Pending Status Check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/statuses/${{ steps.checkout-pr.outputs.commit-sha }} \
-f state='pending' \
-f target_url='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
-f description='Running...' \
-f context="Uptest-${{ steps.get-example-list-name.outputs.example-hash }}"
uptest:
if: ${{ (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' ) &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '/test-examples' ) }}
runs-on: ubuntu-latest
needs: get-example-list
steps:
- name: Cleanup Disk
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
large-packages: false
swap-storage: false
- name: Setup QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
with:
platforms: all
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
- name: Setup Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout PR
id: checkout-pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout ${{ github.event.issue.number }}
git submodule update --init --recursive
OUTPUT=$(git log -1 --format='%H')
echo "commit-sha=$OUTPUT" >> $GITHUB_OUTPUT
- name: Vendor Dependencies
run: make vendor vendor.check
- name: Run Uptest
id: run-uptest
env:
UPTEST_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_CLOUD_CREDENTIALS }}
UPTEST_EXAMPLE_LIST: ${{ needs.get-example-list.outputs.example_list }}
UPTEST_TEST_DIR: ./_output/controlplane-dump
UPTEST_DATASOURCE_PATH: .work/uptest-datasource.yaml
UPTEST_UPDATE_PARAMETER: ""
run: |
mkdir -p .work && echo "${{ secrets.UPTEST_DATASOURCE }}" > .work/uptest-datasource.yaml
make e2e
- name: Create Successful Status Check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXAMPLE_HASH: ${{ needs.get-example-list.outputs.example_hash }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/statuses/${{ steps.checkout-pr.outputs.commit-sha }} \
-f state='success' \
-f target_url='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
-f description='Passed' \
-f context="Uptest-${EXAMPLE_HASH}"
- name: Collect Cluster Dump
if: always()
run: |
make controlplane.dump
- name: Upload Cluster Dump
if: always()
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: controlplane-dump
path: ./_output/controlplane-dump
- name: Cleanup
if: always()
run: |
eval $(make --no-print-directory build.vars)
${KUBECTL} delete managed --all || true
- name: Create Unsuccessful Status Check
if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXAMPLE_HASH: ${{ needs.get-example-list.outputs.example_hash }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/statuses/${{ steps.checkout-pr.outputs.commit-sha }} \
-f state='failure' \
-f target_url='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
-f description='Failed' \
-f context="Uptest-${EXAMPLE_HASH}"