1
1
name : Nightly Install
2
2
on :
3
- push : {}
4
- # schedule:
5
- # - cron: "0 0 * * 1-5"
6
- # workflow_dispatch: {}
3
+ schedule :
4
+ - cron : " 0 0 * * 1-5"
5
+ workflow_dispatch : {}
7
6
8
7
permissions :
9
8
contents : read
@@ -19,122 +18,200 @@ jobs:
19
18
channel : [stable, latest]
20
19
vm : [rocky-8, fedora, opensuse-leap, ubuntu-2204]
21
20
max-parallel : 4
22
- # defaults:
23
- # run:
24
- # working-directory: tests/install/${{ matrix.vm }}
21
+ defaults :
22
+ run :
23
+ working-directory : tests/install/${{ matrix.vm }}
25
24
env :
26
25
INSTALL_K3S_CHANNEL : ${{ matrix.channel }}
26
+ LOG_FILE : /tmp/k3s-install-test-results.log
27
27
steps :
28
28
- name : " Checkout"
29
29
uses : actions/checkout@v4
30
30
with : {fetch-depth: 1}
31
- # - name: Set up vagrant and libvirt
32
- # uses: ./.github/actions/vagrant-setup
33
- # - name: "Vagrant Cache"
34
- # uses: actions/cache@v4
35
- # with:
36
- # path: |
37
- # ~/.vagrant.d/boxes
38
- # key: vagrant-box-${{ matrix.vm }}
39
- # id: vagrant-cache
40
- # - name: "Vagrant Plugin(s)"
41
- # run: vagrant plugin install vagrant-k3s vagrant-reload
42
- # - name: "Vagrant Up ⏩ Install K3s"
43
- # run: vagrant up
44
- # - name: "⏳ Node"
45
- # run: vagrant provision --provision-with=k3s-wait-for-node
46
- # - name: "⏳ CoreDNS"
47
- # run: vagrant provision --provision-with=k3s-wait-for-coredns
48
- # - name: "⏳ Local Storage"
49
- # run: vagrant provision --provision-with=k3s-wait-for-local-storage
50
- # continue-on-error: true
51
- # - name: "⏳ Metrics Server"
52
- # run: vagrant provision --provision-with=k3s-wait-for-metrics-server
53
- # continue-on-error: true
54
- # - name: "⏳ Traefik"
55
- # run: vagrant provision --provision-with=k3s-wait-for-traefik
56
- # continue-on-error: true
57
- # - name: "k3s-status"
58
- # run: vagrant provision --provision-with=k3s-status
59
- # - name: "k3s-procps"
60
- # run: vagrant provision --provision-with=k3s-procps
31
+ - name : Set up vagrant and libvirt
32
+ uses : ./.github/actions/vagrant-setup
33
+ - name : " Vagrant Cache"
34
+ uses : actions/cache@v4
35
+ with :
36
+ path : |
37
+ ~/.vagrant.d/boxes
38
+ key : vagrant-box-${{ matrix.vm }}
39
+ id : vagrant-cache
40
+ - name : " Vagrant Plugin(s)"
41
+ run : vagrant plugin install vagrant-k3s vagrant-reload
42
+ - name : " Vagrant Up ⏩ Install K3s"
43
+ run : |
44
+ if vagrant up; then
45
+ echo "Vagrant Up ⏩ Install K3s: success" | tee -a ${{ env.LOG_FILE }}
46
+ else
47
+ echo "Vagrant Up ⏩ Install K3s: failure" | tee -a ${{ env.LOG_FILE }}
48
+ exit 1
49
+ fi
50
+ - name : " ⏳ Node"
51
+ run : |
52
+ if vagrant provision --provision-with=k3s-wait-for-node; then
53
+ echo "Node provision: success" | tee -a ${{ env.LOG_FILE }}
54
+ else
55
+ echo "Node provision: failure" | tee -a ${{ env.LOG_FILE }}
56
+ exit 1
57
+ fi
58
+ - name : " ⏳ CoreDNS"
59
+ run : |
60
+ if vagrant provision --provision-with=k3s-wait-for-coredns; then
61
+ echo "CoreDNS provision: success" | tee -a ${{ env.LOG_FILE }}
62
+ else
63
+ echo "CoreDNS provision: failure" | tee -a ${{ env.LOG_FILE }}
64
+ exit 1
65
+ fi
66
+ - name : " ⏳ Local Storage"
67
+ run : |
68
+ vagrant provision --provision-with=k3s-wait-for-local-storage && \
69
+ echo "Local Storage provision: success" | tee -a ${{ env.LOG_FILE }} || \
70
+ echo "Local Storage provision: failure" | tee -a ${{ env.LOG_FILE }}
71
+ continue-on-error : true
72
+ - name : " ⏳ Metrics Server"
73
+ run : |
74
+ vagrant provision --provision-with=k3s-wait-for-metrics-server && \
75
+ echo "Metrics Server provision: success" | tee -a ${{ env.LOG_FILE }} || \
76
+ echo "Metrics Server provision: failure" | tee -a ${{ env.LOG_FILE }}
77
+ continue-on-error : true
78
+ - name : " ⏳ Traefik"
79
+ run : |
80
+ vagrant provision --provision-with=k3s-wait-for-traefik && \
81
+ echo "Traefik provision: success" | tee -a ${{ env.LOG_FILE }} || \
82
+ echo "Traefik provision: failure" | tee -a ${{ env.LOG_FILE }}
83
+ continue-on-error : true
84
+ - name : " k3s-status"
85
+ run : |
86
+ if vagrant provision --provision-with=k3s-status; then
87
+ echo "k3s-status: success" | tee -a ${{ env.LOG_FILE }}
88
+ else
89
+ echo "k3s-status: failure" | tee -a ${{ env.LOG_FILE }}
90
+ exit 1
91
+ fi
92
+ - name : " k3s-procps"
93
+ run : |
94
+ if vagrant provision --provision-with=k3s-procps; then
95
+ echo "k3s-procps: success" | tee -a ${{ env.LOG_FILE }}
96
+ else
97
+ echo "k3s-procps: failure" | tee -a ${{ env.LOG_FILE }}
98
+ exit 1
99
+ fi
61
100
62
- - name : Create Qase Run
63
- id : qase
101
+ - name : " Qase Results environment setup "
102
+ if : always()
64
103
env :
104
+ QASE_RUN_NAME : " K3s Nightly Install-${{ matrix.vm }}(${{ matrix.channel }})"
65
105
QASE_API_TOKEN : ${{ secrets.QASE_API_TOKEN }}
106
+ PROJECT_CODE : " K3SRKE2"
107
+ CASE_ID_LIST : " 108,109,110,111,112,113,114,115"
66
108
run : |
67
- sudo apt-get install jq
68
- # create a QASE_RUN_NAME DINAMICALLY
69
- QASE_RUN_NAME="Install K3s on ${{ matrix.vm }}"
70
-
71
- # create a run ID
72
- RESPONSE=$(curl --request POST \
73
- --url https://api.qase.io/v1/run/DEMO \
74
- --header 'Token: $QASE_API_TOKEN' \
75
- --header 'accept: application/json' \
76
- --header 'content-type: application/json' \
77
- --data '
78
- {
79
- "cases": [
80
- 0,
81
- 1
82
- ],
83
- "is_autotest": true,
84
- "title": "'"$QASE_RUN_NAME"'",
85
- }'
86
- )
87
-
88
- # set the run ID as an output variable
89
- RUN_ID=$(echo $RESPONSE | jq -r '.result.id')
90
-
91
- # Print the RUN_ID to verify
92
- echo "The RUN_ID is: $RUN_ID"
93
-
94
- # Set the run ID as an output variable using the environment file
95
- echo "QASE_RUN_ID=$RUN_ID" >> $GITHUB_ENV
109
+ echo "QASE_RUN_NAME=${{ env.QASE_RUN_NAME }}" >> $GITHUB_ENV
110
+ echo "PROJECT_CODE=${{ env.PROJECT_CODE }}" >> $GITHUB_ENV
111
+ echo "CASE_ID_LIST=${{ env.CASE_ID_LIST }}" >> $GITHUB_ENV
112
+
113
+ - name : " Create Qase Run"
114
+ if : always()
115
+ id : create-qase-run
116
+ env :
117
+ QASE_RUN_NAME : ${{ env.QASE_RUN_NAME }}
118
+ CASE_ID_LIST : ${{ env.CASE_ID_LIST }}
119
+ QASE_API_TOKEN : ${{ secrets.QASE_API_TOKEN }}
120
+ run : |
121
+ # Create a run ID
122
+ RUN_ID_RESPONSE=$(curl --request POST \
123
+ --url "https://api.qase.io/v1/run/$PROJECT_CODE" \
124
+ --header "Token: $QASE_API_TOKEN" \
125
+ --header "accept: application/json" \
126
+ --header "content-type: application/json" \
127
+ --data '{
128
+ "cases": ['"$CASE_ID_LIST"'],
129
+ "title": "'"$QASE_RUN_NAME"'"
130
+ }')
131
+ echo "Run ID response: $RUN_ID_RESPONSE"
96
132
97
- ## step
133
+ # set the run ID as an output variable
134
+ RUN_ID=$(echo $RUN_ID_RESPONSE | jq -r '.result.id')
98
135
136
+ if [ -z "$RUN_ID" ] || [ "$RUN_ID" == "null" ]; then
137
+ echo "Failed to create Qase run"
138
+ fi
99
139
100
- # complete the run
101
- COMPLETE_RUN=$(curl --request POST \
102
- --url https://api.qase.io/v1/run/K3SRKE2/$RUN_ID/complete \
103
- --header 'Token: $QASE_API_TOKEN' \
104
- --header 'accept: application/json'
105
- )
140
+ # Set the run ID as an output variable using the environment file
141
+ echo "QASE_RUN_ID=$RUN_ID" >> $GITHUB_ENV
142
+ continue-on-error : true
143
+
144
+ - name : Process Test Results
145
+ if : always()
146
+ id : process-test-results
147
+ env :
148
+ CASE_ID_LIST : ${{ env.CASE_ID_LIST }}
149
+ run : |
150
+ GITHUB_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
151
+ COMMENT_LINK="In case of failure in GitHub Actions run. See details here: $GITHUB_RUN_URL"
152
+
153
+ IFS=',' read -r -a CASE_IDS <<< "$CASE_ID_LIST"
154
+ COUNTER=0
155
+ results='[]'
156
+
157
+ while IFS= read -r line; do
158
+ TEST_NAME=$(echo "$line" | awk -F': ' '{print $1}')
159
+ TEST_STATUS=$(echo "$line" | awk -F': ' '{print $2}')
160
+ TEST_CASE_ID=${CASE_IDS[$COUNTER]}
161
+
162
+ COUNTER=$((COUNTER + 1))
163
+ if [ $COUNTER -ge ${#CASE_IDS[@]} ]; then
164
+ COUNTER=0
165
+ fi
106
166
107
- RUN_STATUS=$(echo $COMPLETE_RUN | jq -r '.status')
108
- if [[ $RUN_STATUS != true ]]; then
109
- echo "Failed to complete the run"
110
- fi
167
+ if [ "$TEST_STATUS" == "success" ]; then
168
+ STATUS="passed"
169
+ else
170
+ STATUS="failed"
171
+ fi
111
172
112
- # # make run public
113
- # PUBLISH_RUN=$(curl --request PATCH \
114
- # --url https://api.qase.io/v1/run/K3SRKE2/$RUN_ID/public \
115
- # --header 'Token: $QASE_API_TOKEN' \
116
- # --header 'accept: application/json' \
117
- # --header 'content-type: application/json' \
118
- # --data '{"status":true}'
119
- # )
120
- #
121
- # REPORT_URL=$(echo $PUBLISH_RUN | jq -r '.result.url')
122
- # if [[ -n "${REPORT_URL}" ]]; then
123
- # echo report url: ${REPORT_URL}
124
- # echo "## QASE Reporting" >> ${GITHUB_STEP_SUMMARY}
125
- # echo "Public Qase report: ${REPORT_URL}" >> ${GITHUB_STEP_SUMMARY}
126
- # fi
173
+ results=$(echo "$results" | jq --arg case_id "$TEST_CASE_ID" --arg status "$STATUS" --arg comment "$COMMENT_LINK" \
174
+ '. + [{ "case_id": ($case_id|tonumber), "status": $status, "comment": $comment }]')
175
+ done < /tmp/k3s-install-test-results.log
127
176
128
- - name : Run Tests and Upload Results to Qase
177
+ echo "$results" > results.json
178
+ continue-on-error : true
179
+
180
+ - name : Publish Test Results
181
+ if : always()
129
182
env :
183
+ RUN_ID : ${{ env.QASE_RUN_ID }}
184
+ PROJECT_CODE : ${{ env.PROJECT_CODE }}
130
185
QASE_API_TOKEN : ${{ secrets.QASE_API_TOKEN }}
131
- QASE_RUN_ID : ${{ env.QASE_RUN_ID }}
132
186
run : |
133
- echo "Run K3s Smoke Test"
134
- #Example: ./run-tests.sh and capture results in a file, e.g., test-results.json
135
- ./run-tests.sh > test-results.json
187
+ results=$(cat results.json)
188
+ RESPONSE=$(curl --request POST \
189
+ --url "https://api.qase.io/v1/result/${PROJECT_CODE}/${RUN_ID}/bulk" \
190
+ --header "Token: $QASE_API_TOKEN" \
191
+ --header 'accept: application/json' \
192
+ --header "Content-Type: application/json" \
193
+ --data "{\"results\": $results}")
136
194
137
-
195
+ echo "Publish test results response: $RESPONSE"
196
+ continue-on-error : true
197
+
198
+ - name : Complete Qase Run
199
+ if : always()
200
+ env :
201
+ RUN_ID : ${{ env.QASE_RUN_ID }}
202
+ PROJECT_CODE : ${{ env.PROJECT_CODE }}
203
+ QASE_API_TOKEN : ${{ secrets.QASE_API_TOKEN }}
204
+ run : |
205
+ COMPLETE_RUN=$(curl --request POST \
206
+ --url "https://api.qase.io/v1/run/${PROJECT_CODE}/${RUN_ID}/complete" \
207
+ --header "Token: $QASE_API_TOKEN" \
208
+ --header 'accept: application/json')
138
209
139
-
210
+ RUN_STATUS=$(echo $COMPLETE_RUN | jq -r '.status')
211
+ if [[ $RUN_STATUS != true ]]; then
212
+ echo "Failed to complete the run"
213
+ else
214
+ echo "Run completed successfully"
215
+ fi
216
+ continue-on-error : true
140
217
0 commit comments