-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup Makefile, Dockerfile, go.mod
Updates to Go 1.19 in go.mod to get us to a more modern Go release. Similarly changes the Dockerfile that builds the `ghwc` binary to use Go 1.19 and use a hashed version of the Alpine base image to address security best practices. Finally, removes the outdated and unnecessary Make targets and unnecessarily complicated calls to find Go packages. These targets and fancy code was left over from before Go modules and when we were using `dep` and vendoring things. Adds a `.github/workflows/fmtcheck.yml` that follows GH actions security best practices and separates the fmtcheck stuff from the other tests in the main `.github.com/workflows/go.yml`. Signed-off-by: Jay Pipes <jaypipes@gmail.com>
- Loading branch information
Showing
5 changed files
with
37 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: fmtcheck | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
fmtcheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: harden runner | ||
uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1 | ||
with: | ||
egress-policy: block | ||
disable-sudo: true | ||
allowed-endpoints: > | ||
github.com:443 | ||
- name: checkout code | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | ||
- name: setup go | ||
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | ||
with: | ||
go-version: 1.19 | ||
- name: fmtcheck | ||
run: bash -c "diff -u <(echo -n) <(gofmt -d .)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,16 @@ | ||
VENDOR := vendor | ||
PKGS := $(shell go list ./... | grep -v /$(VENDOR)/) | ||
SRC = $(shell find . -type f -name '*.go' -not -path "*/$(VENDOR)/*") | ||
BIN_DIR := $(GOPATH)/bin | ||
GOMETALINTER := $(BIN_DIR)/gometalinter | ||
|
||
.PHONY: test | ||
test: vet | ||
go test $(PKGS) | ||
|
||
$(GOMETALINTER): | ||
go get -u github.com/alecthomas/gometalinter | ||
$(GOMETALINTER) --install &> /dev/null | ||
|
||
.PHONY: lint | ||
lint: $(GOMETALINTER) | ||
$(GOMETALINTER) ./... --vendor | ||
go test -v ./... | ||
|
||
.PHONY: fmt | ||
fmt: | ||
@echo "Running gofmt on all sources..." | ||
@gofmt -s -l -w $(SRC) | ||
@gofmt -s -l -w . | ||
|
||
.PHONY: fmtcheck | ||
fmtcheck: | ||
@bash -c "diff -u <(echo -n) <(gofmt -d $(SRC))" | ||
@bash -c "diff -u <(echo -n) <(gofmt -d .)" | ||
|
||
.PHONY: vet | ||
vet: | ||
go vet $(PKGS) | ||
|
||
.PHONY: cover | ||
cover: | ||
$(shell [ -e coverage.out ] && rm coverage.out) | ||
@echo "mode: count" > coverage-all.out | ||
$(foreach pkg,$(PKGS),\ | ||
go test -coverprofile=coverage.out -covermode=count $(pkg);\ | ||
tail -n +2 coverage.out >> coverage-all.out;) | ||
go tool cover -html=coverage-all.out -o=coverage-all.html | ||
go vet ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/jaypipes/ghw | ||
|
||
go 1.18 | ||
go 1.19 | ||
|
||
require ( | ||
github.com/StackExchange/wmi v1.2.1 | ||
|