2017-06-25 23:45:22 +02:00
|
|
|
SHELL := /bin/bash
|
|
|
|
|
|
|
|
PREFIX=qingstor-sdk-go
|
|
|
|
VERSION=$(shell cat version.go | grep "Version\ =" | sed -e s/^.*\ //g | sed -e s/\"//g)
|
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@echo "Please use \`make <target>\` where <target> is one of"
|
|
|
|
@echo " all to check, build, test and release this SDK"
|
|
|
|
@echo " check to vet and lint the SDK"
|
|
|
|
@echo " update to update git submodules"
|
|
|
|
@echo " generate to generate service code"
|
|
|
|
@echo " build to build the SDK"
|
|
|
|
@echo " test to run test"
|
|
|
|
@echo " test-coverage to run test with coverage"
|
|
|
|
@echo " test-race to run test with race"
|
|
|
|
@echo " integration-test to run integration test"
|
|
|
|
@echo " clean to clean the coverage files"
|
|
|
|
|
|
|
|
.PHONY: all
|
2020-02-25 15:20:57 +01:00
|
|
|
all: check build test release
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: check
|
2018-05-02 18:09:45 +02:00
|
|
|
check: vet lint format
|
|
|
|
|
|
|
|
.PHONY: format
|
|
|
|
format:
|
|
|
|
@echo "go fmt, skipping vendor packages"
|
2020-02-25 15:20:57 +01:00
|
|
|
@go fmt ./...
|
2018-05-02 18:09:45 +02:00
|
|
|
@echo "ok"
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: vet
|
|
|
|
vet:
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Go tool vet, skipping vendor packages"
|
2020-02-25 15:20:57 +01:00
|
|
|
@go vet ./...
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Done"
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Golint, skipping vendor packages"
|
2020-02-25 15:20:57 +01:00
|
|
|
@golint ./...
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Done"
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: update
|
|
|
|
update:
|
|
|
|
git submodule update --remote
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Done"
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: generate
|
|
|
|
generate:
|
|
|
|
@if [[ ! -f "$$(which snips)" ]]; then \
|
|
|
|
echo "ERROR: Command \"snips\" not found."; \
|
|
|
|
fi
|
2017-09-30 16:27:27 +02:00
|
|
|
snips -f="./specs/qingstor/2016-01-06/swagger/api_v2.0.json" -t="./template" -o="./service"
|
2019-11-11 16:04:53 +01:00
|
|
|
snips -f="./specs/qingstor/2016-01-06/swagger/api_v2.0.json" -t="./interface" -o="./interface"
|
2017-06-25 23:45:22 +02:00
|
|
|
gofmt -w .
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Done"
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: build
|
2018-05-02 18:09:45 +02:00
|
|
|
build: format
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Build the SDK"
|
2020-02-25 15:20:57 +01:00
|
|
|
go build ./...
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Done"
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Run test"
|
2020-02-25 15:20:57 +01:00
|
|
|
go test -v ./...
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Done"
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: test-coverage
|
|
|
|
test-coverage:
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Run test with coverage"
|
2020-02-25 15:20:57 +01:00
|
|
|
@go test -race -coverprofile=coverage.txt -covermode=atomic -v ./...
|
|
|
|
@go tool cover -html="coverage.txt" -o "coverage.html"
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Done"
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: test-race
|
|
|
|
test-race:
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Run test with race"
|
2020-02-25 15:20:57 +01:00
|
|
|
go test -v -race -cpu=1,2,4 ./...
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Done"
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: integration-test
|
|
|
|
integration-test:
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Run integration test"
|
2018-09-21 12:01:55 +02:00
|
|
|
pushd "./test"; go test; popd
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Done"
|
2017-06-25 23:45:22 +02:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -rf $${PWD}/coverage
|
2018-01-16 14:20:59 +01:00
|
|
|
@echo "Done"
|