Skip to content

Commit d5d6835

Browse files
Adding e2e test trigger
1 parent 378e174 commit d5d6835

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

‎.gitlab/input_files/build.yaml.tpl‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{- $e2e_region := "us-west-2" -}}
2+
13
variables:
24
CI_DOCKER_TARGET_IMAGE: registry.ddbuild.io/ci/datadog-lambda-js
35
CI_DOCKER_TARGET_VERSION: latest
@@ -7,6 +9,7 @@ stages:
79
- test
810
- sign
911
- publish
12+
- e2e
1013

1114
default:
1215
retry:
@@ -126,6 +129,8 @@ publish layer {{ $environment.name }} ({{ $runtime.name }}):
126129
tags: ["arch:amd64"]
127130
image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION}
128131
rules:
132+
- if: '"{{ $environment_name }}" == "sandbox" && $REGION == "{{ $e2e_region }}"'
133+
when: on_success
129134
- if: '"{{ $environment.name }}" =~ /^(sandbox|staging)/'
130135
when: manual
131136
allow_failure: true
@@ -203,3 +208,56 @@ publish npm package:
203208
- mkdir -p datadog_lambda_js-{{ if eq $environment.name "prod"}}signed-{{ end }}bundle-${CI_JOB_ID}
204209
- cp .layers/datadog_lambda_node*.zip datadog_lambda_js-{{ if eq $environment.name "prod"}}signed-{{ end }}bundle-${CI_JOB_ID}
205210
{{ end }}
211+
212+
e2e-test:
213+
stage: e2e
214+
trigger:
215+
project: DataDog/serverless-e2e-tests
216+
strategy: depend
217+
variables:
218+
LANGUAGES_SUBSET: node
219+
# These env vars are inherited from the dotenv reports of the publish-layer jobs
220+
{{- range (ds "runtimes").runtimes }}
221+
{{- if eq .arch "amd64" }}
222+
{{- $runtime.node_version := print (.name | strings.Trim "node") }}
223+
NODEJS_{{ $runtime.node_version }}_VERSION: $NODEJS_{{ $runtime.node_version }}_VERSION
224+
{{- end }}
225+
{{- end }}
226+
needs: {{ range (ds "runtimes").runtimes }}
227+
{{- if eq .arch "amd64" }}
228+
- "publish-layer-sandbox ({{ .name }}): [{{ $e2e_region }}]"
229+
{{- end }}
230+
{{- end }}
231+
232+
e2e-test-status:
233+
stage: e2e
234+
image: registry.ddbuild.io/images/docker:20.10-py3
235+
tags: ["arch:amd64"]
236+
timeout: 3h
237+
script: |
238+
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)
239+
URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/bridges"
240+
echo "Fetching E2E job status from: $URL"
241+
while true; do
242+
RESPONSE=$(curl -s --header "PRIVATE-TOKEN: ${GITLAB_API_TOKEN}" "$URL")
243+
E2E_JOB_STATUS=$(echo "$RESPONSE" | jq -r '.[] | select(.name=="e2e-test") | .downstream_pipeline.status')
244+
echo -n "E2E job status: $E2E_JOB_STATUS, "
245+
if [ "$E2E_JOB_STATUS" == "success" ]; then
246+
echo "✅ E2E tests completed successfully"
247+
exit 0
248+
elif [ "$E2E_JOB_STATUS" == "failed" ]; then
249+
echo "❌ E2E tests failed"
250+
exit 1
251+
elif [ "$E2E_JOB_STATUS" == "running" ]; then
252+
echo "⏳ E2E tests are still running, retrying in 1 minute..."
253+
elif [ "$E2E_JOB_STATUS" == "canceled" ]; then
254+
echo "🚫 E2E tests were canceled"
255+
exit 1
256+
elif [ "$E2E_JOB_STATUS" == "skipped" ]; then
257+
echo "⏭️ E2E tests were skipped"
258+
exit 0
259+
else
260+
echo "❓ Unknown E2E test status: $E2E_JOB_STATUS, retrying in 1 minute..."
261+
fi
262+
sleep 60
263+
done

0 commit comments

Comments
 (0)