From aecf417c3a50d81d05af012dfe6b55c72b738c9e Mon Sep 17 00:00:00 2001 From: Chia Automation Date: Wed, 28 Feb 2024 03:12:33 +0000 Subject: [PATCH 1/3] Updated go-makefile --- Makefile | 68 +++++++++++++++++++++----------------------------------- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 6e31b22..500754d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ MODULE = $(shell env GO111MODULE=on $(GO) list -m) DATE ?= $(shell date +%FT%T%z) PKGS = $(or $(PKG),$(shell env GO111MODULE=on $(GO) list ./...)) +TESTPKGS = $(shell env GO111MODULE=on $(GO) list -f \ + '{{ if or .TestGoFiles .XTestGoFiles }}{{ .ImportPath }}{{ end }}' \ + $(PKGS)) BIN = $(CURDIR)/bin GO = go @@ -9,6 +12,11 @@ V = 0 Q = $(if $(filter 1,$V),,@) M = $(shell printf "\033[34;1m▶\033[0m") +binext="" +ifeq ($(GOOS),windows) + binext=".exe" +endif + export GO111MODULE=on .PHONY: all @@ -18,70 +26,40 @@ all: fmt lint vet build build: $(BIN) ; $(info $(M) building executable…) @ ## Build program binary $Q CGO_ENABLED=0 $(GO) build \ -tags release \ - -o $(BIN)/$(notdir $(basename $(MODULE))) main.go + -o $(BIN)/$(notdir $(basename $(MODULE)))$(binext) main.go # Tools $(BIN): @mkdir -p $@ $(BIN)/%: | $(BIN) ; $(info $(M) building $(PACKAGE)…) - $Q tmp=$$(mktemp -d); \ - env GO111MODULE=off GOPATH=$$tmp GOBIN=$(BIN) $(GO) get $(PACKAGE) \ + $Q env GOBIN=$(BIN) $(GO) install $(PACKAGE) \ || ret=$$?; \ - rm -rf $$tmp ; exit $$ret + exit $$ret GOLINT = $(BIN)/golint -$(BIN)/golint: PACKAGE=golang.org/x/lint/golint +$(BIN)/golint: PACKAGE=golang.org/x/lint/golint@latest STATICCHECK = $(BIN)/staticcheck -$(BIN)/staticcheck: PACKAGE=honnef.co/go/tools/cmd/staticcheck +$(BIN)/staticcheck: PACKAGE=honnef.co/go/tools/cmd/staticcheck@latest ERRCHECK = $(BIN)/errcheck -$(BIN)/errcheck: PACKAGE=github.com/kisielk/errcheck - -GOCOV = $(BIN)/gocov -$(BIN)/gocov: PACKAGE=github.com/axw/gocov/... +$(BIN)/errcheck: PACKAGE=github.com/kisielk/errcheck@latest -GOCOVXML = $(BIN)/gocov-xml -$(BIN)/gocov-xml: PACKAGE=github.com/AlekSi/gocov-xml - -GO2XUNIT = $(BIN)/go2xunit -$(BIN)/go2xunit: PACKAGE=github.com/tebeka/go2xunit +VULNCHECK = $(BIN)/govulncheck +$(BIN)/govulncheck: PACKAGE=golang.org/x/vuln/cmd/govulncheck@latest # Tests TEST_TARGETS := test-default test-bench test-short test-verbose test-race -.PHONY: $(TEST_TARGETS) test-xml check test tests +.PHONY: $(TEST_TARGETS) check test tests test-bench: ARGS=-run=__absolutelynothing__ -bench=. ## Run benchmarks test-short: ARGS=-short ## Run only short tests -test-verbose: ARGS=-v ## Run tests in verbose mode with coverage reporting +test-verbose: ARGS=-v ## Run tests in verbose mode test-race: ARGS=-race ## Run tests with race detector $(TEST_TARGETS): NAME=$(MAKECMDGOALS:test-%=%) $(TEST_TARGETS): test -check test tests: fmt lint vet staticcheck errcheck; $(info $(M) running $(NAME:%=% )tests…) @ ## Run tests - $Q $(GO) test -timeout $(TIMEOUT)s $(ARGS) $(PKGS) - -test-xml: fmt lint vet staticcheck errcheck | $(GO2XUNIT) ; $(info $(M) running xUnit tests…) @ ## Run tests with xUnit output - $Q mkdir -p test - $Q 2>&1 $(GO) test -timeout $(TIMEOUT)s -v $(PKGS) | tee test/tests.output - $(GO2XUNIT) -fail -input test/tests.output -output test/tests.xml - -COVERAGE_MODE = atomic -COVERAGE_PROFILE = $(COVERAGE_DIR)/profile.out -COVERAGE_XML = $(COVERAGE_DIR)/coverage.xml -COVERAGE_HTML = $(COVERAGE_DIR)/index.html -.PHONY: test-coverage test-coverage-tools -test-coverage-tools: | $(GOCOV) $(GOCOVXML) -test-coverage: COVERAGE_DIR := $(CURDIR)/test/coverage -test-coverage: fmt lint vet staticcheck errcheck test-coverage-tools ; $(info $(M) running coverage tests…) @ ## Run coverage tests - $Q mkdir -p $(COVERAGE_DIR) - $Q $(GO) test \ - -coverpkg=$$($(GO) list -f '{{ join .Deps "\n" }}' $(PKGS) | \ - grep '^$(MODULE)/' | \ - tr '\n' ',' | sed 's/,$$//') \ - -covermode=$(COVERAGE_MODE) \ - -coverprofile="$(COVERAGE_PROFILE)" $(PKGS) - $Q $(GO) tool cover -html=$(COVERAGE_PROFILE) -o $(COVERAGE_HTML) - $Q $(GOCOV) convert $(COVERAGE_PROFILE) | $(GOCOVXML) > $(COVERAGE_XML) +check test tests: fmt lint vet staticcheck errcheck vulncheck; $(info $(M) running $(NAME:%=% )tests…) @ ## Run tests + $Q $(GO) test -timeout $(TIMEOUT)s $(ARGS) $(TESTPKGS) .PHONY: lint lint: | $(GOLINT) ; $(info $(M) running golint…) @ ## Run golint @@ -103,12 +81,16 @@ staticcheck: | $(STATICCHECK) ; $(info $(M) running staticcheck…) @ errcheck: | $(ERRCHECK) ; $(info $(M) running errcheck…) @ $Q $(ERRCHECK) $(PKGS) +.PHONY: vulncheck +vulncheck: | $(VULNCHECK) ; $(info $(M) running vulncheck…) @ + $Q $(VULNCHECK) $(PKGS) + # Misc .PHONY: clean clean: ; $(info $(M) cleaning…) @ ## Cleanup everything @rm -rf $(BIN) - @rm -rf test/tests.* test/coverage.* + @rm -rf test/tests.* .PHONY: help help: From d2917308f70924d118f610f3c1c22e5baf8d90b7 Mon Sep 17 00:00:00 2001 From: Chia Automation Date: Wed, 28 Feb 2024 03:12:34 +0000 Subject: [PATCH 2/3] Updated go-dependabot --- .github/dependabot.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4c8d17f..48ee185 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,8 +1,5 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - +# This file is managed by the repo-content-updater project. Manual changes here will result in a PR to bring back +# inline with the upstream template, unless you remove the go-dependabot managed file property from the repo version: 2 updates: - package-ecosystem: gomod From 3048929e4e19ce3e6cc6c25cd8ab7e4ea67bf5cb Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 27 Feb 2024 21:16:22 -0600 Subject: [PATCH 3/3] Swap to make test --- .github/workflows/lint.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 094570b..89b25b8 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest container: golang:1 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Test - run: make test-coverage + run: make test