|
2 | 2 | - test |
3 | 3 | - compile |
4 | 4 | - build |
| 5 | + - integration-tests |
5 | 6 | - self-monitoring |
6 | 7 | - sign |
7 | 8 | - publish |
@@ -322,3 +323,152 @@ signed layer bundle: |
322 | 323 | - rm -rf datadog_extension-signed-bundle-${CI_JOB_ID} |
323 | 324 | - mkdir -p datadog_extension-signed-bundle-${CI_JOB_ID} |
324 | 325 | - cp .layers/datadog_extension-*.zip datadog_extension-signed-bundle-${CI_JOB_ID} |
| 326 | + |
| 327 | +# Integration Tests - Publish arm64 layer with integration test prefix |
| 328 | +publish integration layer (arm64): |
| 329 | + stage: integration-tests |
| 330 | + tags: ["arch:amd64"] |
| 331 | + image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION} |
| 332 | + rules: |
| 333 | + - when: on_success |
| 334 | + needs: |
| 335 | + - layer (arm64) |
| 336 | + dependencies: |
| 337 | + - layer (arm64) |
| 338 | + variables: |
| 339 | + LAYER_NAME_BASE_SUFFIX: "" |
| 340 | + ARCHITECTURE: arm64 |
| 341 | + LAYER_FILE: datadog_extension-arm64.zip |
| 342 | + REGION: us-east-1 |
| 343 | + ADD_LAYER_VERSION_PERMISSIONS: "0" |
| 344 | + AUTOMATICALLY_BUMP_VERSION: "1" |
| 345 | + {{ with $environment := (ds "environments").environments.sandbox }} |
| 346 | + before_script: |
| 347 | + - EXTERNAL_ID_NAME={{ $environment.external_id }} ROLE_TO_ASSUME={{ $environment.role_to_assume }} AWS_ACCOUNT={{ $environment.account }} source .gitlab/scripts/get_secrets.sh |
| 348 | + - export PIPELINE_LAYER_SUFFIX="ARM-${CI_COMMIT_SHORT_SHA}" |
| 349 | + - echo "Publishing layer with suffix - ${PIPELINE_LAYER_SUFFIX}" |
| 350 | + script: |
| 351 | + - .gitlab/scripts/publish_layers.sh |
| 352 | + - LAYER_ARN=$(aws lambda list-layer-versions --layer-name "Datadog-Extension-ARM-${CI_COMMIT_SHORT_SHA}" --query 'LayerVersions[0].LayerVersionArn' --output text --region us-east-1) |
| 353 | + - echo "Published layer ARN - ${LAYER_ARN}" |
| 354 | + {{ end }} |
| 355 | + |
| 356 | +# Integration Tests - Deploy CDK stacks with commit hash prefix |
| 357 | +integration-deploy: |
| 358 | + stage: integration-tests |
| 359 | + tags: ["arch:amd64"] |
| 360 | + image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION} |
| 361 | + rules: |
| 362 | + - when: on_success |
| 363 | + needs: |
| 364 | + - publish integration layer (arm64) |
| 365 | + variables: |
| 366 | + IDENTIFIER: ${CI_COMMIT_SHORT_SHA} |
| 367 | + AWS_DEFAULT_REGION: us-east-1 |
| 368 | + {{ with $environment := (ds "environments").environments.sandbox }} |
| 369 | + before_script: |
| 370 | + - EXTERNAL_ID_NAME={{ $environment.external_id }} ROLE_TO_ASSUME={{ $environment.role_to_assume }} AWS_ACCOUNT={{ $environment.account }} source .gitlab/scripts/get_secrets.sh |
| 371 | + - curl -fsSL https://deb.nodesource.com/setup_20.x | bash - |
| 372 | + - apt-get install -y nodejs |
| 373 | + - cd integration-tests |
| 374 | + - npm ci |
| 375 | + {{ end }} |
| 376 | + script: |
| 377 | + - echo "Deploying CDK stacks with identifier ${IDENTIFIER}..." |
| 378 | + - export EXTENSION_LAYER_ARN=$(aws lambda list-layer-versions --layer-name "Datadog-Extension-ARM-${CI_COMMIT_SHORT_SHA}" --query 'LayerVersions[0].LayerVersionArn' --output text --region us-east-1) |
| 379 | + - echo "Using integration test layer - ${EXTENSION_LAYER_ARN}" |
| 380 | + - export CDK_DEFAULT_ACCOUNT=$(aws sts get-caller-identity --query Account --output text) |
| 381 | + - export CDK_DEFAULT_REGION=us-east-1 |
| 382 | + - npm run build |
| 383 | + - npx cdk deploy "integ-$IDENTIFIER-*" --require-approval never |
| 384 | + |
| 385 | +# Integration Tests - Run Jest test suite |
| 386 | +integration-test: |
| 387 | + stage: integration-tests |
| 388 | + tags: ["arch:amd64"] |
| 389 | + image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION} |
| 390 | + rules: |
| 391 | + - when: on_success |
| 392 | + needs: |
| 393 | + - integration-deploy |
| 394 | + variables: |
| 395 | + IDENTIFIER: ${CI_COMMIT_SHORT_SHA} |
| 396 | + DD_SITE: datadoghq.com |
| 397 | + {{ with $environment := (ds "environments").environments.sandbox }} |
| 398 | + before_script: |
| 399 | + - EXTERNAL_ID_NAME={{ $environment.external_id }} ROLE_TO_ASSUME={{ $environment.role_to_assume }} AWS_ACCOUNT={{ $environment.account }} source .gitlab/scripts/get_secrets.sh |
| 400 | + - curl -fsSL https://deb.nodesource.com/setup_20.x | bash - |
| 401 | + - apt-get install -y nodejs |
| 402 | + - cd integration-tests |
| 403 | + - npm ci |
| 404 | + script: |
| 405 | + - echo "Running integration tests with identifier ${IDENTIFIER}..." |
| 406 | + - npm run test:ci |
| 407 | + {{ end }} |
| 408 | + artifacts: |
| 409 | + when: always |
| 410 | + paths: |
| 411 | + - integration-tests/test-results/ |
| 412 | + reports: |
| 413 | + junit: integration-tests/test-results/junit.xml |
| 414 | + expire_in: 30 days |
| 415 | + |
| 416 | +# Integration Tests - Cleanup stacks |
| 417 | +integration-cleanup-stacks: |
| 418 | + stage: integration-tests |
| 419 | + tags: ["arch:amd64"] |
| 420 | + image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION} |
| 421 | + when: always |
| 422 | + rules: |
| 423 | + - when: always |
| 424 | + needs: |
| 425 | + - integration-test |
| 426 | + variables: |
| 427 | + IDENTIFIER: ${CI_COMMIT_SHORT_SHA} |
| 428 | + {{ with $environment := (ds "environments").environments.sandbox }} |
| 429 | + before_script: |
| 430 | + - EXTERNAL_ID_NAME={{ $environment.external_id }} ROLE_TO_ASSUME={{ $environment.role_to_assume }} AWS_ACCOUNT={{ $environment.account }} source .gitlab/scripts/get_secrets.sh |
| 431 | + - curl -fsSL https://deb.nodesource.com/setup_20.x | bash - |
| 432 | + - apt-get install -y nodejs |
| 433 | + - cd integration-tests |
| 434 | + {{ end }} |
| 435 | + script: |
| 436 | + - echo "Destroying CDK stacks with identifier ${IDENTIFIER}..." |
| 437 | + - npx cdk destroy "integ-$IDENTIFIER-*" --force || echo "Failed to destroy some stacks, but continuing..." |
| 438 | + |
| 439 | +# Integration Tests - Cleanup layer |
| 440 | +integration-cleanup-layer: |
| 441 | + stage: integration-tests |
| 442 | + tags: ["arch:amd64"] |
| 443 | + image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION} |
| 444 | + when: always |
| 445 | + rules: |
| 446 | + - when: always |
| 447 | + needs: |
| 448 | + - integration-cleanup-stacks |
| 449 | + variables: |
| 450 | + IDENTIFIER: ${CI_COMMIT_SHORT_SHA} |
| 451 | + {{ with $environment := (ds "environments").environments.sandbox }} |
| 452 | + before_script: |
| 453 | + - EXTERNAL_ID_NAME={{ $environment.external_id }} ROLE_TO_ASSUME={{ $environment.role_to_assume }} AWS_ACCOUNT={{ $environment.account }} source .gitlab/scripts/get_secrets.sh |
| 454 | + {{ end }} |
| 455 | + script: |
| 456 | + - echo "Deleting integration test layer with identifier ${IDENTIFIER}..." |
| 457 | + - | |
| 458 | + LAYER_NAME="Datadog-Extension-${IDENTIFIER}" |
| 459 | + echo "Looking for layer: ${LAYER_NAME}" |
| 460 | + |
| 461 | + # Get all versions of the layer |
| 462 | + VERSIONS=$(aws lambda list-layer-versions --layer-name "${LAYER_NAME}" --query 'LayerVersions[*].Version' --output text --region us-east-1 2>/dev/null || echo "") |
| 463 | + |
| 464 | + if [ -z "$VERSIONS" ]; then |
| 465 | + echo "No versions found for layer ${LAYER_NAME}" |
| 466 | + else |
| 467 | + echo "Found versions: ${VERSIONS}" |
| 468 | + for VERSION in $VERSIONS; do |
| 469 | + echo "Deleting ${LAYER_NAME} version ${VERSION}..." |
| 470 | + aws lambda delete-layer-version --layer-name "${LAYER_NAME}" --version-number "${VERSION}" --region us-east-1 || echo "Failed to delete version ${VERSION}, continuing..." |
| 471 | + done |
| 472 | + echo "Successfully deleted all versions of ${LAYER_NAME}" |
| 473 | + fi |
| 474 | + |
0 commit comments