This repository has been archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
107 lines (83 loc) · 3.14 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
# Copyright SecureKey Technologies Inc.
#
# SPDX-License-Identifier: Apache-2.0
EDV_REST_PATH=cmd/edv-rest
# Namespace for the EDV server image
DOCKER_OUTPUT_NS ?= ghcr.io
EDV_REST_IMAGE_NAME ?= trustbloc/edv
# OpenAPI spec
OPENAPI_DOCKER_IMG=quay.io/goswagger/swagger
OPENAPI_SPEC_PATH=build/rest/openapi/spec
OPENAPI_DOCKER_IMG_VERSION=v0.23.0
# Tool commands (overridable)
ALPINE_VER ?= 3.12
GO_VER ?= 1.16
.PHONY: all
all: checks refresh-test-keys unit-test bdd-test
.PHONY: checks
checks: license lint generate-openapi-spec
.PHONY: lint
lint:
@scripts/check_lint.sh
.PHONY: license
license:
@scripts/check_license.sh
.PHONY: edv-rest
edv-rest:
@echo "Building edv-rest"
@mkdir -p ./build/bin
@cd ${EDV_REST_PATH} && go build -o ../../build/bin/edv-rest main.go
.PHONY: edv-docker
edv-docker:
@echo "Building edv docker image"
@docker build -f ./images/edv-rest/Dockerfile --no-cache -t $(DOCKER_OUTPUT_NS)/$(EDV_REST_IMAGE_NAME):latest \
--build-arg GO_VER=$(GO_VER) \
--build-arg ALPINE_VER=$(ALPINE_VER) .
.PHONY: bdd-test
bdd-test: edv-docker generate-test-keys mock-login-consent-docker
@rm -Rf ./test/bdd/*.log
@scripts/check_integration.sh
.PHONY: mock-login-consent-docker
mock-login-consent-docker:
@echo "Building mock login consent server for BDD tests..."
@cd test/bdd/mock/loginconsent && docker build -f image/Dockerfile --build-arg GO_VER=$(GO_VER) --build-arg ALPINE_VER=$(ALPINE_VER) -t mockloginconsent:latest .
unit-test:
@scripts/check_unit.sh
.PHONY: generate-openapi-spec
generate-openapi-spec: clean
@echo "Generating and validating controller API specifications using Open API"
@mkdir -p build/rest/openapi/spec
@SPEC_META=$(VC_REST_PATH) SPEC_LOC=${OPENAPI_SPEC_PATH} \
DOCKER_IMAGE=$(OPENAPI_DOCKER_IMG) DOCKER_IMAGE_VERSION=$(OPENAPI_DOCKER_IMG_VERSION) \
scripts/generate-openapi-spec.sh
.PHONY: generate-openapi-demo-specs
generate-openapi-demo-specs: clean generate-openapi-spec edv-docker
@echo "Generate demo agent rest controller API specifications using Open API"
@SPEC_PATH=${OPENAPI_SPEC_PATH} OPENAPI_DEMO_PATH=test/bdd/fixtures/openapi-demo \
DOCKER_IMAGE=$(OPENAPI_DOCKER_IMG) DOCKER_IMAGE_VERSION=$(OPENAPI_DOCKER_IMG_VERSION) \
scripts/generate-openapi-demo-specs.sh
.PHONY: run-openapi-demo
run-openapi-demo: generate-openapi-demo-specs
@echo "Starting OpenAPI demo and EDV containers ..."
@FIXTURES_PATH=test/bdd/fixtures \
scripts/run-openapi-demo.sh
# TODO (#264): frapsoft/openssl only has an amd64 version. While this does work under amd64 and arm64 Mac OS currently,
# we should add an arm64 version for systems that can only run arm64 code.
.PHONY: generate-test-keys
generate-test-keys:
@mkdir -p test/bdd/fixtures/keys/tls
@docker run -i --platform linux/amd64 --rm \
-v $(abspath .):/opt/workspace/edv \
--entrypoint "/opt/workspace/edv/scripts/generate_test_keys.sh" \
frapsoft/openssl
.PHONY: clean
clean: clean-build
.PHONY: clean-build
clean-build:
@rm -Rf ./.build
@rm -Rf ./test/bdd/docker-compose.log
.PHONY: clean-test-keys
clean-test-keys:
@rm -Rf ./test/bdd/fixtures/keys/
.PHONY: refresh-test-keys
refresh-test-keys: clean-test-keys generate-test-keys