Skip to content

Commit 46362ed

Browse files
authored
ci: add codeowners to gotestsum report (#3118)
1 parent f0ed584 commit 46362ed

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
for file in "$@"; do
4+
temp_file="tempfile.xml"
5+
6+
# force write a new line at the end of the gotestsum-report.xml, or else
7+
# the loop will skip the last line.
8+
# fixes issue with a missing </testsuites>
9+
echo -e "\n" >> $file
10+
11+
while read p; do
12+
# we might try to report gotestsum-report.xml multiple times, so don't
13+
# calculate codeowners more times than we need
14+
if [[ "$p" =~ \<testcase && ! "$p" =~ "file=" ]]; then
15+
class=$(echo "$p" | grep -o '.v1/[^"]*"')
16+
file_name=$(echo "${class:3}" | sed 's/.$//') # trim off the edges to get the path
17+
new_line=$(echo "$p" | sed "s|<testcase \([^>]*\)>|<testcase \1 file=\"$file_name\">|")
18+
echo "$new_line" >> "$temp_file"
19+
else
20+
echo "$p" >> "$temp_file"
21+
fi
22+
done < $file
23+
24+
mv "$temp_file" $file
25+
done

.github/actions/dd-ci-upload/action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ runs:
4242
curl -L --fail "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_${{ env.DD_CI_CLI_BUILD }}" --output datadog-ci
4343
chmod +x datadog-ci
4444
45+
- name: Add CodeOwners to JUnit files
46+
shell: bash
47+
run: cd ./.github/actions/add-codeowners && ./codeowners.sh ${{ inputs.files }}
48+
4549
- name: Upload the JUnit files
4650
shell: bash
4751
run: |

0 commit comments

Comments
 (0)