-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ci for PRs, fix fmt issues, generate SBOMS for source artif… (
#34) * feat: add ci for PRs, fix fmt issues, generate SBOMS for source artifacts, add gitleaks, Pin go to 1.23.6 * feat: remove gitleaks workflow configuration * feat: update archive format to array syntax in goreleaser configuration * feat: update archive configuration to use 'formats' key for consistency * fix: update golangci-lint action to exit with code 1 on issues
- Loading branch information
Showing
10 changed files
with
266 additions
and
15 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,21 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{yml,yaml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[{go.mod,go.sum,*.go}] | ||
indent_style = tab | ||
indent_size = 4 |
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: ci | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
env: | ||
GO_VERSION: '1.23.6' | ||
|
||
jobs: | ||
lint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Check go mod | ||
run: | | ||
go mod tidy | ||
git diff --exit-code go.mod | ||
git diff --exit-code go.sum | ||
- name: lint | ||
uses: golangci/[email protected] | ||
with: | ||
version: latest | ||
args: --issues-exit-code=1 --config=.golangci.yml | ||
|
||
ci-linux: | ||
name: ci-linux | ||
needs: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Build with Goreleaser | ||
uses: goreleaser/[email protected] | ||
with: | ||
distribution: goreleaser | ||
version: '~> v2' | ||
args: release --snapshot --skip publish,archive,sbom,homebrew --clean --config .goreleaser.yaml | ||
|
||
ci-windows: | ||
name: ci-windows | ||
needs: ci-linux | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/[email protected] | ||
with: | ||
distribution: goreleaser | ||
version: '~> v2' | ||
args: release --snapshot --skip publish,archive,sbom,chocolatey,winget --clean --config .goreleaser-windows.yaml |
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 |
---|---|---|
@@ -0,0 +1,134 @@ | ||
run: | ||
tests: true | ||
allow-parallel-runners: true | ||
timeout: 5m | ||
|
||
# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml | ||
linters: | ||
# Disable all linters. | ||
# Default: false | ||
disable-all: true | ||
# Enable specific linter | ||
enable: | ||
- asciicheck | ||
- bidichk | ||
- copyloopvar | ||
- dupl | ||
- errorlint | ||
- funlen | ||
#- errcheck | ||
- gofmt | ||
- goconst | ||
- gofumpt | ||
- gocyclo | ||
- godox | ||
- gosec | ||
#- gocritic | ||
#- govet | ||
- goimports | ||
- goheader | ||
- misspell | ||
- nolintlint | ||
#- revive | ||
#- stylecheck | ||
- staticcheck | ||
- tparallel | ||
- tagliatelle | ||
- unconvert | ||
- unparam | ||
- whitespace | ||
#- nilerr | ||
|
||
linters-settings: | ||
dupl: | ||
# Tokens count to trigger issue. | ||
# Default: 150 | ||
threshold: 100 | ||
|
||
errorlint: | ||
# Check whether fmt.Errorf uses the %w verb for formatting errors. | ||
# Default: true | ||
asserts: false | ||
|
||
funlen: | ||
# Checks the number of lines in a function. | ||
# Default: 60 | ||
lines: -1 | ||
# Default: 40 | ||
statements: 50 | ||
# Ignore comments when counting lines. | ||
# Default false | ||
ignore-comments: true | ||
|
||
goconst: | ||
# Minimal length of string constant. | ||
# Default: 3 | ||
min-len: 2 | ||
# Default: 3 | ||
min-occurrences: 3 | ||
|
||
# gocritic: | ||
# enabled-tags: | ||
# - diagnostic | ||
# - experimental | ||
# - opinionated | ||
# - performance | ||
# - style | ||
# disabled-checks: | ||
# - dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
# - ifElseChain | ||
# - octalLiteral | ||
# - whyNoLint | ||
|
||
gocyclo: | ||
# Minimal code complexity to report. | ||
# Default: 30 (but we recommend 10-20) | ||
min-complexity: 15 | ||
|
||
godox: | ||
keywords: | ||
- FIXME | ||
#- TODO | ||
- FIX | ||
- NOTE | ||
- OPTIMIZE # marks code that should be optimized before merging | ||
- HACK # marks hack-around that should be removed before merging | ||
|
||
gofmt: | ||
# Simplify code: gofmt with `-s` option. | ||
# Default: true | ||
simplify: false | ||
# Apply the rewrite rules to the source before reformatting. | ||
# https://pkg.go.dev/cmd/gofmt | ||
# Default: [] | ||
rewrite-rules: | ||
# - pattern: 'interface{}' | ||
# replacement: 'any' | ||
- pattern: 'a[b:len(a)]' | ||
replacement: 'a[b:]' | ||
|
||
goimports: | ||
local-prefixes: github.com/golangci/golangci-lint | ||
|
||
# govet: | ||
# enable-all: true | ||
# disable: | ||
# - fieldalignment | ||
|
||
misspell: | ||
# Correct spellings using locale preferences for US or UK. | ||
locale: US | ||
|
||
nolintlint: | ||
# Disable to ensure that all nolint directives actually have an effect. | ||
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: | ||
# - name: indent-error-flow | ||
# - name: unexported-return | ||
# disabled: true | ||
# - name: unused-parameter | ||
# - name: unused-receiver |
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
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