-
Notifications
You must be signed in to change notification settings - Fork 2.4k
220 lines (201 loc) · 7.78 KB
/
nightly-install.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
214
215
216
217
218
219
name: Nightly Install
on:
push:
branches:
- []
# schedule:
# - cron: "0 0 * * 1-5"
workflow_dispatch: {}
permissions:
contents: read
jobs:
test:
name: "Smoke Test"
runs-on: ubuntu-latest
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
channel: [stable, latest]
vm: [rocky-8, fedora, opensuse-leap, ubuntu-2204]
max-parallel: 4
defaults:
run:
working-directory: tests/install/${{ matrix.vm }}
env:
INSTALL_K3S_CHANNEL: ${{ matrix.channel }}
LOG_FILE: /tmp/k3s-install-test-results.log
steps:
- name: "Checkout"
uses: actions/checkout@v4
with: {fetch-depth: 1}
- name: Set up vagrant and libvirt
uses: ./.github/actions/vagrant-setup
- name: "Vagrant Cache"
uses: actions/cache@v4
with:
path: |
~/.vagrant.d/boxes
key: vagrant-box-${{ matrix.vm }}
id: vagrant-cache
- name: "Vagrant Plugin(s)"
run: vagrant plugin install vagrant-k3s vagrant-reload
- name: "Vagrant Up ⏩ Install K3s"
run: |
if vagrant up; then
echo "Vagrant Up ⏩ Install K3s: success" | tee -a ${{ env.LOG_FILE }}
else
echo "Vagrant Up ⏩ Install K3s: failure" | tee -a ${{ env.LOG_FILE }}
exit 1
fi
- name: "⏳ Node"
run: |
if vagrant provision --provision-with=k3s-wait-for-node; then
echo "Node provision: success" | tee -a ${{ env.LOG_FILE }}
else
echo "Node provision: failure" | tee -a ${{ env.LOG_FILE }}
exit 1
fi
- name: "⏳ CoreDNS"
run: |
if vagrant provision --provision-with=k3s-wait-for-coredns; then
echo "CoreDNS provision: success" | tee -a ${{ env.LOG_FILE }}
else
echo "CoreDNS provision: failure" | tee -a ${{ env.LOG_FILE }}
exit 1
fi
- name: "⏳ Local Storage"
run: |
vagrant provision --provision-with=k3s-wait-for-local-storage && \
echo "Local Storage provision: success" | tee -a ${{ env.LOG_FILE }} || \
echo "Local Storage provision: failure" | tee -a ${{ env.LOG_FILE }}
continue-on-error: true
- name: "⏳ Metrics Server"
run: |
vagrant provision --provision-with=k3s-wait-for-metrics-server && \
echo "Metrics Server provision: success" | tee -a ${{ env.LOG_FILE }} || \
echo "Metrics Server provision: failure" | tee -a ${{ env.LOG_FILE }}
continue-on-error: true
- name: "⏳ Traefik"
run: |
vagrant provision --provision-with=k3s-wait-for-traefik && \
echo "Traefik provision: success" | tee -a ${{ env.LOG_FILE }} || \
echo "Traefik provision: failure" | tee -a ${{ env.LOG_FILE }}
continue-on-error: true
- name: "k3s-status"
run: |
if vagrant provision --provision-with=k3s-status; then
echo "k3s-status: success" | tee -a ${{ env.LOG_FILE }}
else
echo "k3s-status: failure" | tee -a ${{ env.LOG_FILE }}
exit 1
fi
- name: "k3s-procps"
run: |
if vagrant provision --provision-with=k3s-procps; then
echo "k3s-procps: success" | tee -a ${{ env.LOG_FILE }}
else
echo "k3s-procps: failure" | tee -a ${{ env.LOG_FILE }}
exit 1
fi
- name: "Qase Results environment setup"
if: always()
env:
QASE_RUN_NAME: "K3s Nightly Install-${{ matrix.vm }}(${{ matrix.channel }})"
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
PROJECT_CODE: "K3SRKE2"
CASE_ID_LIST: "108,109,110,111,112,113,114,115"
run: |
echo "QASE_RUN_NAME=${{ env.QASE_RUN_NAME }}" >> $GITHUB_ENV
echo "PROJECT_CODE=${{ env.PROJECT_CODE }}" >> $GITHUB_ENV
echo "CASE_ID_LIST=${{ env.CASE_ID_LIST }}" >> $GITHUB_ENV
- name: "Create Qase Run"
if: always()
id: create-qase-run
env:
QASE_RUN_NAME: ${{ env.QASE_RUN_NAME }}
CASE_ID_LIST: ${{ env.CASE_ID_LIST }}
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
run: |
# Create a run ID
RUN_ID_RESPONSE=$(curl --request POST \
--url "https://api.qase.io/v1/run/$PROJECT_CODE" \
--header "Token: $QASE_API_TOKEN" \
--header "accept: application/json" \
--header "content-type: application/json" \
--data '{
"cases": ['"$CASE_ID_LIST"'],
"title": "'"$QASE_RUN_NAME"'"
}')
echo "Run ID response: $RUN_ID_RESPONSE"
# set the run ID as an output variable
RUN_ID=$(echo $RUN_ID_RESPONSE | jq -r '.result.id')
if [ -z "$RUN_ID" ] || [ "$RUN_ID" == "null" ]; then
echo "Failed to create Qase run"
fi
# Set the run ID as an output variable using the environment file
echo "QASE_RUN_ID=$RUN_ID" >> $GITHUB_ENV
continue-on-error: true
- name: Process Test Results
if: always()
id: process-test-results
env:
CASE_ID_LIST: ${{ env.CASE_ID_LIST }}
run: |
GITHUB_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
COMMENT_LINK="In case of failure in GitHub Actions run. See details here: $GITHUB_RUN_URL"
IFS=',' read -r -a CASE_IDS <<< "$CASE_ID_LIST"
COUNTER=0
results='[]'
while IFS= read -r line; do
TEST_NAME=$(echo "$line" | awk -F': ' '{print $1}')
TEST_STATUS=$(echo "$line" | awk -F': ' '{print $2}')
TEST_CASE_ID=${CASE_IDS[$COUNTER]}
COUNTER=$((COUNTER + 1))
if [ $COUNTER -ge ${#CASE_IDS[@]} ]; then
COUNTER=0
fi
if [ "$TEST_STATUS" == "success" ]; then
STATUS="passed"
else
STATUS="failed"
fi
results=$(echo "$results" | jq --arg case_id "$TEST_CASE_ID" --arg status "$STATUS" --arg comment "$COMMENT_LINK" \
'. + [{ "case_id": ($case_id|tonumber), "status": $status, "comment": $comment }]')
done < /tmp/k3s-install-test-results.log
echo "$results" > results.json
continue-on-error: true
- name: Publish Test Results
if: always()
env:
RUN_ID: ${{ env.QASE_RUN_ID }}
PROJECT_CODE: ${{ env.PROJECT_CODE }}
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
run: |
results=$(cat results.json)
RESPONSE=$(curl --request POST \
--url "https://api.qase.io/v1/result/${PROJECT_CODE}/${RUN_ID}/bulk" \
--header "Token: $QASE_API_TOKEN" \
--header 'accept: application/json' \
--header "Content-Type: application/json" \
--data "{\"results\": $results}")
echo "Publish test results response: $RESPONSE"
continue-on-error: true
- name: Complete Qase Run
if: always()
env:
RUN_ID: ${{ env.QASE_RUN_ID }}
PROJECT_CODE: ${{ env.PROJECT_CODE }}
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
run: |
COMPLETE_RUN=$(curl --request POST \
--url "https://api.qase.io/v1/run/${PROJECT_CODE}/${RUN_ID}/complete" \
--header "Token: $QASE_API_TOKEN" \
--header 'accept: application/json')
RUN_STATUS=$(echo $COMPLETE_RUN | jq -r '.status')
if [[ $RUN_STATUS != true ]]; then
echo "Failed to complete the run"
else
echo "Run completed successfully"
fi
continue-on-error: true