Skip to content

Commit

Permalink
[v2] ci: add codeowners to gotestsum report (#3118) (#3125)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahkm authored Feb 3, 2025
1 parent 36f7fad commit 1e52457
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/actions/add-codeowners/codeowners.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

for file in "$@"; do
temp_file="tempfile.xml"

# force write a new line at the end of the gotestsum-report.xml, or else
# the loop will skip the last line.
# fixes issue with a missing </testsuites>
echo -e "\n" >> $file

while read p; do
# we might try to report gotestsum-report.xml multiple times, so don't
# calculate codeowners more times than we need
if [[ "$p" =~ \<testcase && ! "$p" =~ "file=" ]]; then
# in v2, some of our paths contain a "/v2" before the subdirectory path, but
# the contribs do not. We optionally remove it.
class=$(echo "$p" | sed "s|/v2||")
class=$(echo "$class" | grep -o 'dd-trace-go/[^"]*"')
file_name=$(echo "${class:11}" | sed 's/.$//') # trim off the edges to get the path
new_line=$(echo "$p" | sed "s|<testcase \([^>]*\)>|<testcase \1 file=\"$file_name\">|")
echo "$new_line" >> "$temp_file"
else
echo "$p" >> "$temp_file"
fi
done < $file

mv "$temp_file" $file
done
4 changes: 4 additions & 0 deletions .github/actions/dd-ci-upload/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ runs:
curl -L --fail "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_${{ env.DD_CI_CLI_BUILD }}" --output datadog-ci
chmod +x datadog-ci
- name: Add CodeOwners to JUnit files
shell: bash
run: cd ./.github/actions/add-codeowners && ./codeowners.sh ${{ inputs.files }}

- name: Upload the JUnit files
shell: bash
run: |
Expand Down

0 comments on commit 1e52457

Please sign in to comment.