Skip to content

Commit 5b76dcc

Browse files
committed
Use CI_JOB_STATUS to determine pass/fail.
1 parent 28bdf4b commit 5b76dcc

File tree

1 file changed

+62
-84
lines changed

1 file changed

+62
-84
lines changed

ci/input_files/build.yaml.tpl

Lines changed: 62 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,18 @@ build-layer ({{ $runtime.name }}-{{ $runtime.arch }}):
5353
variables:
5454
CI_ENABLE_CONTAINER_IMAGE_BUILDS: "true"
5555
script:
56-
- exit 0
5756
- PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/build_layers.sh
5857

59-
#check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }}):
60-
# stage: test
61-
# tags: ["arch:amd64"]
62-
# image: registry.ddbuild.io/images/docker:20.10
63-
# needs:
64-
# - build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
65-
# dependencies:
66-
# - build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
67-
# script:
68-
# - PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/check_layer_size.sh
58+
check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }}):
59+
stage: test
60+
tags: ["arch:amd64"]
61+
image: registry.ddbuild.io/images/docker:20.10
62+
needs:
63+
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
64+
dependencies:
65+
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
66+
script:
67+
- PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/check_layer_size.sh
6968

7069
lint python:
7170
stage: test
@@ -74,39 +73,38 @@ lint python:
7473
cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache
7574
before_script: *python-before-script
7675
script:
77-
- exit 0
7876
- source venv/bin/activate
7977
- ./scripts/check_format.sh
8078

81-
#unit-test ({{ $runtime.name }}-{{ $runtime.arch }}):
82-
# stage: test
83-
# tags: ["arch:amd64"]
84-
# image: registry.ddbuild.io/images/mirror/python:{{ $runtime.image }}
85-
# cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache
86-
# before_script: *python-before-script
87-
# script:
88-
# - source venv/bin/activate
89-
# - pytest -vv
79+
unit-test ({{ $runtime.name }}-{{ $runtime.arch }}):
80+
stage: test
81+
tags: ["arch:amd64"]
82+
image: registry.ddbuild.io/images/mirror/python:{{ $runtime.image }}
83+
cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache
84+
before_script: *python-before-script
85+
script:
86+
- source venv/bin/activate
87+
- pytest -vv
9088

