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

ci: add codeowners to gotestsum report #3118

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
25 changes: 25 additions & 0 deletions .github/actions/add-codeowners/codeowners.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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
class=$(echo "$p" | grep -o '.v1/[^"]*"')
file_name=$(echo "${class:3}" | sed 's/.$//') # trim off the edges to get the path
new_line=$(echo "$p" | sed "s|<testcase|<testcase 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