-
Notifications
You must be signed in to change notification settings - Fork 323
Automatic triggering of CiVis test environment #9734
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
Merged
daniel-mohedano
merged 2 commits into
master
from
daniel.mohedano/test-environment-trigger
Oct 20, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| function get_pr_number() { | ||
| local branch=$1 | ||
|
|
||
| if [ -z "$branch" ]; then | ||
| echo "Error: Branch name is required" >&2 | ||
| return 1 | ||
| fi | ||
|
|
||
| local pr_number | ||
| pr_number=$(gh pr list --repo DataDog/dd-trace-java --head "$branch" --state open --json number --jq '.[0].number') | ||
|
|
||
| if [ -z "$pr_number" ]; then | ||
| echo "Error: No open PR found for branch $branch" >&2 | ||
| return 1 | ||
| fi | ||
|
|
||
| echo "$pr_number" | ||
| return 0 | ||
| } | ||
|
|
||
| function get_pr_labels() { | ||
| local pr_number=$1 | ||
|
|
||
| if [ -z "$pr_number" ]; then | ||
| echo "Error: PR number is required" >&2 | ||
| return 1 | ||
| fi | ||
|
|
||
| local labels | ||
| labels=$(gh pr view "$pr_number" --repo DataDog/dd-trace-java --json labels --jq '.labels[].name') | ||
|
|
||
| if [ -z "$labels" ]; then | ||
| echo "Warning: No labels found for PR #$pr_number" >&2 | ||
| return 1 | ||
| fi | ||
|
|
||
| echo "$labels" | ||
| return 0 | ||
| } | ||
|
|
||
| function pr_has_label() { | ||
| local pr_number=$1 | ||
| local target_label=$2 | ||
|
|
||
| if [ -z "$pr_number" ] || [ -z "$target_label" ]; then | ||
| echo "Error: PR number and label are required" >&2 | ||
| return 1 | ||
| fi | ||
|
|
||
| local labels | ||
| if ! labels=$(get_pr_labels "$pr_number"); then | ||
| return 1 | ||
| fi | ||
|
|
||
| if echo "$labels" | grep -q "$target_label"; then | ||
| return 0 | ||
| else | ||
| return 1 | ||
| fi | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ question: What about using
run-tests:label category?As I will soon enforce to only have one
comp:orinst:label to prevent duplicate changelog, I would recommend using the labels dedicated to CI task run.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then we'll have to add
run-tests:...to every one of our PRs just for the sake of it. Addingcomp:ci-visibilityis something we already do and won't forget to do.That's a pity, is there any other way we could avoid duplicates? E.g. if there's an instrumentation label, use it to determine the section, and then fallback to the comp one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coming back to this, I could modify the trigger to activate when either one of the two labels is set, so that our use case is still supported. Although after checking, in our last over 100 PRs we haven't used an
inst:label, so I don't think the conflict will be common at all (in cases where there were multiplecomp:labels it was mainly related to either testing or tooling)