Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] ci: add codeowners to gotestsum report (#3118) #3125

Open
wants to merge 3 commits into
base: v2-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading