Skip to content

Commit

Permalink
[SMP] regression detector: curl request to pr-commenter (#29684)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffrey M. Oxberry <[email protected]>
  • Loading branch information
goxberry authored Oct 3, 2024
1 parent 149c32a commit 407624b
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions .gitlab/functional_test/regression_detector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ single-machine-performance-regression_detector:
- outputs/regression_signal.json # for debugging, also on S3
- outputs/bounds_check_signal.json # for debugging, also on S3
- outputs/junit.xml # for debugging, also on S3
- report_as_json_string.txt # for debugging transform to valid JSON string
- pr_comment_payload.json # for debugging PR commenter JSON payload bugs
when: always
variables:
SMP_VERSION: 0.16.0
Expand Down Expand Up @@ -124,9 +126,38 @@ single-machine-performance-regression_detector:
# space characters. This avoids
# https://gitlab.com/gitlab-org/gitlab/-/issues/217231.
- cat outputs/report.md | sed "s/^\$/$(echo -ne '\uFEFF\u00A0\u200B')/g"
- !reference [.install_pr_commenter]
# Post HTML report to GitHub
- cat outputs/report.md | /usr/local/bin/pr-commenter --for-pr="$CI_COMMIT_REF_NAME" --header="Regression Detector"
# Download auth tool; see
# https://github.com/DataDog/dd-source/tree/8f80b7ef031839b0b11b4a70b9067d6142f3dd5b/domains/devex/ci/authanywhere
- curl -Lo ./authanywhere binaries.ddbuild.io/dd-source/authanywhere/LATEST/authanywhere-linux-amd64
- chmod u+x ./authanywhere
# We need to transform the Markdown report into a valid JSON string (without
# quotes) in order to pass a well-formed payload to the PR commenting
# service. Note that on macOS, the "-z" flag is invalid for `sed` (but
# should be fine for GNU `sed`). We need to use `sed` to escape newlines
# because JSON does not permit (raw) newlines in strings. We use the "-z"
# option with `sed` because that option treats its input as
# NUL-character-separated (i.e., '\0'-separated, the zero-byte character),
# so `sed` does not interpret its input as newline-delimited. We also need
# to escape double quotes to distinguish literal quotes in the report from
# the double quotes that delimit the value of the "message" field in the
# payload.
- cat outputs/report.md | sed -z 's/\n/\\n/g' | sed -z 's/"/\\"/g' > report_as_json_string.txt
- cat report_as_json_string.txt
# Transforming the Markdown report to a valid JSON string is easy to foul
# up, so to make debugging easier, we store the payload in a variable to
# help debugging.
- PR_COMMENT_JSON_PAYLOAD='{"org":"DataDog", "repo":"datadog-agent", "commit":"'"${CI_COMMIT_SHA}"'", "header":"Regression Detector", "message":"'"$(cat report_as_json_string.txt)"'"}'
- printf "%s\n" "PR comment JSON payload:${PR_COMMENT_JSON_PAYLOAD}"
- printf "%s\n" "${PR_COMMENT_JSON_PAYLOAD}" > pr_comment_payload.json
# Craft an HTTPS request to pr-commenter service to post Markdown report to
# GitHub, per
# https://github.com/DataDog/dd-source/tree/7c941f527fb9c44a73433c7dd0a090d92be7deb4/domains/devex/codex/apps/apis/pr-commenter
- |
curl https://pr-commenter.us1.ddbuild.io/internal/cit/pr-comment \
-H "$(./authanywhere)" \
-H "X-DdOrigin: curl" \
-X PATCH \
-d "${PR_COMMENT_JSON_PAYLOAD}"
# Upload JUnit XML outside of Agent CI's tooling because the `junit_upload`
# invoke task has additional logic that does not seem to apply well to SMP's
# JUnit XML. Agent CI seems to use `datadog-agent` as the service name when
Expand Down

0 comments on commit 407624b

Please sign in to comment.