Skip to content

Commit 7533219

Browse files
feat: initial version of automatic test environment
1 parent 55230eb commit 7533219

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

.gitlab/ci-visibility-tests.yml

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,67 @@
1+
check-ci-visibility-label:
2+
stage: publish
3+
image: registry.ddbuild.io/images/dd-octo-sts-ci-base:2025.06-1
4+
tags: [ "arch:amd64" ]
5+
needs: [ publish-artifacts-to-s3 ]
6+
id_tokens:
7+
DDOCTOSTS_ID_TOKEN:
8+
aud: dd-octo-sts
9+
rules:
10+
- if: '$POPULATE_CACHE'
11+
when: never
12+
- if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(master|release\/)/'
13+
when: on_success
14+
- when: never
15+
before_script:
16+
- dd-octo-sts version
17+
- dd-octo-sts debug --scope DataDog/dd-trace-java --policy self.gitlab.github-access.read
18+
- dd-octo-sts token --scope DataDog/dd-trace-java --policy self.gitlab.github-access.read > github-token.txt
19+
- gh auth login --with-token < github-token.txt
20+
script:
21+
- |
22+
set +e
23+
PR_NUMBER=$(gh pr list --repo DataDog/dd-trace-java --head "${CI_COMMIT_BRANCH}" --state open --json number --jq '.[0].number')
24+
EXIT_CODE=$?
25+
set -e
26+
27+
if [ $EXIT_CODE -ne 0 ] || [ -z "$PR_NUMBER" ]; then
28+
echo "No open PR found for branch ${CI_COMMIT_BRANCH}"
29+
echo "CI_VISIBILITY_LABEL_FOUND=false" > ci-visibility-label.env
30+
exit 0
31+
fi
32+
33+
echo "Found PR #${PR_NUMBER}"
34+
35+
LABELS=$(gh pr view "${PR_NUMBER}" --repo DataDog/dd-trace-java --json labels --jq '.labels[].name')
36+
37+
if echo "$LABELS" | grep -q "comp: ci visibility"; then
38+
echo "Label 'comp: ci visibility' found on PR #${PR_NUMBER}"
39+
echo "CI_VISIBILITY_LABEL_FOUND=true" > ci-visibility-label.env
40+
else
41+
echo "Label 'comp: ci visibility' not found on PR #${PR_NUMBER}"
42+
echo "CI_VISIBILITY_LABEL_FOUND=false" > ci-visibility-label.env
43+
fi
44+
after_script:
45+
- dd-octo-sts revoke -t $(cat github-token.txt)
46+
artifacts:
47+
reports:
48+
dotenv: ci-visibility-label.env
49+
retry:
50+
max: 2
51+
when: always
52+
153
run-ci-visibility-test-environment:
254
stage: ci-visibility-tests
3-
when: manual
4-
needs: []
55+
needs:
56+
- job: check-ci-visibility-label
57+
optional: true
58+
rules:
59+
- if: '$POPULATE_CACHE'
60+
when: never
61+
- if: '$CI_VISIBILITY_LABEL_FOUND == "true"'
62+
when: on_success
63+
- when: manual
64+
allow_failure: true
565
trigger:
666
project: DataDog/apm-reliability/test-environment
767
branch: main

0 commit comments

Comments
 (0)