Makefile raw

   1  SHELL := /usr/bin/env bash
   2  BROWSERTEST_VERSION = v0.6
   3  LINT_VERSION = 1.50.1
   4  GO_BIN = $(shell printf '%s/bin' "$$(go env GOPATH)")
   5  
   6  .PHONY: all
   7  all: lint test
   8  
   9  .PHONY: lint-deps
  10  lint-deps:
  11  	@if ! which golangci-lint >/dev/null || [[ "$$(golangci-lint version 2>&1)" != *${LINT_VERSION}* ]]; then \
  12  		curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GO_BIN}" v${LINT_VERSION}; \
  13  	fi
  14  
  15  .PHONY: lint
  16  lint: lint-deps
  17  	"${GO_BIN}/golangci-lint" run
  18  	GOOS=js GOARCH=wasm "${GO_BIN}/golangci-lint" run
  19  
  20  .PHONY: test-deps
  21  test-deps:
  22  	@if [[ ! -f "${GO_BIN}/go_js_wasm_exec" ]]; then \
  23  		set -ex; \
  24  		go install github.com/agnivade/wasmbrowsertest@${BROWSERTEST_VERSION}; \
  25  		mv "${GO_BIN}/wasmbrowsertest" "${GO_BIN}/go_js_wasm_exec"; \
  26  	fi
  27  
  28  .PHONY: test
  29  test: test-deps
  30  	go test wasm_tags_test.go                                                                  # Verify build tags and whatnot first
  31  	go test -race -coverprofile=native-cover.out ./...                                         # Test non-js side
  32  	GOOS=js GOARCH=wasm go test -coverprofile=js-cover.out -covermode=atomic ./...             # Test js side
  33  	{ echo 'mode: atomic'; cat *-cover.out | grep -v '^mode'; } > cover.out && rm *-cover.out  # Combine JS and non-JS coverage.
  34  	go tool cover -func cover.out | grep total:
  35  
  36  .PHONY: test-publish-coverage
  37  test-publish-coverage:
  38  	go install github.com/mattn/goveralls@v0.0.11
  39  	COVERALLS_TOKEN=$$GITHUB_TOKEN goveralls -coverprofile="cover.out" -service=github
  40