-
Notifications
You must be signed in to change notification settings - Fork 28
/
.gitlab-ci.yml
104 lines (91 loc) · 3.25 KB
/
.gitlab-ci.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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
variables:
AWS_DEFAULT_REGION: us-east-1
DEPLOYMENT_BUCKET_NAME: aws-hcls-ml
DEV_BUCKET_PREFIX: dev
MAIN_BUCKET_PREFIX: main
default:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/amazonlinux:latest
include:
- template: Security/Secret-Detection.gitlab-ci.yml
stages:
- lint
- deploy-dev
- test
- deploy-main
################################
# .pre
################################
cfn-lint:
image: python:3.8
stage: lint
before_script:
- python --version # For debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install -U cfn-lint
- pip freeze
script:
- cfn-lint -I infrastructure/cloudformation/*cfn*.yaml -i W3002
cfn-nag:
image:
name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/stelligent/cfn_nag
entrypoint: ['']
stage: lint
script:
- cfn_nag_scan --input-path infrastructure/cloudformation/*.yaml
secret_detection:
stage: lint
variables:
CI_DEBUG_TRACE: "true"
################################
# deploy-dev
################################
push-to-s3-dev:
stage: deploy-dev
before_script:
- yum update -y && yum install -y awscli zip
script:
- zip -r batch-protein-folding.zip . -x .\*/\* -x .gitlab-ci.yml
- aws s3 cp batch-protein-folding.zip s3://$DEPLOYMENT_BUCKET_NAME/$DEV_BUCKET_PREFIX/batch-protein-folding.zip
- aws cloudformation package --template-file infrastructure/cloudformation/batch-protein-folding-cfn-root.yaml --output-template infrastructure/cloudformation/batch-protein-folding-cfn-packaged.yaml --s3-bucket $DEPLOYMENT_BUCKET_NAME --s3-prefix $DEV_BUCKET_PREFIX --region $AWS_DEFAULT_REGION
- aws s3 cp infrastructure/cloudformation/batch-protein-folding-cfn-packaged.yaml s3://$DEPLOYMENT_BUCKET_NAME/$DEV_BUCKET_PREFIX/batch-protein-folding-cfn-packaged.yaml
artifacts:
paths:
- infrastructure/cloudformation/batch-protein-folding-cfn-packaged.yaml
expire_in: 1 day
only:
- dev
################################
# test
################################
test_cfn:
image: python:3.8
stage: test
before_script:
- python --version # For debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install taskcat
- pip freeze
script:
- taskcat test run
only:
- dev
################################
# deploy-main
################################
push-to-s3-main:
stage: deploy-main
before_script:
- yum update -y && yum install -y awscli zip
script:
- zip -r batch-protein-folding.zip . -x .\*/\* -x .gitlab-ci.yml
- aws s3 cp batch-protein-folding.zip s3://$DEPLOYMENT_BUCKET_NAME/$MAIN_BUCKET_PREFIX/batch-protein-folding.zip
- aws cloudformation package --template-file infrastructure/cloudformation/batch-protein-folding-cfn-root.yaml --output-template infrastructure/cloudformation/batch-protein-folding-cfn-packaged.yaml --s3-bucket $DEPLOYMENT_BUCKET_NAME --s3-prefix $MAIN_BUCKET_PREFIX --region $AWS_DEFAULT_REGION
- aws s3 cp infrastructure/cloudformation/batch-protein-folding-cfn-packaged.yaml s3://$DEPLOYMENT_BUCKET_NAME/$MAIN_BUCKET_PREFIX/batch-protein-folding-cfn-packaged.yaml
only:
- main