Skip to content

Commit d354ef2

Browse files
committed
github action: use the json file instead of parsing the logs
1 parent 205d5b5 commit d354ef2

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

.github/workflows/GnuTests.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
key: lima-${{ steps.lima-actions-setup.outputs.version }}
9696

9797
- name: Selinux - Start Fedora VM with SELinux
98-
run: limactl start --plain --name=default --cpus=2 --disk=40 --memory=8 --network=lima:user-v2 template://fedora
98+
run: limactl start --plain --name=default --cpus=4 --disk=40 --memory=8 --network=lima:user-v2 template://fedora
9999

100100
- name: Selinux - Setup SSH
101101
uses: lima-vm/lima-actions/ssh@v1
@@ -201,17 +201,19 @@ jobs:
201201
run: |
202202
lima bash -c "cd ~/work/uutils/ && CI=1 bash util/run-gnu-test.sh run-root \$(cat selinux-tests.txt)"
203203
204-
- name: Selinux - Extract testing info from indiv logs into JSON
204+
- name: Selinux - Extract testing info from individual logs into JSON
205205
shell: bash
206206
run : |
207-
lima bash -c "cd ~/work/gnu/ && python3 ../uutils/util/gnu-json-result.py tests > tests-selinux/selinux-gnu-full-result.json && cat tests-selinux/selinux-gnu-full-result.json"
207+
lima bash -c "mkdir -p ~/work/gnu/tests-selinux/"
208+
lima bash -c "cd ~/work/gnu/ && python3 ../uutils/util/gnu-json-result.py tests"
209+
lima bash -c "cd ~/work/gnu/ && python3 ../uutils/util/gnu-json-result.py tests > ~/work/gnu/tests-selinux/selinux-gnu-full-result.json && cat ~/work/gnu/tests-selinux/selinux-gnu-full-result.json"
208210
209211
- name: Selinux - Collect test logs and test results
210212
run: |
211213
mkdir -p ${{ steps.vars.outputs.path_GNU_tests }}-selinux
212214
213215
# Copy the test logs from the Lima VM to the host
214-
lima bash -c "mkdir -p ~/work/gnu/tests-selinux && cp ~/work/gnu/tests/test-suite.log ~/work/gnu/tests-selinux/ || echo 'No test-suite.log found'"
216+
lima bash -c "cp ~/work/gnu/tests/test-suite.log ~/work/gnu/tests-selinux/ || echo 'No test-suite.log found'"
215217
lima bash -c "cp ~/work/gnu/tests/test-suite-root.log ~/work/gnu/tests-selinux/ || echo 'No test-suite-root.log found'"
216218
rsync -v -a -e ssh lima-default:~/work/gnu/tests-selinux/ ./${{ steps.vars.outputs.path_GNU_tests }}-selinux/
217219
@@ -245,25 +247,27 @@ jobs:
245247
run: |
246248
## Extract/summarize testing info
247249
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
248-
#
250+
249251
path_UUTILS='${{ steps.vars.outputs.path_UUTILS }}'
250-
#
251-
SUITE_LOG_FILE='${{ steps.vars.outputs.SUITE_LOG_FILE }}'
252-
ROOT_SUITE_LOG_FILE='${{ steps.vars.outputs.ROOT_SUITE_LOG_FILE }}'
253-
SELINUX_SUITE_LOG_FILE='${{ steps.vars.outputs.SELINUX_SUITE_LOG_FILE }}'
254-
SELINUX_ROOT_SUITE_LOG_FILE='${{ steps.vars.outputs.SELINUX_ROOT_SUITE_LOG_FILE }}'
255-
ls -al ${SUITE_LOG_FILE} ${ROOT_SUITE_LOG_FILE} ${SELINUX_SUITE_LOG_FILE} ${SELINUX_ROOT_SUITE_LOG_FILE}
256252
257-
if test -f "${SUITE_LOG_FILE}"
253+
# Check if the file exists
254+
if test -f "${{ steps.vars.outputs.TEST_FULL_SUMMARY_FILE }}"
258255
then
259-
source ${path_UUTILS}/util/analyze-gnu-results.sh ${SUITE_LOG_FILE} ${ROOT_SUITE_LOG_FILE} ${SELINUX_SUITE_LOG_FILE} ${SELINUX_ROOT_SUITE_LOG_FILE}
256+
# Run the Python script to analyze the JSON data
257+
eval $(python3 ${path_UUTILS}/util/analyze-gnu-results.py ${{ steps.vars.outputs.TEST_FULL_SUMMARY_FILE }})
258+
260259
if [[ "$TOTAL" -eq 0 || "$TOTAL" -eq 1 ]]; then
261-
echo "::error ::Failed to parse test results from '${SUITE_LOG_FILE}'; failing early"
260+
echo "::error ::Failed to parse test results from '${{ steps.vars.outputs.TEST_FULL_SUMMARY_FILE }}'; failing early"
262261
exit 1
263262
fi
263+
264264
output="GNU tests summary = TOTAL: $TOTAL / PASS: $PASS / FAIL: $FAIL / ERROR: $ERROR / SKIP: $SKIP"
265265
echo "${output}"
266-
if [[ "$FAIL" -gt 0 || "$ERROR" -gt 0 ]]; then echo "::warning ::${output}" ; fi
266+
267+
if [[ "$FAIL" -gt 0 || "$ERROR" -gt 0 ]]; then
268+
echo "::warning ::${output}"
269+
fi
270+
267271
jq -n \
268272
--arg date "$(date --rfc-email)" \
269273
--arg sha "$GITHUB_SHA" \
@@ -277,9 +281,10 @@ jobs:
277281
HASH=$(sha1sum '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}' | cut --delim=" " -f 1)
278282
outputs HASH
279283
else
280-
echo "::error ::Failed to find summary of test results (missing '${SUITE_LOG_FILE}'); failing early"
284+
echo "::error ::Failed to find summary of test results (missing '${{ steps.vars.outputs.TEST_FULL_SUMMARY_FILE }}'); failing early"
281285
exit 1
282286
fi
287+
283288
# Compress logs before upload (fails otherwise)
284289
gzip ${{ steps.vars.outputs.TEST_LOGS_GLOB }}
285290
- name: Reserve SHA1/ID of 'test-summary'

0 commit comments

Comments
 (0)