Skip to content

Commit 08c1936

Browse files
committed
updating stuff
1 parent 172dcf7 commit 08c1936

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

.github/workflows/unit-testing.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ jobs:
5252
run: |
5353
pwd
5454
ls
55-
# cat summary_2.yml
5655
git status
5756
git pull
5857
source .venv/bin/activate
5958
git checkout ${GITHUB_REF#refs/heads/}
60-
cat summary_2.yml
59+
cat summary.yml
6160
# contentctl test --post-test-behavior never_pause mode:changes --mode.target-branch develop
6261
6362
summarize-test-results:
@@ -72,24 +71,28 @@ jobs:
7271
- name: Install dependencies
7372
run: sudo apt-get install -y jq
7473

75-
- name: Print results
74+
- name: Extract total_fail value
7675
run: |
77-
yq e '.summary' summary_2.yml -o=json | jq -r 'to_entries | .[] | "### \(.key)\n\(.value)\n"'
76+
total_fail=$(yq e '.summary.total_fail' summary.yml)
7877
79-
- name: Check Test Summary
78+
- name: Check if total_fail is greater than one
8079
run: |
81-
git status
82-
total_fail=$(yq e '.summary.total_fail' summary_2.yml)
83-
84-
# Check if total_fail is greater than one
8580
if [ "$total_fail" -gt 1 ]; then
8681
echo "CI Failure: There are failed tests."
87-
echo "Name | Status | Test Type"
88-
echo "---- | ------ | ---------"
89-
# Loop through each item in tested_detections and print required fields
90-
yq e '.tested_detections[] | "\(.name) | \(.success) | \(.tests[].test_type)"' summary_2.yml
82+
echo -e "Name | Status | Test Type"
83+
echo -e "---- | ------ | ---------"
84+
# Loop through each item in tested_detections and print required fields with color
85+
yq e '.tested_detections[] | .name as $name | .success as $status | .tests[].test_type as $test_type | "\($name) | \($status) | \($test_type)"' summary.yml | while read line; do
86+
name=$(echo $line | cut -d '|' -f 1)
87+
status=$(echo $line | cut -d '|' -f 2 | xargs)
88+
test_type=$(echo $line | cut -d '|' -f 3)
89+
if [ "$status" == "true" ]; then
90+
echo -e "${name} | \033[32m${status}\033[0m | ${test_type}"
91+
else
92+
echo -e "${name} | \033[31m${status}\033[0m | ${test_type}"
93+
fi
94+
done
95+
exit 1 # Fail the CI job
9196
else
9297
echo "CI Success: No failed tests."
9398
fi
94-
95-
File renamed without changes.

0 commit comments

Comments
 (0)