Skip to content

Commit

Permalink
Bug fixes and optimizations (#133)
Browse files Browse the repository at this point in the history
* Dependency updates
* Updates workflows
  • Loading branch information
djschleen authored Feb 28, 2024
1 parent 2d77573 commit f529748
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 508 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "hookz-devcontainer",
"image": "mcr.microsoft.com/devcontainers/go:1-1.22-bookworm",
"features": {
"ghcr.io/devcontainers-contrib/features/starship:1": {}
}
}
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ jobs:

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

6 changes: 3 additions & 3 deletions .github/workflows/go-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.18'
go-version: '1.22'
-
name: Install Dependencies
run: |
Expand Down
28 changes: 16 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
# -
Expand All @@ -24,27 +24,31 @@ jobs:
# snapcraft_token: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
-
name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.18
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: ${{ env.GITHUB_REF_NAME }}
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
go-version: '1.22'
check-latest: true
-
run: go version
-
name: Generate SBOM
uses: anchore/sbom-action@v0
with:
artifact-name: hookz.cyclonedx.json
path: .
format: cyclonedx-json
-
name: Release SBOM
uses: anchore/sbom-action/publish-sbom@v0
with:
sbom-artifact-match: ".*\\.cyclonedx.json$"
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5.0.0
with:
distribution: goreleaser
version: ${{ env.GITHUB_REF_NAME }}
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@

hookz
coverage.out
coverage.html

.DS_Store
28 changes: 13 additions & 15 deletions .hookz.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: 2.4.3
sources:
- source: github.com/anchore/syft/cmd/syft@latest
- source: github.com/devops-kung-fu/hinge@latest
- source: github.com/kisielk/errcheck@latest
- source: golang.org/x/lint/golint@latest
- source: github.com/fzipp/gocyclo/cmd/gocyclo@latest
- source: github.com/devops-kung-fu/hinge@latest
- source: github.com/kisielk/errcheck@latest
- source: honnef.co/go/tools/cmd/staticcheck@latest
- source: github.com/fzipp/gocyclo/cmd/gocyclo@latest
- source: golang.org/x/vuln/cmd/govulncheck@latest
hooks:
- type: pre-commit
actions:
Expand All @@ -20,32 +20,30 @@
- name: "gofmt: Run gofmt to format the code"
exec: gofmt
args: ["-s", "-w", "**/*.go"]
- name: "golint: Lint all go files"
exec: golint
args: ["-set_exit_status", "./..."] #to error out, add the arg "-set_exit_status"
# - name: "staticcheck: Lint all go files"
# exec: staticcheck
# args: ["-f", "stylish", "-checks", "all", "./..."] #to error out, add the arg "-set_exit_status"
- name: "errcheck: Ensure that errors are checked"
exec: errcheck
args: ["-ignoretests", "./..."]
- name: "govulncheck: Check for vulnerabilities"
exec: govulncheck
args: ["./..."]
- name: "gocyclo: Check cyclomatic complexities"
exec: gocyclo
args: ["-over", "14", "."]
args: ["-over", "9", "."]
- name: Hinge
exec: hinge
args: ["."]
- name: "go: Build (Ensure pulled modules do not break the build)"
exec: go
args: ["build", "-v"]
args: ["build", "-v", "./..."]
- name: "go: Run all tests"
exec: go
args: ["test", "-v", "-coverprofile=coverage.out", "./..."]
- name: "go: Test coverage"
exec: go
args: ["tool", "cover", "-func=coverage.out"]
- name: "syft: Generate a Software Bill of Materials (SBoM)"
script: "
#!/bin/bash \n
syft . -o cyclonedx-json=sbom/hookz.cyclonedx.json &> /dev/null \n
"
- name: "git: Add all changed files during the pre-commit stage"
exec: git
args: ["add", "."]
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ check: build ## Tests the pre-commit hooks if they exist

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

install: build ## Builds an executable local version of Hookz and puts in in /usr/local/bin
@sudo chmod +x hookz
Expand Down
16 changes: 9 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
module github.com/devops-kung-fu/hookz

go 1.18
go 1.22

toolchain go1.22.0

require (
github.com/dustin/go-humanize v1.0.1
github.com/gookit/color v1.5.3
github.com/gookit/color v1.5.4
github.com/jarcoal/httpmock v1.2.0
github.com/segmentio/ksuid v1.0.4
github.com/spf13/afero v1.9.5
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.0
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.8.4
gopkg.in/yaml.v2 v2.4.0
)

Expand All @@ -20,7 +22,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit f529748

Please sign in to comment.