github.com/companieshouse/insolvency-api@v0.0.0-20231024103413-440c973d9e9b/Makefile (about) 1 CHS_ENV_HOME ?= $(HOME)/.chs_env 2 TESTS ?= ./... 3 4 bin := insolvency-api 5 chs_envs := $(CHS_ENV_HOME)/global_env $(CHS_ENV_HOME)/$(bin)/env 6 source_env := for chs_env in $(chs_envs); do test -f $$chs_env && . $$chs_env; done 7 xunit_output := test.xml 8 lint_output := lint.txt 9 10 .EXPORT_ALL_VARIABLES: 11 GO111MODULE = on 12 13 .PHONY: all 14 all: build 15 16 .PHONY: fmt 17 fmt: 18 go fmt ./... 19 20 .PHONY: build 21 build: fmt $(bin) 22 23 $(bin): 24 CGO_ENABLED=0 go build -o ./$(bin) 25 26 .PHONY: test 27 test: test-unit test-integration 28 29 .PHONY: test-unit 30 test-unit: 31 go test $(TESTS) -run 'Unit' -coverprofile=coverage.out 32 33 .PHONY: test-integration 34 test-integration: 35 $(source_env); go test $(TESTS) -run 'Integration' 36 37 .PHONY: clean 38 clean: 39 go mod tidy 40 rm -f ./$(bin) ./$(bin)-*.zip $(test_path) build.log 41 42 .PHONY: package 43 package: 44 ifndef version 45 $(error No version given. Aborting) 46 endif 47 $(info Packaging version: $(version)) 48 $(eval tmpdir := $(shell mktemp -d build-XXXXXXXXXX)) 49 cp ./$(bin) $(tmpdir) 50 cp ./routes.yaml $(tmpdir) 51 cp ./start.sh $(tmpdir) 52 cd $(tmpdir) && zip -r ../$(bin)-$(version).zip $(bin) start.sh routes.yaml 53 rm -rf $(tmpdir) 54 55 .PHONY: dist 56 dist: clean build package 57 58 .PHONY: xunit-tests 59 xunit-tests: GO111MODULE = off 60 xunit-tests: 61 go get github.com/tebeka/go2xunit 62 @set -a; go test -v $(TESTS) -run 'Unit' | go2xunit -output $(xunit_output)