-
Notifications
You must be signed in to change notification settings - Fork 46
Run e2e tests on each PR. #584
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
base: main
Are you sure you want to change the base?
Changes from all commits
e3bd1c0
bcd9694
35ab3f5
a258935
a6fcea9
bb556d1
b4e3b4a
0953779
cf0ac9e
4340b67
6416495
f214993
041bb9a
6cd4b91
1dd8e36
fac1c32
b7ffa18
aaef324
9816e4d
0a3ff19
5c6b64c
8898773
c6b953b
5bda987
f6844fb
49de9fd
5b29953
ae1fa34
47fd32e
58b9189
5c05fc5
f92b03e
793e31c
0d81a40
3afb253
5b9c002
14c8d5b
692fcc9
312b150
1b03542
4832760
16cb46f
66693af
28bdf4b
5b76dcc
c7042e9
694e14f
9039707
0a4e02a
61c6ebf
2510813
e2c18b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
{{- $e2e_region := "us-west-2" -}} | ||
|
||
stages: | ||
- build | ||
- test | ||
- sign | ||
- publish | ||
- e2e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
.python-before-script: &python-before-script | ||
- pip install virtualenv | ||
|
@@ -52,56 +55,56 @@ build-layer ({{ $runtime.name }}-{{ $runtime.arch }}): | |
script: | ||
- PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/build_layers.sh | ||
|
||
check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }}): | ||
stage: test | ||
tags: ["arch:amd64"] | ||
image: registry.ddbuild.io/images/docker:20.10 | ||
needs: | ||
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
dependencies: | ||
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
script: | ||
- PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/check_layer_size.sh | ||
|
||
lint python: | ||
stage: test | ||
tags: ["arch:amd64"] | ||
image: registry.ddbuild.io/images/mirror/python:{{ $runtime.image }} | ||
cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache | ||
before_script: *python-before-script | ||
script: | ||
- source venv/bin/activate | ||
- ./scripts/check_format.sh | ||
|
||
unit-test ({{ $runtime.name }}-{{ $runtime.arch }}): | ||
stage: test | ||
tags: ["arch:amd64"] | ||
image: registry.ddbuild.io/images/mirror/python:{{ $runtime.image }} | ||
cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache | ||
before_script: *python-before-script | ||
script: | ||
- source venv/bin/activate | ||
- pytest -vv | ||
|
||
integration-test ({{ $runtime.name }}-{{ $runtime.arch }}): | ||
stage: test | ||
tags: ["arch:amd64"] | ||
image: registry.ddbuild.io/images/docker:20.10-py3 | ||
needs: | ||
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
dependencies: | ||
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache | ||
variables: | ||
CI_ENABLE_CONTAINER_IMAGE_BUILDS: "true" | ||
before_script: | ||
- *install-node | ||
- EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source ./ci/get_secrets.sh | ||
- yarn global add serverless@^3.38.0 --prefix /usr/local | ||
- yarn global add serverless-python-requirements@^6.1.1 --prefix /usr/local | ||
- cd integration_tests && yarn install && cd .. | ||
script: | ||
- RUNTIME_PARAM={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/run_integration_tests.sh | ||
#check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }}): | ||
# stage: test | ||
# tags: ["arch:amd64"] | ||
# image: registry.ddbuild.io/images/docker:20.10 | ||
# needs: | ||
# - build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
# dependencies: | ||
# - build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
# script: | ||
# - PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/check_layer_size.sh | ||
# | ||
#lint python: | ||
# stage: test | ||
# tags: ["arch:amd64"] | ||
# image: registry.ddbuild.io/images/mirror/python:{{ $runtime.image }} | ||
# cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache | ||
# before_script: *python-before-script | ||
# script: | ||
# - source venv/bin/activate | ||
# - ./scripts/check_format.sh | ||
# | ||
#unit-test ({{ $runtime.name }}-{{ $runtime.arch }}): | ||
# stage: test | ||
# tags: ["arch:amd64"] | ||
# image: registry.ddbuild.io/images/mirror/python:{{ $runtime.image }} | ||
# cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache | ||
# before_script: *python-before-script | ||
# script: | ||
# - source venv/bin/activate | ||
# - pytest -vv | ||
# | ||
#integration-test ({{ $runtime.name }}-{{ $runtime.arch }}): | ||
# stage: test | ||
# tags: ["arch:amd64"] | ||
# image: registry.ddbuild.io/images/docker:20.10-py3 | ||
# needs: | ||
# - build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
# dependencies: | ||
# - build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
# cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache | ||
# variables: | ||
# CI_ENABLE_CONTAINER_IMAGE_BUILDS: "true" | ||
# before_script: | ||
# - *install-node | ||
# - EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source ./ci/get_secrets.sh | ||
# - yarn global add serverless@^3.38.0 --prefix /usr/local | ||
# - yarn global add serverless-python-requirements@^6.1.1 --prefix /usr/local | ||
# - cd integration_tests && yarn install && cd .. | ||
# script: | ||
# - RUNTIME_PARAM={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/run_integration_tests.sh | ||
|
||
sign-layer ({{ $runtime.name }}-{{ $runtime.arch }}): | ||
stage: sign | ||
|
@@ -112,10 +115,10 @@ sign-layer ({{ $runtime.name }}-{{ $runtime.arch }}): | |
when: manual | ||
needs: | ||
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
- check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
- lint python | ||
- unit-test ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
- integration-test ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
#- check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
#- lint python | ||
#- unit-test ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
#- integration-test ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
dependencies: | ||
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
artifacts: # Re specify artifacts so the modified signed file is passed | ||
|
@@ -132,25 +135,31 @@ sign-layer ({{ $runtime.name }}-{{ $runtime.arch }}): | |
- LAYER_FILE=datadog_lambda_py-{{ $runtime.arch}}-{{ $runtime.python_version }}.zip ./scripts/sign_layers.sh prod | ||
|
||
{{ range $environment_name, $environment := (ds "environments").environments }} | ||
{{ $dotenv := print $runtime.name "_" $runtime.arch "_" $environment_name ".env" }} | ||
|
||
publish-layer-{{ $environment_name }} ({{ $runtime.name }}-{{ $runtime.arch }}): | ||
stage: publish | ||
tags: ["arch:amd64"] | ||
image: registry.ddbuild.io/images/docker:20.10-py3 | ||
rules: | ||
- if: '"{{ $environment_name }}" == "sandbox" && $REGION == "{{ $e2e_region }}" && "{{ $runtime.arch }}" == "amd64"' | ||
when: on_success | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always be sure to publish to the sandbox account in us-west-2 for e2e testing. |
||
- if: '"{{ $environment_name }}" == "sandbox"' | ||
when: manual | ||
allow_failure: true | ||
- if: '$CI_COMMIT_TAG =~ /^v.*/' | ||
artifacts: | ||
reports: | ||
dotenv: {{ $dotenv }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When saved as a dotenv report, this file will get sourced for its env vars in every downstream job. |
||
needs: | ||
{{ if or (eq $environment_name "prod") }} | ||
- sign-layer ({{ $runtime.name }}-{{ $runtime.arch}}) | ||
{{ else }} | ||
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
- check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
- lint python | ||
- unit-test ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
- integration-test ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
#- check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
#- lint python | ||
#- unit-test ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
#- integration-test ({{ $runtime.name }}-{{ $runtime.arch }}) | ||
{{ end }} | ||
dependencies: | ||
{{ if or (eq $environment_name "prod") }} | ||
|
@@ -166,7 +175,7 @@ publish-layer-{{ $environment_name }} ({{ $runtime.name }}-{{ $runtime.arch }}): | |
before_script: | ||
- EXTERNAL_ID_NAME={{ $environment.external_id }} ROLE_TO_ASSUME={{ $environment.role_to_assume }} AWS_ACCOUNT={{ $environment.account }} source ./ci/get_secrets.sh | ||
script: | ||
- STAGE={{ $environment_name }} PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./ci/publish_layers.sh | ||
- STAGE={{ $environment_name }} PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} DOTENV={{ $dotenv }} ./ci/publish_layers.sh | ||
|
||
{{- end }} | ||
|
||
|
@@ -232,3 +241,32 @@ signed layer bundle: | |
- rm -rf datadog_lambda_py-signed-bundle-${CI_JOB_ID} | ||
- mkdir -p datadog_lambda_py-signed-bundle-${CI_JOB_ID} | ||
- cp .layers/datadog_lambda_py-*.zip datadog_lambda_py-signed-bundle-${CI_JOB_ID} | ||
|
||
e2e-test: | ||
stage: e2e | ||
trigger: | ||
project: DataDog/serverless-e2e-tests | ||
strategy: depend | ||
variables: | ||
LANGUAGES_SUBSET: python | ||
# These env vars are inherited from the dotenv reports of the publish-layer jobs | ||
{{- range (ds "runtimes").runtimes }} | ||
{{- if eq .arch "amd64" }} | ||
{{- $version := print (.name | strings.Trim "python") }} | ||
PYTHON_{{ $version }}_VERSION: $PYTHON_{{ $version }}_VERSION | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly pass environment variables from the sourced publish job dotenv file to the downstream job. These env vars are not passed downstream otherwise. |
||
{{- end }} | ||
{{- end }} | ||
needs: {{ range (ds "runtimes").runtimes }} | ||
{{- if eq .arch "amd64" }} | ||
- "publish-layer-sandbox ({{ .name }}-{{ .arch }}): [{{ $e2e_region }}]" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Run after all the publish jobs have completed. |
||
{{- end }} | ||
{{- end }} | ||
|
||
e2e-test-status: | ||
stage: test | ||
image: registry.ddbuild.io/images/docker:20.10-py3 | ||
tags: ["arch:amd64"] | ||
script: | ||
- git clone -b rey.abolofia/status-check --single-branch https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/serverless-e2e-tests | ||
- cd ./serverless-e2e-tests | ||
- ./scripts/check_e2e_status.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,6 +199,8 @@ fi | |
while [ $latest_version -lt $VERSION ]; do | ||
latest_version=$(publish_layer $REGION $layer $aws_cli_python_version_key $layer_path) | ||
printf "[$REGION] Published version $latest_version for layer $layer in region $REGION\n" | ||
latest_arn=$(aws lambda get-layer-version --layer-name $layer --version-number $latest_version --region $REGION --query 'LayerVersionArn' --output text) | ||
printf "[$REGION] Published arn $latest_arn\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Be sur to always print the arn to stdout when publishing layers. The publish gitlab jobs will do a regex search on this stdout to determine the arn for a newly published layer. |
||
|
||
# This shouldn't happen unless someone manually deleted the latest version, say 28, and | ||
# then tries to republish 28 again. The published version would actually be 29, because | ||
|
@@ -209,4 +211,10 @@ while [ $latest_version -lt $VERSION ]; do | |
fi | ||
done | ||
|
||
if [ -n "$DOTENV" ]; then | ||
printf "[$REGION] Exporting layer version to $DOTENV file...\n" | ||
echo "PYTHON_${PYTHON_VERSION/./}_VERSION=$latest_arn" >> "$DOTENV" | ||
cat "$DOTENV" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is where we write the arn to the given dotenv file. This dotenv file will be saved as an artifact on the job. |
||
fi | ||
|
||
printf "[$REGION] Finished publishing layers...\n\n" |
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.
Is this a variable declaration? If so, why not use an environment variable?
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.
Yes, it is just a variable declaration. I hadn't thought of just using an environment variable. I was thinking that this way, the value is just built into the final yaml file, instead of being resolved later, at ci execution time. What are your thoughts on that?
Ah, okay, so one of the places this variable is used is in a
needs
block. According to gitlab docs, variables are not available inneeds
blocks.