-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
195 lines (145 loc) · 5.67 KB
/
Makefile
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
INFRA_ARGS =
COMMIT := $(shell git rev-parse --short HEAD)
# Local Commands
local: install-dependencies
pipenv shell
install-dependencies:
pipenv clean
pipenv install --dev
docs-install:
cd docs;npm install
docs-build: docs-install
cd docs;npm run build
docs-run: docs-build
cd docs;npm run dev
local-grafana:
docker run -d -p 3000:3000 mirror.gcr.io/grafana/grafana:latest
# Test Commands
unittest:
pipenv run pytest -m 'not integration' tests/src tests/publisher
integration-test:
pipenv run pytest -m 'integration' tests/src tests/publisher
test:
pipenv run pytest --cov=src --cov=publisher --cov-fail-under=81 --cov-report term-missing tests/src tests/publisher
aws-test:
pipenv run pytest -m 'not gcp' --cov=src --cov=publisher --cov-fail-under=75 --cov-report term-missing tests/src tests/publisher
gcp-test:
pipenv run pytest -m 'not aws' --cov=src --cov=publisher --cov-fail-under=75 --cov-report term-missing tests/src tests/publisher
watch:
ptw -- -m 'not integration' tests/src tests/publisher
e2e:
cd tests/; pipenv run behave
aws-e2e:
cd tests/; pipenv run behave --tags=aws
gcp-e2e:
cd tests/; pipenv run behave --tags=gcp
# Infrastructure Commands
# General
clean:
cd infrastructure/aws; rm -rf cdktf.out
cd infrastructure/gcp; rm -rf cdktf.out
synth: aws-synth gcp-synth
plan: aws-plan-all gcp-plan-all
deploy: aws-deploy-all gcp-deploy-all
destroy: aws-destroy-all gcp-destroy-all
# AWS
aws-build-dependencies:
@echo "\n\n---AWS-BUILD-DEPENDENCIES---\n"
rsync -avu $(shell pwd)/src $(shell pwd)/infrastructure/aws/controller_core
pipenv requirements | tee requirements.txt
pip install -r requirements.txt --target=$(shell pwd)/infrastructure/aws/controller_core
pip install boto3 --target=$(shell pwd)/infrastructure/aws/api_key_rotation
cd infrastructure/aws; cdktf provider add grafana/grafana
aws-synth: aws-build-dependencies
@echo "\n\n---AWS-SYNTH---\n"
cd infrastructure/aws;cdktf synth
aws-plan-core:
@echo "\n\n---AWS-PLAN-CORE---\n"
cd infrastructure/aws;cdktf plan aws_core
aws-plan-grafana:
@echo "\n\n---AWS-PLAN-GRAFANA---\n"
cd infrastructure/aws;cdktf plan aws_grafana_dashboard
aws-plan-all: aws-build-dependencies aws-plan-core aws-plan-grafana aws-plan-convert
aws-plan-convert:
@echo "\n\n---Converting AWS plans file to json---\n"
cd infrastructure/aws/cdktf.out/stacks; \
find . -type f -name 'plan' -exec dirname {} \; | while read file; do \
cd "$$file"; \
terraform show -json plan > plan.json; \
cd -; \
done
aws-deploy-core:
@echo "\n\n---AWS-DEPLOY-CORE---\n"
cd infrastructure/aws;cdktf deploy aws_core ${INFRA_ARGS}
aws-deploy-grafana:
@echo "\n\n---AWS-DEPLOY-GRAFANA---\n"
cd infrastructure/aws;cdktf deploy aws_grafana_dashboard ${INFRA_ARGS}
aws-deploy-all:
@echo "\n\n---AWS-DEPLOY-ALL---\n"
cd infrastructure/aws;cdktf deploy aws_core aws_grafana_dashboard ${INFRA_ARGS}
aws-destroy-core:
@echo "\n\n---AWS-DESTROY-CORE---\n"
cd infrastructure/aws;cdktf destroy aws_core
aws-destroy-grafana:
@echo "\n\n---AWS-DESTROY-GRAFANA---\n"
cd infrastructure/aws;cdktf destroy aws_grafana_dashboard
aws-destroy-all:
@echo "\n\n---AWS-DESTROY-ALL---\n"
cd infrastructure/aws;cdktf destroy aws_core aws_grafana_dashboard
# GCP
gcp-build-dependencies:
@echo "\n\n---GCP-BUILD-DEPENDENCIES---\n"
cd infrastructure/gcp; cdktf provider add grafana/grafana
gcp-core-image:
@echo "\n\n---GCP-BUILD-IMAGE---\n"
gcloud auth configure-docker australia-southeast1-docker.pkg.dev
pipenv requirements | tee requirements.txt
docker buildx build --platform=linux/amd64 -f infrastructure/gcp/Core.Dockerfile . --push -t australia-southeast1-docker.pkg.dev/contino-squad0-fc/flight-controller-event-receiver/event_receiver:${COMMIT}
gcp-grafana-image:
@echo "\n\n---BUILD-GRAFANA-IMAGE---\n"
cd infrastructure/gcp
gcloud auth configure-docker australia-southeast1-docker.pkg.dev
docker buildx build --platform=linux/amd64 --build-arg GRAFANA_PASSWORD=${GRAFANA_PASSWORD} -f infrastructure/gcp/Grafana.Dockerfile . --push -t australia-southeast1-docker.pkg.dev/contino-squad0-fc/flight-controller-event-receiver/grafana:${COMMIT}
gcp-synth: gcp-build-dependencies
@echo "\n\n---GCP-SYNTH---\n"
cd infrastructure/gcp; cdktf synth
gcp-plan-base:
@echo "\n\n---GCP-PLAN-BASE---\n"
cd infrastructure/gcp;cdktf plan gcp_base
gcp-plan-core:
@echo "\n\n---GCP-PLAN-CORE---\n"
cd infrastructure/gcp;cdktf plan gcp_core
gcp-plan-grafana:
@echo "\n\n---GCP-PLAN-GRAFANA---\n"
cd infrastructure/gcp;cdktf plan gcp_grafana
gcp-plan-all: gcp-build-dependencies gcp-plan-base gcp-plan-core gcp-plan-convert
gcp-plan-convert:
@echo "\n\n---Converting GCP plans file to json---\n"
cd infrastructure/gcp/cdktf.out/stacks; \
find . -type f -name 'plan' -exec dirname {} \; | while read file; do \
cd "$$file"; \
terraform show -json plan > plan.json; \
cd -; \
done
gcp-deploy-base:
@echo "\n\n---GCP-DEPLOY-BASE---\n"
cd infrastructure/gcp;cdktf deploy gcp_base ${INFRA_ARGS}
gcp-deploy-core:
@echo "\n\n---GCP-DEPLOY-CORE---\n"
cd infrastructure/gcp;cdktf deploy gcp_base gcp_core ${INFRA_ARGS}
gcp-deploy-grafana:
@echo "\n\n---GCP-DEPLOY-GRAFANA---\n"
cd infrastructure/gcp;cdktf deploy gcp_grafana ${INFRA_ARGS}
gcp-deploy-all: gcp-deploy-base gcp-core-image gcp-grafana-image gcp-deploy-core gcp-deploy-grafana
gcp-destroy-base:
@echo "\n\n---GCP-DESTROY-BASE---\n"
cd infrastructure/gcp;cdktf destroy gcp_base
gcp-destroy-core:
@echo "\n\n---GCP-DESTROY-CORE---\n"
cd infrastructure/gcp;cdktf destroy gcp_core
gcp-destroy-grafana:
@echo "\n\n---GCP-DESTROY-GRAFANA---\n"
cd infrastructure/gcp;cdktf destroy gcp_grafana
gcp-destroy-all:
@echo "\n\n---GCP-DESTROY-ALL---\n"
cd infrastructure/gcp;cdktf destroy gcp_base gcp_core gcp_grafana