github.com/hyperledger/aries-framework-go@v0.3.2/Makefile (about)

     1  # Copyright SecureKey Technologies Inc.
     2  #
     3  # SPDX-License-Identifier: Apache-2.0
     4  
     5  GO_CMD ?= go
     6  ARIES_AGENT_REST_PATH=cmd/aries-agent-rest
     7  ARIES_AGENT_MOBILE_PATH=cmd/aries-agent-mobile
     8  SIDETREE_CLI_PATH=test/bdd/cmd/sidetree
     9  OPENAPI_DOCKER_IMG=quay.io/goswagger/swagger
    10  OPENAPI_SPEC_PATH=build/rest/openapi/spec
    11  OPENAPI_DOCKER_IMG_VERSION=v0.23.0
    12  
    13  # Namespace for the agent images
    14  DOCKER_OUTPUT_NS   ?= aries-framework-go
    15  AGENT_REST_IMAGE_NAME   ?= agent-rest
    16  WEBHOOK_IMAGE_NAME ?= sample-webhook
    17  
    18  # Tool commands (overridable)
    19  DOCKER_CMD ?= docker
    20  GO_CMD     ?= go
    21  ALPINE_VER ?= 3.16
    22  GO_TAGS    ?=
    23  GO_VER ?= 1.19.2
    24  PROJECT_ROOT = github.com/hyperledger/aries-framework-go
    25  GOBIN_PATH=$(abspath .)/build/bin
    26  MOCKGEN=$(GOBIN_PATH)/mockgen
    27  GOMOCKS=pkg/internal/gomocks
    28  
    29  .PHONY: all
    30  all: clean checks unit-test unit-test-wasm unit-test-mobile bdd-test
    31  
    32  .PHONY: checks
    33  checks: license lint generate-openapi-spec
    34  
    35  .PHONY: lint
    36  lint:
    37  	@scripts/check_lint.sh
    38  
    39  .PHONY: license
    40  license:
    41  	@scripts/check_license.sh
    42  
    43  .PHONY: unit-test
    44  unit-test: mocks
    45  	@scripts/check_unit.sh
    46  
    47  .PHONY: unit-test-ursa
    48  unit-test-ursa: mocks
    49  	@scripts/check_unit_ursa.sh
    50  
    51  .PHONY: benchmark
    52  benchmark:
    53  	@scripts/check_bench.sh
    54  
    55  .PHONY: unit-test-wasm
    56  unit-test-wasm: export GOBIN=$(GOBIN_PATH)
    57  unit-test-wasm: depend
    58  	@scripts/check_unit_wasm.sh
    59  
    60  .PHONY: unit-test-mobile
    61  unit-test-mobile:
    62  	@echo "Running unit tests for mobile"
    63  	@cd ${ARIES_AGENT_MOBILE_PATH} && $(MAKE) unit-test
    64  
    65  .PHONY: bdd-test
    66  bdd-test: clean generate-test-keys agent-rest-docker sample-webhook-docker sidetree-cli bdd-test-js bdd-test-go
    67  
    68  .PHONY: bdd-test-go
    69  bdd-test-go:
    70  	@scripts/check_go_integration.sh
    71  
    72  .PHONY: bdd-test-js
    73  bdd-test-js:
    74  	@scripts/check_js_integration.sh
    75  
    76  bdd-test-js-local:
    77  	@scripts/check_js_integration.sh test-local
    78  
    79  bdd-test-js-debug:
    80  	@scripts/check_js_integration.sh test-debug
    81  
    82  
    83  .PHONY: vc-test-suite
    84  vc-test-suite: clean
    85  	@scripts/run_vc_test_suite.sh
    86  
    87  .PHONY: bbs-interop-test
    88  bbs-interop-test:
    89  	@scripts/check_bbs_interop.sh
    90  
    91  generate-test-keys: clean
    92  	@mkdir -p -p test/bdd/fixtures/keys/tls
    93  	@docker run -i --rm \
    94  		-v $(abspath .):/opt/go/src/$(PROJECT_ROOT) \
    95  		--entrypoint "/opt/go/src/$(PROJECT_ROOT)/scripts/generate_test_keys.sh" \
    96  		frapsoft/openssl
    97  
    98  .PHONY: generate-openapi-spec
    99  generate-openapi-spec: clean
   100  	@echo "Generating and validating controller API specifications using Open API"
   101  	@mkdir -p build/rest/openapi/spec
   102  	@SPEC_META=$(ARIES_AGENT_REST_PATH) SPEC_LOC=${OPENAPI_SPEC_PATH}  \
   103  	DOCKER_IMAGE=$(OPENAPI_DOCKER_IMG) DOCKER_IMAGE_VERSION=$(OPENAPI_DOCKER_IMG_VERSION)  \
   104  	scripts/generate-openapi-spec.sh
   105  
   106  .PHONY: generate-openapi-demo-specs
   107  generate-openapi-demo-specs: clean generate-openapi-spec agent-rest-docker sample-webhook-docker
   108  	@echo "Generate demo agent rest controller API specifications using Open API"
   109  	@SPEC_PATH=${OPENAPI_SPEC_PATH} OPENAPI_DEMO_PATH=test/bdd/fixtures/demo/openapi \
   110      	DOCKER_IMAGE=$(OPENAPI_DOCKER_IMG) DOCKER_IMAGE_VERSION=$(OPENAPI_DOCKER_IMG_VERSION)  \
   111      	scripts/generate-openapi-demo-specs.sh
   112  
   113  .PHONY: run-openapi-demo
   114  run-openapi-demo: generate-test-keys generate-openapi-demo-specs
   115  	@echo "Starting demo agent rest containers ..."
   116  	@DEMO_COMPOSE_PATH=test/bdd/fixtures/demo/openapi SIDETREE_COMPOSE_PATH=test/bdd/fixtures/sidetree-mock AGENT_REST_COMPOSE_PATH=test/bdd/fixtures/agent-rest  \
   117          scripts/run-openapi-demo.sh
   118  
   119  .PHONY: stop-openapi-demo
   120  stop-openapi-demo:
   121  	@echo "Stopping demo agent rest containers ..."
   122  	@DEMO_COMPOSE_PATH=test/bdd/fixtures/demo/openapi SIDETREE_COMPOSE_PATH=test/bdd/fixtures/sidetree-mock AGENT_REST_COMPOSE_PATH=test/bdd/fixtures/agent-rest  \
   123          DEMO_COMPOSE_OP=down scripts/run-openapi-demo.sh
   124  
   125  .PHONY: agent-rest
   126  agent-rest:
   127  	@echo "Building aries-agent-rest"
   128  	@mkdir -p ./build/bin
   129  	@cd ${ARIES_AGENT_REST_PATH} && go build -o ../../build/bin/aries-agent-rest main.go
   130  
   131  .PHONY: agent-rest-acapy-interop
   132  agent-rest-acapy-interop:
   133  	@echo "Building aries-agent-rest for aca-py interop"
   134  	@mkdir -p ./build/bin
   135  	@cd ${ARIES_AGENT_REST_PATH} && go build -o ../../build/bin/aries-agent-rest -tags ACAPyInterop main.go
   136  
   137  .PHONY: agent-mobile
   138  agent-mobile:
   139  	@echo "Building aries-agent-mobile"
   140  	@cd ${ARIES_AGENT_MOBILE_PATH} && $(MAKE) all
   141  
   142  .PHONY: sidetree-cli
   143  sidetree-cli:
   144  	@echo "Building sidetree-cli"
   145  	@mkdir -p ./build/bin
   146  	@cd ${SIDETREE_CLI_PATH} && go build -o ../../../../build/bin/sidetree main.go
   147  
   148  .PHONY: agent-rest-docker
   149  agent-rest-docker:
   150  	@echo "Building aries agent rest docker image"
   151  	@docker build -f ./images/agent-rest/Dockerfile --no-cache -t $(DOCKER_OUTPUT_NS)/$(AGENT_REST_IMAGE_NAME):latest \
   152  	--build-arg GO_VER=$(GO_VER) \
   153  	--build-arg ALPINE_VER=$(ALPINE_VER) \
   154  	--build-arg GO_TAGS=$(GO_TAGS) \
   155  	--build-arg GOPROXY=$(GOPROXY) .
   156  
   157  .PHONY: sample-webhook
   158  sample-webhook:
   159  	@echo "Building sample webhook server"
   160  	@mkdir -p ./build/bin
   161  	@go build -o ./build/bin/webhook-server test/bdd/webhook/main.go
   162  
   163  .PHONY: sample-webhook-docker
   164  sample-webhook-docker:
   165  	@echo "Building sample webhook server docker image"
   166  	@docker build -f ./images/mocks/webhook/Dockerfile --no-cache -t $(DOCKER_OUTPUT_NS)/$(WEBHOOK_IMAGE_NAME):latest \
   167  	--build-arg GO_VER=$(GO_VER) \
   168  	--build-arg ALPINE_VER=$(ALPINE_VER) \
   169  	--build-arg GO_TAGS=$(GO_TAGS) \
   170  	--build-arg GOPROXY=$(GOPROXY) .
   171  
   172  comma:= ,
   173  semicolon:= ;
   174  mocks_dir =
   175  
   176  define create_mock
   177    $(eval mocks_dir := $(subst pkg,$(GOMOCKS),$(1)))
   178    @echo Creating $(mocks_dir)
   179    @mkdir -p $(mocks_dir) && rm -rf $(mocks_dir)/*
   180    @$(MOCKGEN) -destination $(mocks_dir)/mocks.gen.go -self_package mocks -package mocks $(PROJECT_ROOT)/$(1) $(subst $(semicolon),$(comma),$(2))
   181  endef
   182  
   183  define create_spi_provider_mocks
   184    $(eval mocks_dir := $(GOMOCKS)/spi/storage)
   185    @echo Creating $(mocks_dir)
   186    @mkdir -p $(mocks_dir) && rm -rf $(mocks_dir)/*
   187    @$(MOCKGEN) -destination $(mocks_dir)/mocks.gen.go -self_package mocks -package mocks $(PROJECT_ROOT)/$(1) $(subst $(semicolon),$(comma),$(2))
   188  endef
   189  
   190  depend:
   191  	@mkdir -p ./build/bin
   192  	GOBIN=$(GOBIN_PATH) go install github.com/golang/mock/mockgen@v1.5.0
   193  	GOBIN=$(GOBIN_PATH) go install github.com/agnivade/wasmbrowsertest@v0.3.5
   194  
   195  .PHONY: mocks
   196  mocks: depend clean-mocks
   197  	$(call create_mock,pkg/framework/aries/api/vdr,Registry)
   198  	$(call create_mock,pkg/kms,Provider;KeyManager)
   199  	$(call create_mock,pkg/didcomm/protocol/issuecredential,Provider)
   200  	$(call create_mock,pkg/didcomm/protocol/middleware/issuecredential,Provider;Metadata)
   201  	$(call create_mock,pkg/didcomm/protocol/middleware/presentproof,Provider;Metadata)
   202  	$(call create_mock,pkg/client/outofband,Provider;OobService)
   203  	$(call create_mock,pkg/client/outofbandv2,Provider;OobService)
   204  	$(call create_mock,pkg/didcomm/protocol/presentproof,Provider)
   205  	$(call create_mock,pkg/client/introduce,Provider;ProtocolService)
   206  	$(call create_mock,pkg/client/issuecredential,Provider;ProtocolService)
   207  	$(call create_mock,pkg/client/presentproof,Provider;ProtocolService)
   208  	$(call create_mock,pkg/didcomm/protocol/introduce,Provider)
   209  	$(call create_mock,pkg/didcomm/common/service,DIDComm;Event;Messenger;MessengerHandler)
   210  	$(call create_mock,pkg/didcomm/dispatcher,Outbound)
   211  	$(call create_mock,pkg/didcomm/messenger,Provider)
   212  	$(call create_mock,pkg/store/verifiable,Store)
   213  	$(call create_mock,pkg/store/did,ConnectionStore)
   214  	$(call create_mock,pkg/controller/command/presentproof,Provider)
   215  	$(call create_mock,pkg/controller/command/issuecredential,Provider)
   216  	$(call create_mock,pkg/controller/webnotifier,Notifier)
   217  	$(call create_spi_provider_mocks,spi/storage,Provider;Store)
   218  
   219  .PHONY: clean-mocks
   220  clean-mocks:
   221  	@if [ -d $(GOMOCKS) ]; then rm -r $(GOMOCKS); echo "Folder $(GOMOCKS) was removed!"; fi
   222  
   223  .PHONY: clean
   224  clean: clean-fixtures clean-build clean-images
   225  
   226  .PHONY: clean-images
   227  clean-images: clean-fixtures
   228  clean-images: IMAGES=$(shell docker image ls | grep aries-framework-go | awk '{print $$3}')
   229  clean-images:
   230  	@if [ ! -z "$(IMAGES)" ]; then \
   231  		echo "Cleaning aries-framework-go docker images ..."; \
   232  		docker rmi -f $(IMAGES); \
   233  	fi;
   234  
   235  .PHONY: clean-build
   236  clean-build:
   237  	@rm -f coverage.out
   238  	@rm -Rf ./build
   239  	@rm -Rf $(ARIES_AGENT_MOBILE_PATH)/build
   240  	@rm -Rf ./test/bdd/db
   241  	@rm -Rf ./test/bdd/*.log
   242  
   243  .PHONY: clean-fixtures
   244  clean-fixtures:
   245  	@rm -Rf ./test/bdd/fixtures/keys/tls
   246  	@rm -Rf ./test/bdd/fixtures/demo/openapi/specs
   247  	@cd test/bdd/fixtures/demo/openapi && docker-compose down 2> /dev/null
   248  	@cd test/bdd/fixtures/sidetree-mock && docker-compose down 2> /dev/null
   249  	@cd test/bdd/fixtures/agent-rest && docker-compose down 2> /dev/null
   250