Skip to content

Commit 2c57e69

Browse files
Migrate e2e status to short-lived token (#784)
* Migrate e2e status to short-lived token * Executable mode
1 parent 8badbdb commit 2c57e69

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

ci/input_files/build.yaml.tpl

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -285,30 +285,5 @@ e2e-test-status:
285285
- if: '$SKIP_E2E_TESTS == "true"'
286286
when: never
287287
- when: on_success
288-
script: |
289-
GITLAB_API_TOKEN=$(aws ssm get-parameter --region us-east-1 --name "ci.${CI_PROJECT_NAME}.serverless-e2e-gitlab-token" --with-decryption --query "Parameter.Value" --out text)
290-
URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/bridges"
291-
echo "Fetching E2E job status from: $URL"
292-
while true; do
293-
RESPONSE=$(curl -s --header "PRIVATE-TOKEN: ${GITLAB_API_TOKEN}" "$URL")
294-
E2E_JOB_STATUS=$(echo "$RESPONSE" | jq -r '.[] | select(.name=="e2e-test") | .downstream_pipeline.status')
295-
echo -n "E2E job status: $E2E_JOB_STATUS, "
296-
if [ "$E2E_JOB_STATUS" == "success" ]; then
297-
echo "✅ E2E tests completed successfully"
298-
exit 0
299-
elif [ "$E2E_JOB_STATUS" == "failed" ]; then
300-
echo "❌ E2E tests failed"
301-
exit 1
302-
elif [ "$E2E_JOB_STATUS" == "running" ]; then
303-
echo "⏳ E2E tests are still running, retrying in 1 minute..."
304-
elif [ "$E2E_JOB_STATUS" == "canceled" ]; then
305-
echo "🚫 E2E tests were canceled"
306-
exit 1
307-
elif [ "$E2E_JOB_STATUS" == "skipped" ]; then
308-
echo "⏭️ E2E tests were skipped"
309-
exit 0
310-
else
311-
echo "❓ Unknown E2E test status: $E2E_JOB_STATUS, retrying in 1 minute..."
312-
fi
313-
sleep 60
314-
done
288+
script:
289+
- ci/poll_e2e.sh

ci/poll_e2e.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
curl -OL "binaries.ddbuild.io/dd-source/authanywhere/LATEST/authanywhere-linux-amd64" && mv "authanywhere-linux-amd64" /bin/authanywhere && chmod +x /bin/authanywhere
2+
3+
BTI_CI_API_TOKEN=$(authanywhere --audience rapid-devex-ci)
4+
5+
BTI_RESPONSE=$(curl --silent --request GET \
6+
--header "$BTI_CI_API_TOKEN" \
7+
--header "Content-Type: application/vnd.api+json" \
8+
"https://bti-ci-api.us1.ddbuild.io/internal/ci/gitlab/token?owner=DataDog&repository=datadog-lambda-python")
9+
10+
GITLAB_TOKEN=$(echo "$BTI_RESPONSE" | jq -r '.token // empty')
11+
12+
URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/bridges"
13+
14+
echo "Fetching E2E job status from: $URL"
15+
16+
while true; do
17+
RESPONSE=$(curl -s --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" "$URL")
18+
E2E_JOB_STATUS=$(echo "$RESPONSE" | jq -r '.[] | select(.name=="e2e-test") | .downstream_pipeline.status')
19+
echo -n "E2E job status: $E2E_JOB_STATUS, "
20+
if [ "$E2E_JOB_STATUS" == "success" ]; then
21+
echo "✅ E2E tests completed successfully"
22+
exit 0
23+
elif [ "$E2E_JOB_STATUS" == "failed" ]; then
24+
echo "❌ E2E tests failed"
25+
exit 1
26+
elif [ "$E2E_JOB_STATUS" == "running" ]; then
27+
echo "⏳ E2E tests are still running, retrying in 2 minutes..."
28+
elif [ "$E2E_JOB_STATUS" == "canceled" ]; then
29+
echo "🚫 E2E tests were canceled"
30+
exit 1
31+
elif [ "$E2E_JOB_STATUS" == "skipped" ]; then
32+
echo "⏭️ E2E tests were skipped"
33+
exit 0
34+
else
35+
echo "❓ Unknown E2E test status: $E2E_JOB_STATUS, retrying in 2 minutes..."
36+
fi
37+
sleep 120
38+
done

0 commit comments

Comments
 (0)