generated from dynatrace-oss/template-project
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.travis.yml
138 lines (118 loc) · 10.9 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
os: linux
dist: jammy
addons:
apt:
sources:
- sourceline: 'deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable'
packages:
- docker-buildx-plugin
if: fork = false
language: shell
notifications:
email:
recipients:
secure: ej6/5zNDDQUhSqobhxnp+x23cAnd6Jg9Fu6Dh7PFtMeHfn8xHkLDb0qsZ75B9vRoI1cwuTTw7hzmxkA4EbAdr8Sl/mZMZJOmHLUKZ6zz/Or9Um0Cg7be1lzBogXVXE/zXnhy4nYZ7ga3VbK0553L6aBfCbkiixy7fiR8Hvt0GgME3Gp3lgpj4S7Hjdhx3IiKFAW0zuzQPrlGVjFLmxzTtEp+ActSiaBghB59qbHhqTmbj4UPMZdKhQV/Heho18eYmpk2y7uYo+aCFLjDhtmzfnhZCRG4ZNTO7MfyailUMcu3MGss9CA9NPmRGaEUHR+Qu2rIe66aDdJaQX1zifSVvV3NW74vLJ1AbqOcGK2ZdrjPSrG78AWX+Cvb31ZjHoo6+5QUa8hfcOedmbBj6hdn+4ev59FknjIC5JjEzq6keflhPbOfaGlIMbZCwoAnk+Ulc5ZEAnRHrAQ1UG+w/Zr/DhtoC1T13uG6WGbSESIqr1U3fV70cs6Uh2JPRU4MUs7WqY3erhtPfVtLbnM+9YCA0JGHkT8CB2PeVVjkPvH3/iCOoEo0VY1/v6ppQugsO5QdoVw48XmW4UEHVQOhemwQzDcAVRnBMxsCDaOrf7+Oh7yUHuOhLYp/UXKkqOIqoq2FOPMXxqSqxhbs4gfXMqcQrB4GUDJxWc1Jg5q15bowjhQ=
on_success: never
on_failure: always
slack:
secure: TVc7fv1HD7wnuS3ZDqiGaUYqXEYLo8e8Bh8Wi25HwdvQahTLO3N58+92IdfL/duvAePmp7pQZ9iPH/AmWTDphCmHAIZeoBzjShcTdFRumWwwnE1UobYOncDnIulnCURi+x2yroZ4LMTAmbfDEP6Tk+93CaOhw/Dv5uB42Ili/TFe9yid7OvamP47rLBmZuyCnO6DOcn1nvhOL5+7eOz6VedpBCzfRliOi+T9c762HXXVFV/WUKWkAm4wMfKwCamSoR6XKIPOP9Wq7F5SqTnU6YOexjzsREoBXtN1IRkTsk8IbWFnNC7GDZzndXlr39hbbCv3eS60IminJRFckP1sfTOCJW0hyvTuLDPSC2nEoGlj+JHwmyWiTveqgcldpP9jK1PLRy/iAGbLRuuj7keEORsskUNk9o3WyOu3hHHkQgoI0HItnVBzYfgL/AO7fxm1wfX4YfWjQlXuqZ0rGAuG4bj08ovamHenM2PzQG6n7NVNHxLeYWHo/meJ+qoETJ0T4kYKqjusGkSsX7n+qngl/b+0RHPiO6NmSnJzTP8ptLGPKI54+n4RsTmAynL363DH0cioGK97VWRWTmVWTSGinAz3Xz97IhBknMkaar3A7LqktSY/zAbUm78YzStB2uTLL2xzJVajZdu6CobYRgBhGL2HiLtry06jwVt4moez4Yg=
env:
global:
- secure: rQuBF5LJD/GVwaypyvO8YsGry6dLH9K66uKx4GnYsXcAe7AazPkAR70ICyDHSVZ4Ow0/06FF/6iMaKZBFcZxyhy1ikQkiy1O181LdVInWxERsnbd6Xk7/jCsXv+mYx4yR7wX6bpcGBj9rWM6eW0rIgUVy3p3gj8H/yQViZys/iigcdSfKoU1GxlplDRxILWY9G2GXoupwJPefa7OVP1XZr6jo1O12uX8DDtAe13DFep+alCdzAOTM4B4d795tzbZYM93Iba1jp20V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cepnUEhsO5xUJXzOpxL5OPPlewOI8xbGAG2bandCV9XlvSxdR+TkE5lgVsiT7abBH0ppVZs4z0jIPrLkH857nJhWHE3+5xutIs8c/nfV6zeASUQ/nIFS1CscOZbWRN1Doys2LEBb74ogJl8deW9kxcTcP0bxuuJGV56WkC0Zertsqbn7wMEHIUhnVjWItQBvyKbmuu2+WG+ol0U25UJjw7q9/BQ6qdlyBKlfBuF+wIHsfvk7j0hxvSQeqIbEbS7RtiYzwlV+QBF6+QArGGvC7khtgdT0h+7pQ+cdDt7hUk9dNLq1rdKejANFUWGUH1hsL56qEg1RzckV3YGv10=
before_install:
- |
# before_install: Install AWS CLI and download Lambda Layers
# Get CPU architecture
if [[ $TRAVIS_CPU_ARCH == "amd64" ]]; then export LAMBDA_ARCH=x86_64; export AWSCLI_ARCH=x86_64; elif [[ ${TRAVIS_CPU_ARCH:0:5} == "arm64" ]]; then export LAMBDA_ARCH=arm64; export AWSCLI_ARCH=aarch64; fi
# install yq and AWS CLI
./scripts/install_tools.sh
# Get dependent lambda layers
bash get-required-lambda-layers.sh
# Define env vars
export COMMIT=${TRAVIS_COMMIT:0:7}
export STACK_NAME=e2e-dt-aws-s3-log-forwarder-${TRAVIS_BUILD_ID}
export E2E_TESTING_BUCKET_NAME=dynatrace-aws-s3-log-forwarder-e2e-testing
# CloudFormation Mappings don't support "_" in names, so we need to match mapping name x86
export MAPPING=$(if [[ $LAMBDA_ARCH == "x86_64" ]];then echo "x86"; else echo $LAMBDA_ARCH; fi )
export LAMBDA_BASE_IMAGE_TAG=$(cat template.yaml | yq ".Mappings.LambdaBaseImageMap.${MAPPING}.Tag")
jobs:
include:
- stage: validate-cfn-templates
name: Validate CloudFormation Templates
script:
- aws cloudformation validate-template --template-body file://template.yaml
- aws cloudformation validate-template --template-body file://dynatrace-aws-s3-log-forwarder-configuration.yaml
- aws cloudformation validate-template --template-body file://dynatrace-aws-s3-log-forwarder-s3-bucket-configuration.yaml
- aws cloudformation validate-template --template-body file://eventbridge-cross-region-or-account-forward-rules.yaml
- stage: unit_tests
name: Unit Tests
services:
- docker
script:
# Build container image with dev dependencies
- |
docker build --progress=plain -t queueprocessingfunction:test --build-arg ARCH=$LAMBDA_ARCH \
--build-arg LAMBDA_BASE_IMAGE_TAG=${LAMBDA_BASE_IMAGE_TAG} --build-arg ENABLE_LAMBDA_INSIGHTS="false" --build-arg ENV="DEV" .
# Run unit tests
- |
docker run --entrypoint="" --mount type=bind,source=${TRAVIS_BUILD_DIR}/tests,target=/var/task/tests --env-file=tests/unit/unit_test.env \
queueprocessingfunction:test python -m unittest discover -s tests -b
- stage: build
name: Build
script:
- ./scripts/update_version.sh
# Build container image
- |
docker build -t dynatrace-aws-s3-log-forwarder:${COMMIT}-${LAMBDA_ARCH} . --build-arg ARCH=$LAMBDA_ARCH \
--build-arg ENABLE_LAMBDA_INSIGHTS="false" --build-arg LAMBDA_BASE_IMAGE_TAG=${LAMBDA_BASE_IMAGE_TAG}
# Log in to ECR
- aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REPOSITORY_URL
# Push image
- docker tag dynatrace-aws-s3-log-forwarder:${COMMIT}-${LAMBDA_ARCH} ${ECR_REPOSITORY_URL}/dynatrace-aws-s3-log-forwarder:${COMMIT}-${LAMBDA_ARCH}
- docker push ${ECR_REPOSITORY_URL}/dynatrace-aws-s3-log-forwarder:${COMMIT}-${LAMBDA_ARCH}
- stage: end-to-end-test
name: End-to-end deployment test
if: fork = false AND ( branch == main OR type == pull_request )
install:
- pip install argparse requests
script:
- ./tests/e2e/deploy_forwarder_for_validation.sh
# Write logs to S3 and allow time for ingestion
- |
echo "[$(date -u '+%Y-%m-%dT%H:%M:%SZ')] E2E testing validation log entry" > ${TRAVIS_BUILD_ID}.log
aws s3 cp ${TRAVIS_BUILD_ID}.log s3://${E2E_TESTING_BUCKET_NAME}/test/${TRAVIS_BUILD_ID}/validation/test_log.log
sleep 120
# Validate log entry
- ./tests/e2e/validate_logs_exist.py --bucket ${E2E_TESTING_BUCKET_NAME} --key test/${TRAVIS_BUILD_ID}/validation/test_log.log
after_script:
- ./tests/e2e/clean_up_resources.sh
- stage: release-container-image
name: Release Container Image
if: tag =~ /^v.*$/
env:
secure: "pqJSEsFc/9Pu6srukaPDG0DiBlejA0xzRTNGKjNUAqQtFQGi9LbpkZ2APjNcIu2z4/T8CjuFdCOnpJWvv++LHh3+qUXD4RODcxXQRlRmvkcF1oePDMU172VlkTiXPpA2rBFsPgyMzsUnbCnYAvGmlJ4MgzaAzzOE/F96GJEBJXwMc8KtZwK2x46GYzAhot9F62ePUkofioiSEWjAHBIrfQP1xblUutp5BPPU53gfRM/RSrTMpc0K/gxy9fvs/cYTXggUJgGGR8BdHuzRwWAwJwDJlO+0rhh/W2z6J83QCePshPn5he09cRtLjp5MRpsOIalLi8fTy0qQyVsvDtUEbhoJW/8ouEjTW02W7f/gcmINe/D77qJgADE+yJllb5Z4I6VkscJPrU3xodAcufT3qr2+8HL1imwHOc5gbjjxFhkVetMaiuz7fydgG9+AnXnPqyuwo000gwh/HVfZDC4iQltp+ed5+I//1jyUsMyOOw0COmM1fI0jYQj/1sa82IdrpzybYwPx7TBJLTlq1acR9yrSYWDNj3/MRdycnbqyJ3ImP3luX+CrkzA2W3PgK9u8Ud7QM02WczuKh2ajRsoodL249NMiV1He1pS4G0PiisfLSdyfc4V58fojck9Vb2J9HV5cZ7/2gnDFkc6I2zWPJXp9S8/PA9Mj+wnQMTKg4DQ="
script:
# Log in to ECR Private repo
- aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REPOSITORY_URL
# Log in to Docker Hub
- echo $DOCKER_HUB_TOKEN | docker login --username dts3logforwarderuser --password-stdin docker.io
# Log in to ECR Public
- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/dynatrace-oss
# pull from ECR and push to Docker hub: dynatrace/dynatrace-aws-s3-log-forwarder:vx.y.z
- docker pull ${ECR_REPOSITORY_URL}/dynatrace-aws-s3-log-forwarder:${COMMIT}-${LAMBDA_ARCH}
- docker tag ${ECR_REPOSITORY_URL}/dynatrace-aws-s3-log-forwarder:${COMMIT}-${LAMBDA_ARCH} dynatrace/dynatrace-aws-s3-log-forwarder:${TRAVIS_TAG}-${LAMBDA_ARCH}
- docker push dynatrace/dynatrace-aws-s3-log-forwarder:${TRAVIS_TAG}-${LAMBDA_ARCH}
# Push to ECR Public
- docker tag ${ECR_REPOSITORY_URL}/dynatrace-aws-s3-log-forwarder:${COMMIT}-${LAMBDA_ARCH} public.ecr.aws/dynatrace-oss/dynatrace-aws-s3-log-forwarder:${TRAVIS_TAG}-${LAMBDA_ARCH}
- docker push public.ecr.aws/dynatrace-oss/dynatrace-aws-s3-log-forwarder:${TRAVIS_TAG}-${LAMBDA_ARCH}
# Push templates to S3
- ./scripts/update_version.sh
- aws s3 cp template.yaml s3://dynatrace-aws-s3-log-forwarder-assets/${TRAVIS_TAG}/
- aws s3 cp dynatrace-aws-s3-log-forwarder-configuration.yaml s3://dynatrace-aws-s3-log-forwarder-assets/${TRAVIS_TAG}/
- aws s3 cp dynatrace-aws-s3-log-forwarder-s3-bucket-configuration.yaml s3://dynatrace-aws-s3-log-forwarder-assets/${TRAVIS_TAG}/
- aws s3 cp eventbridge-cross-region-or-account-forward-rules.yaml s3://dynatrace-aws-s3-log-forwarder-assets/${TRAVIS_TAG}/
- zip templates.zip template.yaml dynatrace-aws-s3-log-forwarder-configuration.yaml dynatrace-aws-s3-log-forwarder-s3-bucket-configuration.yaml eventbridge-cross-region-or-account-forward-rules.yaml
- aws s3 cp templates.zip s3://dynatrace-aws-s3-log-forwarder-assets/${TRAVIS_TAG}/