-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (57 loc) · 1.68 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
GOROOT =
PATH := ${PWD}/cache/go/bin:${PWD}/cache/go/misc/wasm:${PATH}
export
LINT_VERSION = 1.41.1
SHELL := /usr/bin/env bash
GO_VERSION = 1.16.6
.PHONY: all
all: lint test
.PHONY: lint-deps
lint-deps:
@if ! which golangci-lint >/dev/null || [[ "$$(golangci-lint version 2>&1)" != *${LINT_VERSION}* ]]; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v${LINT_VERSION}; \
fi
.PHONY: lint
lint: lint-deps go
golangci-lint run
GOOS=js GOARCH=wasm golangci-lint run --build-tags js,wasm
.PHONY: test-deps
test-deps:
@go install github.com/mattn/[email protected]
.PHONY: test
test: test-deps go
go test -race -coverprofile=cover.out ./...
GOOS=js GOARCH=wasm go test -cover ./...
@if [[ "$$CI" == true ]]; then \
set -ex; \
goveralls -coverprofile=cover.out -service=github; \
fi
cache:
mkdir -p cache
.PHONY: go
go: cache/go${GO_VERSION}
cache/go${GO_VERSION}: cache
if [[ ! -e cache/go${GO_VERSION} ]]; then \
set -ex; \
TMP=$$(mktemp -d); trap 'rm -rf "$$TMP"' EXIT; \
git clone \
--depth 1 \
--single-branch \
--branch hackpad-go${GO_VERSION} \
https://github.com/hack-pad/go.git \
"$$TMP"; \
pushd "$$TMP/src"; \
./make.bash; \
export PATH="$$TMP/bin:$$PATH"; \
go version; \
mkdir -p ../bin/js_wasm; \
go build -o ../bin/js_wasm/ std cmd/go cmd/gofmt; \
go tool dist test -rebuild -list; \
go build -o ../pkg/tool/js_wasm/ std cmd/buildid cmd/pack cmd/cover cmd/vet; \
go install ./...; \
popd; \
mv "$$TMP" cache/go${GO_VERSION}; \
ln -sfn go${GO_VERSION} cache/go; \
fi
touch cache/go${GO_VERSION}
touch cache/go.mod # Makes it so linters will ignore this dir