diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2cbc920 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,68 @@ +name: CI + +on: + pull_request: + branches: + - "**" + push: + branches: + - "**" + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Lint + run: make lint + + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Build + run: make build + + - name: Bin + uses: actions/upload-artifact@v2 + with: + name: binance-proxy + path: ./bin/binance-proxy + +### Tests not yet integrated ... + # test: + # name: Test + # runs-on: ubuntu-latest + # steps: + # - name: Set up Go + # uses: actions/setup-go@v2 + # with: + # go-version: 1.17 + + # - name: Check out code + # uses: actions/checkout@v2 + + # - name: Test + # run: make cover + + # - name: Cover + # uses: actions/upload-artifact@v2 + # with: + # name: cover + # path: ./cover.html \ No newline at end of file diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 0131914..9585a28 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -31,7 +31,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.17 - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 diff --git a/.gitignore b/.gitignore index e6aa58b..67bb495 100644 --- a/.gitignore +++ b/.gitignore @@ -10,10 +10,11 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out - +cover.* # Dependency directories (remove the comment below to include it) vendor/ dist/ +bin/ # IDE's /.idea/* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b9f7bc6 --- /dev/null +++ b/Makefile @@ -0,0 +1,72 @@ +PROJECT := binance-proxy +VERSION := $(git describe --abbrev=0 --tags) +LD_FLAGS := -X main.version=$(VERSION) -s -w +SOURCE_FILES ?= ./internal/... ./pkg/... ./cmd/... +UNAME := $(uname -s) + +export CGO_ENABLED=0 +export GO111MODULE=on + +.PHONY: all +all: help + +.PHONY: help +help: ### Show targets documentation +ifeq ($(UNAME), Linux) + @grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \ + awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' +else + @awk -F ':.*###' '$$0 ~ FS {printf "%15s%s\n", $$1 ":", $$2}' \ + $(MAKEFILE_LIST) | grep -v '@awk' | sort +endif + +.PHONY: clean +clean: ### Clean build files + @rm -rf ./bin + @go clean + +.PHONY: build +build: clean ### Build binary + @go build -tags netgo -a -v -ldflags "${LD_FLAGS}" -o ./bin/binance-proxy ./cmd/binance-proxy/*.go + @chmod +x ./bin/* + +.PHONY: run +run: ### Quick run + @CGO_ENABLED=1 go run -race cmd/binance-proxy/*.go + +.PHONY: deps +deps: ### Optimize dependencies + @go mod tidy + +.PHONY: vendor +vendor: ### Vendor dependencies + @go mod vendor + +.PHONY: install +install: ### Install binary in your system + @go install -v cmd/binance-proxy/*.go + +.PHONY: fmt +fmt: ### Format + @gofmt -s -w . + +.PHONY: vet +vet: ### Vet + @go vet ./... + +### Lint +.PHONY: lint +lint: fmt vet + +### Clean test +.PHONY: test-clean +test-clean: ### Clean test cache + @go clean -testcache ./... + +.PHONY: test +test: lint ### Run tests + @go test -v -coverprofile=cover.out -timeout 10s ./... + +.PHONY: cover +cover: test ### Run tests and generate coverage + @go tool cover -html=cover.out -o=cover.html