-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathuploadnumber.sh
More file actions
33 lines (21 loc) · 1017 Bytes
/
uploadnumber.sh
File metadata and controls
33 lines (21 loc) · 1017 Bytes
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
#!/bin/bash
# Assuming Maven generates XML test reports in the "target/surefire-reports" directory
TEST_REPORT_DIR="target/surefire-reports"
# Print current directory
echo "Current directory: $(pwd)"
xml_files=$(find "$(pwd)" -name "TEST-*.xml")
# Concatenate all XML files and count the occurrences of "<testcase" using grep
test_count=$(cat $xml_files | grep -c "<testcase")
echo "Total number of tests: $test_count"
echo "GIST_ID: $GIST_ID"
json_data='{"schemaVersion": "1", "label": "testcount", "message": "'$test_count'", "color": "orange"}'
echo "JSON data: $json_data"
# Prevent any output from the script
exec > /dev/null
exec 2>&1
# Create or update the Gist with the test count
curl -s -X PATCH \
-H "Authorization: token $GIST_TOKEN" \
-H "Content-Type: application/vnd.github+json" \
-d '{"files":{"test.json":{"content": "{\"schemaVersion\": 1,\"label\": \"testcount\", \"message\": \"'$test_count'\", \"color\":\"orange\"}" }}}' \
"https://api.github.com/gists/$GIST_ID"