-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
75 lines (60 loc) · 3.95 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
package:
# This target should be executed by passing in an argument representing the version of the artifacts we are packaging
# For example: make package version=r1
docker compose run --rm documentation swagger generate spec -i ../../swaggerui/tags.yml -o ../../swaggerui/swagger.json -m
docker build -t packaging -f Dockerfiles/Dockerfile.package .
docker run --rm \
-e BCDA_GPG_RPM_PASSPHRASE='${BCDA_GPG_RPM_PASSPHRASE}' \
-e GPG_RPM_USER='${GPG_RPM_USER}' \
-e GPG_RPM_EMAIL='${GPG_RPM_EMAIL}' \
-e GPG_PUB_KEY_FILE='${GPG_PUB_KEY_FILE}' \
-e GPG_SEC_KEY_FILE='${GPG_SEC_KEY_FILE}' \
-v ${PWD}:/go/src/github.com/CMSgov/bcda-ssas-app packaging $(version)
lint:
docker compose -f docker-compose.test.yml run --rm tests golangci-lint -e SA1029 --timeout 10m0s -v run ./...
docker compose -f docker-compose.test.yml run --rm tests gosec ./...
# The following vars are available to tests needing SSAS admin credentials; currently they are used in smoke-test-ssas, postman-ssas, and unit-test-ssas
# Note that these variables should only be used for smoke tests, must be set before the api starts, and cannot be changed after the api starts
SSAS_ADMIN_CLIENT_ID ?= 31e029ef-0e97-47f8-873c-0e8b7e7f99bf
SSAS_ADMIN_CLIENT_SECRET := $(shell docker compose run --rm ssas sh -c 'ssas --reset-secret --client-id=$(SSAS_ADMIN_CLIENT_ID)'|tail -n1)
smoke-test:
docker compose -f docker-compose.test.yml run --rm postman_test test/postman_test/SSAS_Smoke_Test.postman_collection.json -e test/postman_test/local.postman_environment.json --global-var "token=$(token)" --global-var adminClientId=$(SSAS_ADMIN_CLIENT_ID) --global-var adminClientSecret=$(SSAS_ADMIN_CLIENT_SECRET) --global-var ssas_client_assertion_aud=$(SASS_CLIENT_ASSERTION_AUD)
postman:
docker compose -f docker-compose.test.yml run --rm postman_test test/postman_test/SSAS.postman_collection.json -e test/postman_test/local.postman_environment.json --global-var adminClientId=$(SSAS_ADMIN_CLIENT_ID) --global-var adminClientSecret=$(SSAS_ADMIN_CLIENT_SECRET) --global-var ssas_client_assertion_aud=$(SASS_CLIENT_ASSERTION_AUD)
migrations-test:
docker compose -f docker-compose.test.yml run --rm tests bash ops/migrations_test.sh
start-db:
docker compose up -d db
unit-test: start-db
docker compose -f docker-compose.test.yml run --rm tests bash unit_test.sh
test:
$(MAKE) lint
$(MAKE) unit-test
$(MAKE) postman
$(MAKE) smoke-test
$(MAKE) migrations-test
load-fixtures:
docker compose -f docker-compose.migrate.yml run --rm migrate -database "postgres://postgres:toor@db:5432/bcda?sslmode=disable" -path /go/src/github.com/CMSgov/bcda-ssas-app/db/migrations up
docker compose -f docker-compose.yml run ssas sh -c 'ssas --add-fixture-data'
docker-build:
docker compose build --force-rm
docker compose -f docker-compose.test.yml build --force-rm
docker-bootstrap:
$(MAKE) docker-build
docker compose up -d
sleep 40
$(MAKE) load-fixtures
dbdocs: start-db load-fixtures
docker run --rm -v $PWD:/work -w /work --network bcda-ssas-app_default ghcr.io/k1low/tbls doc --rm-dist "postgres://postgres:toor@db:5432/bcda?sslmode=disable" dbdocs/bcda
.PHONY: docker-build docker-bootstrap load-fixtures test package release smoke-test postman unit-test lint migrations-test start-db dbdocs
# Build and publish images to ECR
build-ssas:
$(eval ACCOUNT_ID =$(shell aws sts get-caller-identity --output text --query Account))
$(eval CURRENT_COMMIT=$(shell git log -n 1 --pretty=format:'%h'))
$(eval DOCKER_REGISTRY_URL=${ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/bcda-ssas)
docker build -t ${DOCKER_REGISTRY_URL}:latest -t '${DOCKER_REGISTRY_URL}:${CURRENT_COMMIT}' -f Dockerfiles/Dockerfile.ssas .
publish-ssas:
$(eval ACCOUNT_ID =$(shell aws sts get-caller-identity --output text --query Account))
$(eval DOCKER_REGISTRY_URL=${ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/bcda-ssas)
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin '${DOCKER_REGISTRY_URL}'
docker image push ${DOCKER_REGISTRY_URL} -a