-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
148 lines (134 loc) · 3.41 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
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
138
139
140
141
142
143
144
145
146
147
148
---
include:
- project: invenia/gitlab-ci-helper
file: /templates/python.yml
- project: invenia/gitlab-ci-helper
file: /templates/py-check.yml
- project: invenia/gitlab-ci-helper
file: /templates/teardown.yml
stages:
- setup
- test
- teardown
- deploy
variables:
STACK_NAME_PREFIX: sandbox-lambdalayers
AWS_DEFAULT_REGION: us-east-1
TOX_TESTENV_PASSENV: AWS_DEFAULT_REGION STACKNAME AWS_SHARED_CREDENTIALS_FILE AWS_PROFILE
AMAZON_LINUX_IMAGE: amazonlinux:2
# Force Docker authentication to be isolated to a pipeline
DOCKER_CONFIG: $CI_PROJECT_DIR/.docker
.setup: &setup |
echo "$common_functions" > common && source common
# Variables that require shell execution or depend on a variable that does
.runtime_variables: &runtime_variables
|
# Declare runtime variables
STACK_NAME=$(stack_name $STACK_NAME_PREFIX)
ACCOUNT_ID=$(aws_account_id)
.install_cred_helper: &install_cred_helper
|
curl -sS -o julia-ci https://gitlab.invenia.ca/invenia/gitlab-ci-helper/raw/master/julia-ci
chmod +x julia-ci
./julia-ci install-cred-helper
.docker_test_3: &docker_test_3
stage: test
tags:
- amzn2
- docker-build
before_script:
- *setup
- enter_python_venv
- *runtime_variables
- install_cloudspy
- pip install tox
- docker --version
extends: .save_test_coverage
"Setup Environment":
stage: setup
except:
- tags
- master
- /^.+\/.*master$/ # e.g. jh/validate-master
when: always
environment:
name: branch/$CI_COMMIT_REF_SLUG
on_stop: "Delete Environment"
script:
- echo "Setting up environment"
"Create Stack":
stage: setup
tags:
- docker-ci
- ci-account
image: $AMAZON_LINUX_IMAGE
before_script:
- *setup
- *runtime_variables
- yum -y update
- install_awscli
- install_cloudspy
script:
- aws cloudformation validate-template --template-body file://tests/stack.yml
- |
aws-deploy-stack \
--role-arn arn:aws:iam::${ACCOUNT_ID}:role/CloudFormationAdmin \
--stack-name $STACK_NAME \
--template-file ./tests/stack.yml \
--wait \
--params CIRoleArn=arn:aws:iam::${ACCOUNT_ID}:role/GitLabCIRunnerRole
"Test Python 3 (Offline)":
extends: .docker_test_3
needs:
- Code Format Check
script:
- tox -re py3-offline
"Test Python 3 (Online)":
extends: .docker_test_3
script:
- assume_test_role
- tox -re py3-online
"Upload to Private PyPi":
extends: .upload_to_private_pypi
.delete: &delete
tags:
- docker-ci
- ci-account
image: $AMAZON_LINUX_IMAGE
before_script:
- *setup
- *runtime_variables
- install_awscli
- install_cloudspy
- assume_test_role
script:
- eval $(aws-stack-outputs $STACKNAME)
- unset AWS_PROFILE # Switch to back to CI runner role
- |
aws cloudformation delete-stack \
--role-arn arn:aws:iam::${ACCOUNT_ID}:role/CloudFormationAdmin \
--stack-name $STACK_NAME
- aws cloudformation wait stack-delete-complete --stack-name $STACK_NAME
"Delete Environment":
stage: teardown
except:
- tags
- master
- /^.+\/.*master$/
when: manual
environment:
name: branch/$CI_COMMIT_REF_SLUG
action: stop
dependencies:
- "Create Stack"
variables:
GIT_STRATEGY: none # Avoid checking out a branch after deletion
<<: *delete
"Delete Stack":
stage: teardown
only:
- tags
- master
- /^.+\/.*master$/
when: always
<<: *delete