Skip to content

Commit

Permalink
revise makefile, use it in gha
Browse files Browse the repository at this point in the history
Signed-off-by: Rumen Vasilev <[email protected]>
  • Loading branch information
rumenvasilev committed Nov 11, 2023
1 parent 34e8170 commit 294241d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 57 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/on-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,20 @@ jobs:
run: go version

- name: Build
run: go build -mod vendor -v ./...
run: make build

- name: Lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc #v3
with:
version: v1.54

- name: Test
run: go test -mod vendor -race -v ./...
run: make test

- name: Create coverage report
run: go test -mod vendor -coverprofile=coverage.out -v ./...
run: make coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d #v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# - name: Run GoKart
# uses: kitabisa/[email protected]
# with:
# globalsTainted: true

# - name: Upload GoKart results
# uses: github/codeql-action/upload-sarif@v1
62 changes: 16 additions & 46 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#
# Copyright (c) 2015, Matt Jones <[email protected]>
# All rights reserved.
# MIT License
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
#
# version 0.1.24
#
SHELL = /bin/bash
SHELL = /bin/bash

.PHONY: all build clean coverage help install package pretty test
.DEFAULT_GOAL := help
.PHONY: all build clean coverage lint test
.DEFAULT_GOAL := lint

# The name of the binary to build
#
Expand Down Expand Up @@ -43,47 +35,25 @@ ifndef target_arch
target_arch = amd64
endif

## all Run lint tools, clean and build
all: pretty clean build
## Lint, build
all: pretty build

## build Download dependencies and build
build: prep
## Build
build: clean
@GOOS=$(target_os) GOARCH=$(target_arch) go build -mod vendor -o ./bin/$(pkg)-$(target_os)

## release Download dependencies and build release binaries
release: prep
@GOOS=$(target_os) GOARCH=$(target_arch) go build -mod vendor -ldflags="-s -w" -o ./bin/$(pkg)$(target_ext)

## clean Clean binaries
## Clean binaries
clean:
@rm -rf ./bin

## help Print available make targets
help:
@echo
@echo "Available make targets:"
@echo
@sed -ne '/@sed/!s/## / /p' $(MAKEFILE_LIST)

## install Build and save binary in `$GOPATH/bin/`
install: pretty
@GOOS=$(target_os) GOARCH=$(target_arch) go install

## package Run tests, clean and build binary
package: test clean build

# TODO set a flag to allow the updating of the packages at build time
## prep Install dependencies
prep:
@go get

## pretty Run golint, go fmt and go vet
pretty:
@golint ./...
## Lint
lint:
@go fmt ./...
@go vet ./...
@golint ./...

## test Run tests with coverage
test: pretty
go test -mod vendor ./... -cover -race
## Some tests depend on built binary, make sure you've built it beforehand.
test:
go test -v -mod vendor -race ./...

coverage:
go test -mod vendor -coverprofile=coverage.out ./...

0 comments on commit 294241d

Please sign in to comment.