Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 51 additions & 37 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,82 @@ jobs:
test_and_build:
runs-on: ubuntu-latest
name: Test and Build

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Get dependencies
run: go mod download

go-version: '1.26'
cache: true
- name: Test
run: |
go test ./...
run: go test ./...

code_quality:
name: Code Quality🎖️
runs-on: ubuntu-latest
container: "golangci/golangci-lint:v1.62.2"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Get dependencies
run: go get -v -t -d ./...
- name: GolangCI-Lint
run: |
golangci-lint run --timeout 9m0s
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.26'
cache: true
- uses: golangci/golangci-lint-action@v8
with:
version: v2.10.1
args: --timeout 9m0s

release_package:
check_docker_config:
if: ${{ startsWith(github.ref, 'refs/tags/v')}}
needs: [test_and_build,code_quality]
runs-on: ubuntu-latest
name: Check Docker Config
outputs:
configured: ${{ steps.check.outputs.configured }}
steps:
- name: Check Docker configuration
id: check
run: |
if [ -z "${{ vars.DOCKER_USERNAME }}" ]; then
echo "::warning::DOCKER_USERNAME variable is not set - skipping Docker push"
exit 0
fi
if [ -z "${{ vars.DOCKER_REGISTRY_TARGET }}" ]; then
echo "::warning::DOCKER_REGISTRY_TARGET variable is not set - skipping Docker push"
exit 0
fi
if [ -z "${{ secrets.DOCKER_HUB_PAT }}" ]; then
echo "::warning::DOCKER_HUB_PAT secret is not set - skipping Docker push"
exit 0
fi
echo "configured=true" >> $GITHUB_OUTPUT

release_package:
if: ${{ needs.check_docker_config.outputs.configured == 'true' }}
needs: [test_and_build, code_quality, check_docker_config]
runs-on: ubuntu-latest
name: Release Package
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Get dependencies
run: |
go mod download
- uses: actions/checkout@v4

- name: Extract Release Tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
- uses: docker/login-action@v3
with:
username: "v4vikash"
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PAT }}

- name: Extract Release Tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v4
- uses: docker/build-push-action@v6
with:
push: true
context: .
file: Dockerfile
tags: zopdev/static-server:${{ env.RELEASE_VERSION }}
provenance: true
sbom: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
${{ vars.DOCKER_REGISTRY_TARGET }}:${{ env.RELEASE_VERSION }}
219 changes: 102 additions & 117 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,100 +1,16 @@
---
linters-settings:
dupl:
threshold: 100
exhaustive:
default-signifies-exhaustive: false
funlen:
lines: 100
statements: 50
gci:
sections:
- standard
- default
- localmodule
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 10
goimports:
local-prefixes: github.com/golangci/golangci-lint
golint:
min-confidence: 0
mnd:
checks:
- argument
- case
- condition
- return
govet:
enable:
- shadow
settings:
printf:
funcs:
- (gofr.dev/pkg/gofr/Logger).Logf
- (gofr.dev/pkg/gofr/Logger).Errorf
lll:
line-length: 140
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-explanation: true # require an explanation for nolint directives
require-specific: true # require nolint directives to be specific about which linter is being skipped
revive:
rules:
# default revive rules, they have to be present otherwise they are disabled
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: increment-decrement
- name: indent-error-flow
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: unreachable-code
- name: unused-parameter
- name: var-declaration
- name: var-naming
# additional revive rules
- name: bare-return
- name: bool-literal-in-expr
- name: comment-spacings
- name: early-return
- name: defer
- name: deep-exit
- name: unused-receiver
version: "2"
formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- github.com/golangci/golangci-lint

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
default: none
enable:
- asciicheck
- bodyclose
Expand All @@ -104,7 +20,6 @@ linters:
- errcheck
- errorlint
- exhaustive
- exportloopref
- funlen
- gochecknoglobals
- gochecknoinits
Expand All @@ -113,11 +28,8 @@ linters:
- gocritic
- gocyclo
- godot
- gofmt
- goimports
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
Expand All @@ -132,31 +44,104 @@ linters:
- revive
- rowserrcheck
- staticcheck
- stylecheck
- testifylint
- thelper
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace
- wsl

# don't enable:
# - godox # Disabling because we need TODO lines at this stage of project.
# - testpackage # We also need to do unit test for unexported functions. And adding _internal in all files is cumbersome.
- wsl_v5

settings:
dupl:
threshold: 100
exhaustive:
default-signifies-exhaustive: false
funlen:
lines: 100
statements: 50
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 10
govet:
enable:
- shadow
settings:
printf:
funcs:
- (gofr.dev/pkg/gofr/Logger).Logf
- (gofr.dev/pkg/gofr/Logger).Errorf
lll:
line-length: 140
misspell:
locale: US
nolintlint:
allow-unused: false
require-explanation: true
require-specific: true
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: increment-decrement
- name: indent-error-flow
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: unreachable-code
- name: unused-parameter
- name: var-declaration
- name: var-naming
- name: bare-return
- name: bool-literal-in-expr
- name: comment-spacings
- name: early-return
- name: defer
- name: deep-exit
- name: unused-receiver
mnd:
checks:
- argument
- case
- condition
- return

service:
golangci-lint-version: 1.59.x

issues:
# exclude-use-default: false
# exclude-use-default: false # By default, golangci-lint does not enforce comments on exported types. We want it.
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- dupl
- goconst
exclusions:
rules:
- path: _test\.go
linters:
- mnd
- dupl
- goconst
- gosec # G704 SSRF false positive in test code
# G703 path traversal - paths are sanitized via sanitizePath before os.Stat calls
- path: main\.go
text: "G703:"
linters:
- gosec
Loading