Skip to content

Commit

Permalink
chore(*): -
Browse files Browse the repository at this point in the history
  • Loading branch information
enenumxela committed Dec 12, 2024
1 parent 5381a75 commit 5a77873
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 66 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
security-events: write
steps:
-
name: Checkout the repository
name: Code Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -38,9 +38,6 @@ jobs:
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
-
name: Autobuild
uses: github/codeql-action/autobuild@v3
-
-
name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ jobs:
go-version: '>=1.23'
cache: false
-
name: Checkout the repository
name: Code Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Run golangci-lint
name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
version: v1.62.2
args: --timeout 5m
working-directory: .
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
name: Test
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-12]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
-
Expand All @@ -29,15 +29,15 @@ jobs:
with:
go-version: '>=1.23'
-
name: Checkout the repository
name: Code Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Go modules hygine
-
name: Go Module Management
run: |
go clean -modcache
go mod tidy
make go-mod-clean
make go-mod-tidy
working-directory: .
-
name: Go test
Expand Down
55 changes: 14 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,93 +1,67 @@
# Set the default shell to `/bin/sh` for executing commands in the Makefile.
# `/bin/sh` is used as it is lightweight and widely available across UNIX systems.
SHELL = /bin/sh

# Define the project name for easy reference throughout the Makefile.
# This helps in maintaining a consistent project name and avoiding hardcoding it in multiple places.
PROJECT = "hq-go-http"

# --- Prepare | Setup -------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------------------
# --- Prepare | Setup ----------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------------------

.PHONY: prepare
prepare:
@# Install the latest version of Lefthook (a Git hooks manager) and set it up.
go install github.com/evilmartians/lefthook@latest && lefthook install

# --- Go(Golang) ------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------------------
# --- Go (Golang) --------------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------------------

# Define common Go commands with variables for reusability and easier updates.
GOCMD=go
GOCLEAN=$(GOCMD) clean
GOMOD=$(GOCMD) mod
GOGET=$(GOCMD) get
GOFMT=$(GOCMD) fmt
GOTEST=$(GOCMD) test

# Define Go build flags for verbosity and linking.
# Verbose flag for Go commands, helpful for debugging and understanding output.
GOFLAGS := -v
# Linker flags:
# - `-s` removes the symbol table for a smaller binary size.
# - `-w` removes DWARF debugging information.
LDFLAGS := -s -w

# Enable static linking on non-macOS platforms.
# This embeds all dependencies directly into the binary, making it more portable.
ifneq ($(shell go env GOOS),darwin)
LDFLAGS := -extldflags "-static"
endif

# Define Golangci-lint command for linting Go code.
GOLANGCILINTCMD=golangci-lint
GOLANGCILINTRUN=$(GOLANGCILINTCMD) run

# --- Go Module Management
.PHONY: go-mod-clean
go-mod-clean:
$(GOCLEAN) -modcache

# Tidy Go modules
# This cleans up `go.mod` and `go.sum` by removing unused dependencies
# and ensuring that only the required packages are listed.
.PHONY: go-mod-tidy
go-mod-tidy:
$(GOMOD) tidy

# Update Go modules
# Updates all Go dependencies to their latest versions, including both direct and indirect dependencies.
# Useful for staying up-to-date with upstream changes and bug fixes.
.PHONY: go-mod-update
go-mod-update:
@# Update test dependencies.
$(GOGET) -f -t -u ./...
@# Update all other dependencies.
$(GOGET) -f -u ./...

# --- Go Code Quality and Testing

# Format Go code
# Formats all Go source files in the current module according to Go's standard rules.
# Consistent formatting is crucial for code readability and collaboration.
.PHONY: go-fmt
go-fmt:
$(GOFMT) ./...

# Lint Go code
# Runs static analysis checks on the Go code using Golangci-lint.
# Ensures the code adheres to best practices and is free from common issues.
# This target also runs `go-fmt` beforehand to ensure the code is formatted.
.PHONY: go-lint
go-lint: go-fmt
$(GOLANGCILINTRUN) $(GOLANGCILINT) ./...

# Run Go tests
# Executes all unit tests in the module with detailed output.
# The `GOFLAGS` variable is used to enable verbosity, making it easier to debug test results.
.PHONY: go-test
go-test:
$(GOTEST) $(GOFLAGS) ./...

# --- Help -----------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------------------
# --- Help ---------------------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------------------

# Display help information
# This target prints out a detailed list of all available Makefile commands for ease of use.
# It's a helpful reference for developers using the Makefile.
.PHONY: help
help:
@echo ""
Expand All @@ -103,6 +77,7 @@ help:
@echo " prepare .................. prepare repository."
@echo ""
@echo " Go Commands:"
@echo " go-mod-clean ............. Clean Go module cache."
@echo " go-mod-tidy .............. Tidy Go modules."
@echo " go-mod-update ............ Update Go modules."
@echo " go-fmt ................... Format Go code."
Expand All @@ -113,6 +88,4 @@ help:
@echo " help ..................... Display this help information"
@echo ""

# Set the default goal to `help`.
# This ensures that running `make` without arguments will display the help information.
.DEFAULT_GOAL = help
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/hueristiq/hq-go-http
go 1.23.3

require (
github.com/hueristiq/hq-go-retrier v0.0.0-20241130122723-f060264d9262
github.com/hueristiq/hq-go-retrier v0.0.0-20241212101846-4c0fbd2c56da
github.com/hueristiq/hqgoutils v0.0.0-20231024005153-bd2c47932440
golang.org/x/net v0.31.0
golang.org/x/net v0.32.0
)

require golang.org/x/text v0.20.0 // indirect
require golang.org/x/text v0.21.0 // indirect
14 changes: 6 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hueristiq/hq-go-retrier v0.0.0-20241124123316-75e4987d3cb6 h1:MrT8DTES74Y5l79N6PPPg3q/GbHQWQcats76FBs6Er0=
github.com/hueristiq/hq-go-retrier v0.0.0-20241124123316-75e4987d3cb6/go.mod h1:1SITeMGkM7cJh41P9zMoXqbp5h8fxlF9nuPdynkwjjI=
github.com/hueristiq/hq-go-retrier v0.0.0-20241130122723-f060264d9262 h1:mEJOmRcl2l0mDrk6pwLSYTrcLXWlAGsGMEQGMtcc/C8=
github.com/hueristiq/hq-go-retrier v0.0.0-20241130122723-f060264d9262/go.mod h1:0gJoaPQEgXzuXWxqGS8eMQarow9FFjRuL/zyeTZPyuw=
github.com/hueristiq/hq-go-retrier v0.0.0-20241212101846-4c0fbd2c56da h1:9HW9SELNqQiGHyqZ7XeFoyKVRVMSoosxVNlBqc6AsRk=
github.com/hueristiq/hq-go-retrier v0.0.0-20241212101846-4c0fbd2c56da/go.mod h1:0gJoaPQEgXzuXWxqGS8eMQarow9FFjRuL/zyeTZPyuw=
github.com/hueristiq/hqgoutils v0.0.0-20231024005153-bd2c47932440 h1:dpHAa9c74HgAXkZ2WPd84q2cCiF76eluuSGRw7bk7To=
github.com/hueristiq/hqgoutils v0.0.0-20231024005153-bd2c47932440/go.mod h1:NlZ117o///yWDbRAbgYD7/Y44qce8z1Dj4caUsjunSY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -12,9 +10,9 @@ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit 5a77873

Please sign in to comment.