Skip to content

Commit

Permalink
Merge pull request #383 from wakatime/misc/makefile-improvements
Browse files Browse the repository at this point in the history
Improve makefile
  • Loading branch information
alanhamlett authored May 19, 2021
2 parents 24214fa + 8652268 commit 9f6908a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}
-
name: "Pull dependencies"
run: go mod vendor
run: make install-go-modules
-
name: "Unit tests"
run: make test
Expand All @@ -46,7 +46,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}
-
name: "Pull dependencies"
run: go mod vendor
run: make install-go-modules
-
name: "Build binary"
env:
Expand All @@ -70,7 +70,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}
-
name: "Pull dependencies"
run: go mod vendor
run: make install-go-modules
-
name: "Unit tests"
run: make test
Expand All @@ -88,7 +88,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}
-
name: "Pull dependencies"
run: go mod vendor
run: make install-go-modules
-
name: "Build binary"
env:
Expand All @@ -111,7 +111,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}
-
name: "Pull dependencies"
run: go mod vendor
run: make install-go-modules
-
name: "Unit tests"
run: make test
Expand All @@ -129,7 +129,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}
-
name: "Pull dependencies"
run: go mod vendor
run: make install-go-modules
-
name: "Build binary"
env:
Expand Down
8 changes: 3 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ To contribute to this project please carefully read this document.

`wakatime-cli` is written in [Go](https://golang.org/).

**Note:** wakatime-cli uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.

Prerequisites:

- `make` - We use make to build and run tests.
- We use `make` to build and run tests.
- [Go 1.16](https://golang.org/doc/install)

After cloning it first run `make test` to make sure everything is properly set.
After cloning, install dependencies with `make install`.

## Branches

Expand All @@ -24,7 +22,7 @@ This project currently has two branches

## Testing and Linting

Before any commit make sure to always run `make lint` and `make test` consecutively. It guarantees there's no linting error and all tests pass.
Run `make test-all` before creating any pull requests, or your PR won’t pass the automated checks.

## Branching Stratgegy

Expand Down
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ else
endif

# targets
build-all: build-all-darwin build-all-freebsd build-all-linux build-all-netbsd build-all-openbsd build-all-windows
build-all: build-darwin build-freebsd build-linux build-netbsd build-openbsd build-windows

build-all-darwin: build-darwin-amd64 build-darwin-arm64
build-darwin-all: build-darwin-amd64 build-darwin-arm64

build-darwin-amd64:
GOOS=darwin GOARCH=amd64 make build-binary

build-darwin-arm64:
GOOS=darwin GOARCH=arm64 make build-binary

build-all-freebsd: build-freebsd-386 build-freebsd-amd64 build-freebsd-arm
build-freebsd: build-freebsd-386 build-freebsd-amd64 build-freebsd-arm

build-freebsd-386:
GOOS=freebsd GOARCH=386 make build-binary
Expand All @@ -54,7 +54,7 @@ build-freebsd-amd64:
build-freebsd-arm:
GOOS=freebsd GOARCH=arm make build-binary

build-all-linux: build-linux-386 build-linux-amd64 build-linux-arm build-linux-arm64
build-linux: build-linux-386 build-linux-amd64 build-linux-arm build-linux-arm64

build-linux-386:
GOOS=linux GOARCH=386 make build-binary
Expand All @@ -68,7 +68,7 @@ build-linux-arm:
build-linux-arm64:
GOOS=linux GOARCH=arm64 make build-binary

build-all-netbsd: build-netbsd-386 build-netbsd-amd64 build-netbsd-arm
build-netbsd: build-netbsd-386 build-netbsd-amd64 build-netbsd-arm

build-netbsd-386:
GOOS=netbsd GOARCH=386 make build-binary
Expand All @@ -79,7 +79,7 @@ build-netbsd-amd64:
build-netbsd-arm:
GOOS=netbsd GOARCH=arm make build-binary

build-all-openbsd: build-openbsd-386 build-openbsd-amd64 build-openbsd-arm build-openbsd-arm64
build-openbsd: build-openbsd-386 build-openbsd-amd64 build-openbsd-arm build-openbsd-arm64

build-openbsd-386:
GOOS=openbsd GOARCH=386 make build-binary
Expand All @@ -93,7 +93,7 @@ build-openbsd-arm:
build-openbsd-arm64:
GOOS=openbsd GOARCH=arm64 make build-binary

build-all-windows: build-windows-386 build-windows-amd64
build-windows: build-windows-386 build-windows-amd64

build-windows-386:
GOOS=windows GOARCH=386 make build-binary-windows
Expand All @@ -111,14 +111,19 @@ build-binary-windows:
-ldflags "${LD_FLAGS} -X ${REPO}/pkg/version.OS=$(GOOS) -X ${REPO}/pkg/version.Arch=$(GOARCH)" \
-o ${BUILD_DIR}/$(BINARY_NAME)-$(GOOS)-$(GOARCH).exe

# install linter
install: install-go-modules install-linter

.PHONY: install-linter
install-linter:
ifneq "$(INSTALLED_LINT_VERSION)" "$(LATEST_LINT_VERSION)"
@echo "new golangci-lint version found:" $(LATEST_LINT_VERSION)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin latest
endif

.PHONY: install-go-modules
install-go-modules:
go mod vendor

# run static analysis tools, configuration in ./.golangci.yml file
.PHONY: lint
lint: install-linter
Expand All @@ -131,3 +136,5 @@ test:
.PHONY: test-integration
test-integration:
go test -race -tags=integration ./main_test.go

test-all: lint test test-integration

0 comments on commit 9f6908a

Please sign in to comment.