Skip to content

Commit f529748

Browse files
authored
Bug fixes and optimizations (#133)
* Dependency updates * Updates workflows
1 parent 2d77573 commit f529748

12 files changed

+86
-508
lines changed

.devcontainer/devcontainer.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "hookz-devcontainer",
3+
"image": "mcr.microsoft.com/devcontainers/go:1-1.22-bookworm",
4+
"features": {
5+
"ghcr.io/devcontainers-contrib/features/starship:1": {}
6+
}
7+
}

.github/workflows/codeql-analysis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ jobs:
6565

6666
- name: Perform CodeQL Analysis
6767
uses: github/codeql-action/analyze@v2
68+

.github/workflows/go-quality.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ jobs:
66
steps:
77
-
88
name: Checkout
9-
uses: actions/checkout@v3
9+
uses: actions/checkout@v4
1010
-
1111
name: Setup Go
12-
uses: actions/setup-go@v4
12+
uses: actions/setup-go@v5
1313
with:
14-
go-version: '1.18'
14+
go-version: '1.22'
1515
-
1616
name: Install Dependencies
1717
run: |

.github/workflows/release.yml

+16-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
-
1616
name: Checkout
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
2020
# -
@@ -24,27 +24,31 @@ jobs:
2424
# snapcraft_token: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
2525
-
2626
name: Set up Go
27-
uses: actions/setup-go@v4
27+
uses: actions/setup-go@v5
2828
with:
29-
go-version: 1.18
30-
-
31-
name: Run GoReleaser
32-
uses: goreleaser/goreleaser-action@v4
33-
with:
34-
distribution: goreleaser
35-
version: ${{ env.GITHUB_REF_NAME }}
36-
args: release --rm-dist
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
29+
go-version: '1.22'
30+
check-latest: true
31+
-
32+
run: go version
3933
-
4034
name: Generate SBOM
4135
uses: anchore/sbom-action@v0
4236
with:
4337
artifact-name: hookz.cyclonedx.json
4438
path: .
39+
format: cyclonedx-json
4540
-
4641
name: Release SBOM
4742
uses: anchore/sbom-action/publish-sbom@v0
4843
with:
4944
sbom-artifact-match: ".*\\.cyclonedx.json$"
45+
-
46+
name: Run GoReleaser
47+
uses: goreleaser/[email protected]
48+
with:
49+
distribution: goreleaser
50+
version: ${{ env.GITHUB_REF_NAME }}
51+
args: release --clean
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
5054

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616

1717
hookz
1818
coverage.out
19+
coverage.html
1920

2021
.DS_Store

.hookz.yaml

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2.4.3
22
sources:
3-
- source: github.com/anchore/syft/cmd/syft@latest
4-
- source: github.com/devops-kung-fu/hinge@latest
5-
- source: github.com/kisielk/errcheck@latest
6-
- source: golang.org/x/lint/golint@latest
7-
- source: github.com/fzipp/gocyclo/cmd/gocyclo@latest
3+
- source: github.com/devops-kung-fu/hinge@latest
4+
- source: github.com/kisielk/errcheck@latest
5+
- source: honnef.co/go/tools/cmd/staticcheck@latest
6+
- source: github.com/fzipp/gocyclo/cmd/gocyclo@latest
7+
- source: golang.org/x/vuln/cmd/govulncheck@latest
88
hooks:
99
- type: pre-commit
1010
actions:
@@ -20,32 +20,30 @@
2020
- name: "gofmt: Run gofmt to format the code"
2121
exec: gofmt
2222
args: ["-s", "-w", "**/*.go"]
23-
- name: "golint: Lint all go files"
24-
exec: golint
25-
args: ["-set_exit_status", "./..."] #to error out, add the arg "-set_exit_status"
23+
# - name: "staticcheck: Lint all go files"
24+
# exec: staticcheck
25+
# args: ["-f", "stylish", "-checks", "all", "./..."] #to error out, add the arg "-set_exit_status"
2626
- name: "errcheck: Ensure that errors are checked"
2727
exec: errcheck
2828
args: ["-ignoretests", "./..."]
29+
- name: "govulncheck: Check for vulnerabilities"
30+
exec: govulncheck
31+
args: ["./..."]
2932
- name: "gocyclo: Check cyclomatic complexities"
3033
exec: gocyclo
31-
args: ["-over", "14", "."]
34+
args: ["-over", "9", "."]
3235
- name: Hinge
3336
exec: hinge
3437
args: ["."]
3538
- name: "go: Build (Ensure pulled modules do not break the build)"
3639
exec: go
37-
args: ["build", "-v"]
40+
args: ["build", "-v", "./..."]
3841
- name: "go: Run all tests"
3942
exec: go
4043
args: ["test", "-v", "-coverprofile=coverage.out", "./..."]
4144
- name: "go: Test coverage"
4245
exec: go
4346
args: ["tool", "cover", "-func=coverage.out"]
44-
- name: "syft: Generate a Software Bill of Materials (SBoM)"
45-
script: "
46-
#!/bin/bash \n
47-
syft . -o cyclonedx-json=sbom/hookz.cyclonedx.json &> /dev/null \n
48-
"
4947
- name: "git: Add all changed files during the pre-commit stage"
5048
exec: git
5149
args: ["add", "."]

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ check: build ## Tests the pre-commit hooks if they exist
2020

2121
test: ## Runs tests and coverage
2222
@go test -v -coverprofile=coverage.out ./... && go tool cover -func=coverage.out
23+
@go tool cover -html=coverage.out -o coverage.html
2324

2425
install: build ## Builds an executable local version of Hookz and puts in in /usr/local/bin
2526
@sudo chmod +x hookz

go.mod

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
module github.com/devops-kung-fu/hookz
22

3-
go 1.18
3+
go 1.22
4+
5+
toolchain go1.22.0
46

57
require (
68
github.com/dustin/go-humanize v1.0.1
7-
github.com/gookit/color v1.5.3
9+
github.com/gookit/color v1.5.4
810
github.com/jarcoal/httpmock v1.2.0
911
github.com/segmentio/ksuid v1.0.4
10-
github.com/spf13/afero v1.9.5
11-
github.com/spf13/cobra v1.7.0
12-
github.com/stretchr/testify v1.8.0
12+
github.com/spf13/afero v1.11.0
13+
github.com/spf13/cobra v1.8.0
14+
github.com/stretchr/testify v1.8.4
1315
gopkg.in/yaml.v2 v2.4.0
1416
)
1517

@@ -20,7 +22,7 @@ require (
2022
github.com/pmezard/go-difflib v1.0.0 // indirect
2123
github.com/spf13/pflag v1.0.5 // indirect
2224
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
23-
golang.org/x/sys v0.8.0 // indirect
24-
golang.org/x/text v0.9.0 // indirect
25+
golang.org/x/sys v0.17.0 // indirect
26+
golang.org/x/text v0.14.0 // indirect
2527
gopkg.in/yaml.v3 v3.0.1 // indirect
2628
)

0 commit comments

Comments
 (0)