91-
#integration-test ({{ $runtime.name }}-{{ $runtime.arch }}):
92-
# stage: test
93-
# tags: ["arch:amd64"]
94-
# image: registry.ddbuild.io/images/docker:20.10-py3
95-
# needs:
96-
# - build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
97-
# dependencies:
98-
# - build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
99-
# cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache
100-
# variables:
101-
# CI_ENABLE_CONTAINER_IMAGE_BUILDS: "true"
102-
# before_script:
103-
# - *install-node
104-
# - EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source ./ci/get_secrets.sh
105-
# - yarn global add serverless@^3.38.0 --prefix /usr/local
106-
# - yarn global add serverless-python-requirements@^6.1.1 --prefix /usr/local
107-
# - cd integration_tests && yarn install && cd ..
108-
# script:
109-
# - RUNTIME_PARAM={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/run_integration_tests.sh
89+
integration-test ({{ $runtime.name }}-{{ $runtime.arch }}):
90+
stage: test
91+
tags: ["arch:amd64"]
92+
image: registry.ddbuild.io/images/docker:20.10-py3
93+
needs:
94+
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
95+
dependencies:
96+
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
97+
cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache
98+
variables:
99+
CI_ENABLE_CONTAINER_IMAGE_BUILDS: "true"
100+
before_script:
101+
- *install-node
102+
- EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source ./ci/get_secrets.sh
103+
- yarn global add serverless@^3.38.0 --prefix /usr/local
104+
- yarn global add serverless-python-requirements@^6.1.1 --prefix /usr/local
105+
- cd integration_tests && yarn install && cd ..
106+
script:
107+
- RUNTIME_PARAM={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/run_integration_tests.sh
110108

111109
sign-layer ({{ $runtime.name }}-{{ $runtime.arch }}):
112110
stage: sign
@@ -117,10 +115,10 @@ sign-layer ({{ $runtime.name }}-{{ $runtime.arch }}):
117115
when: manual
118116
needs:
119117
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
120-
#- check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }})
118+
- check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }})
121119
- lint python
122-
#- unit-test ({{ $runtime.name }}-{{ $runtime.arch }})
123-
#- integration-test ({{ $runtime.name }}-{{ $runtime.arch }})
120+
- unit-test ({{ $runtime.name }}-{{ $runtime.arch }})
121+
- integration-test ({{ $runtime.name }}-{{ $runtime.arch }})
124122
dependencies:
125123
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
126124
artifacts: # Re specify artifacts so the modified signed file is passed
@@ -158,10 +156,10 @@ publish-layer-{{ $environment_name }} ({{ $runtime.name }}-{{ $runtime.arch }}):
158156
- sign-layer ({{ $runtime.name }}-{{ $runtime.arch}})
159157
{{ else }}
160158
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
161-
#- check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }})
159+
- check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }})
162160
- lint python
163-
#- unit-test ({{ $runtime.name }}-{{ $runtime.arch }})
164-
#- integration-test ({{ $runtime.name }}-{{ $runtime.arch }})
161+
- unit-test ({{ $runtime.name }}-{{ $runtime.arch }})
162+
- integration-test ({{ $runtime.name }}-{{ $runtime.arch }})
165163
{{ end }}
166164
dependencies:
167165
{{ if or (eq $environment_name "prod") }}
@@ -178,7 +176,6 @@ publish-layer-{{ $environment_name }} ({{ $runtime.name }}-{{ $runtime.arch }}):
178176
- EXTERNAL_ID_NAME={{ $environment.external_id }} ROLE_TO_ASSUME={{ $environment.role_to_assume }} AWS_ACCOUNT={{ $environment.account }} source ./ci/get_secrets.sh
179177
script:
180178
- |
181-
exit 0
182179
STAGE={{ $environment_name }} PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./ci/publish_layers.sh | tee publish.log
183180
# Extract the arn from the publish log to be used as envvar in e2e tests
184181
layer_arn="$(grep 'Published arn' publish.log | grep -oE 'arn:aws:lambda:.*')"
@@ -229,7 +226,6 @@ layer bundle:
229226
- datadog_lambda_py-bundle-${CI_JOB_ID}/
230227
name: datadog_lambda_py-bundle-${CI_JOB_ID}
231228
script:
232-
- exit 0
233229
- rm -rf datadog_lambda_py-bundle-${CI_JOB_ID}
234230
- mkdir -p datadog_lambda_py-bundle-${CI_JOB_ID}
235231
- cp .layers/datadog_lambda_py-*.zip datadog_lambda_py-bundle-${CI_JOB_ID}
@@ -283,13 +279,13 @@ e2e-status:
283279
image: registry.ddbuild.io/images/mirror/alpine:latest
284280
tags: ["arch:amd64"]
285281
needs:
282+
- e2e-test
286283
{{- range (ds "runtimes").runtimes }}
287284
{{- if eq .arch "amd64" }}
288285
- "publish-layer-sandbox ({{ .name }}-{{ .arch }}): [{{ $e2e_region }}]"
289286
{{- end }}
290287
{{- end }}
291288
script:
292-
- apk add --no-cache curl jq
293289
- echo "Python layer ARNs used in E2E tests:"
294290
{{- range (ds "runtimes").runtimes }}
295291
{{- if eq .arch "amd64" }}
@@ -299,39 +295,21 @@ e2e-status:
299295
{{- end }}
300296
- |
301297
# TODO: link to the test results
298+
# make this job start running at same time as e2e-test job
302299
# do not wait around for the scheduled job to complete
303-
echo "🔄 Waiting for E2E tests to complete..."
304-
URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/bridges"
305-
echo "Fetching E2E job status from: $URL"
306-
env
307-
while true; do
308-
# Get the e2e-test job status
309-
#RESPONSE=$(curl -s --header "JOB-TOKEN: ${CI_JOB_TOKEN}" "$URL")
310-
RESPONSE=$(curl -s --header "PRIVATE-TOKEN: ${GITLAB_API_TOKEN}" "$URL")
311-
echo "Response: $RESPONSE"
312-
E2E_JOB_STATUS=$(echo "$RESPONSE" | jq -r '.[] | select(.name=="e2e-test") | .pipeline.status')
313-
echo "E2E job status: $E2E_JOB_STATUS"
314-
case "$E2E_JOB_STATUS" in
315-
"success")
316-
echo "✅ E2E tests completed successfully"
317-
exit 0
318-
;;
319-
"failed")
320-
echo "❌ E2E tests failed"
321-
echo "💡 Look for pipelines triggered around $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
322-
exit 1
323-
;;
324-
"canceled")
325-
echo "⚠️ E2E tests were canceled"
326-
exit 1
327-
;;
328-
"running"|"pending"|"created")
329-
echo "⏳ E2E tests still running..."
330-
sleep 30
331-
;;
332-
*)
333-
echo "❓ Unknown E2E test status: $E2E_JOB_STATUS"
334-
sleep 30
335-
;;
336-
esac
337-
done
300+
switch "${CI_JOB_STATUS}" in
301+
"success")
302+
echo "✅ E2E tests completed successfully"
303+
;;
304+
"failed")
305+
echo "❌ E2E tests failed"
306+
exit 1
307+
;;
308+
"canceled")
309+
echo "❌ E2E tests were canceled"
310+
exit 1
311+
;;
312+
*)
313+
echo "❌ E2E tests unknown status: ${CI_JOB_STATUS}"
314+
exit 1
315+
esac

0 commit comments

Comments
 (0)