Skip to content

Commit 127923e

Browse files
committed
update for new infra
1 parent 970a1d8 commit 127923e

11 files changed

Lines changed: 616 additions & 82 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
# added by lint-install
27+
out/

.golangci.yml

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
## Golden config for golangci-lint - strict, but within the realm of what Go authors might use.
2+
#
3+
# This is tied to the version of golangci-lint listed in the Makefile, usage with other
4+
# versions of golangci-lint will yield errors and/or false positives.
5+
#
6+
# Docs: https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
7+
# Based heavily on https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322
8+
9+
version: "2"
10+
11+
issues:
12+
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
13+
max-issues-per-linter: 0
14+
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
15+
max-same-issues: 0
16+
17+
formatters:
18+
enable:
19+
# - gci
20+
# - gofmt
21+
- gofumpt
22+
# - goimports
23+
# - golines
24+
- swaggo
25+
26+
settings:
27+
golines:
28+
# Default: 100
29+
max-len: 120
30+
31+
linters:
32+
default: all
33+
disable:
34+
# linters that give advice contrary to what the Go authors advise
35+
- decorder # checks declaration order and count of types, constants, variables and functions
36+
- dupword # [useless without config] checks for duplicate words in the source code
37+
- exhaustruct # [highly recommend to enable] checks if all structure fields are initialized
38+
- forcetypeassert # [replaced by errcheck] finds forced type assertions
39+
- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
40+
- gochecknoglobals # checks that no global variables exist
41+
- cyclop # replaced by revive
42+
- gocyclo # replaced by revive
43+
- forbidigo # needs configuration to be useful
44+
- funlen # replaced by revive
45+
- godox # TODO's are OK
46+
- ireturn # It's OK
47+
- musttag
48+
- nonamedreturns
49+
- goconst # finds repeated strings that could be replaced by a constant
50+
- goheader # checks is file header matches to pattern
51+
- gomodguard # [use more powerful depguard] allow and block lists linter for direct Go module dependencies
52+
- gomoddirectives
53+
- err113 # bad advice about dynamic errors
54+
- lll # [replaced by golines] reports long lines
55+
- mnd # detects magic numbers, duplicated by revive
56+
- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
57+
- noinlineerr # disallows inline error handling `if err := ...; err != nil {`
58+
- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated
59+
- tagliatelle # needs configuration
60+
- testableexamples # checks if examples are testable (have an expected output)
61+
- testpackage # makes you use a separate _test package
62+
- paralleltest # not every test should be in parallel
63+
- wrapcheck # not required
64+
- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines
65+
- wsl_v5 # [too strict and mostly code is not more readable] add or remove empty lines
66+
- zerologlint # detects the wrong usage of zerolog that a user forgets to dispatch zerolog.Event
67+
68+
# All settings can be found here https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
69+
settings:
70+
depguard:
71+
rules:
72+
"deprecated":
73+
files:
74+
- "$all"
75+
deny:
76+
- pkg: github.com/golang/protobuf
77+
desc: Use google.golang.org/protobuf instead, see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules
78+
- pkg: github.com/satori/go.uuid
79+
desc: Use github.com/google/uuid instead, satori's package is not maintained
80+
- pkg: github.com/gofrs/uuid$
81+
desc: Use github.com/gofrs/uuid/v5 or later, it was not a go module before v5
82+
"non-test files":
83+
files:
84+
- "!$test"
85+
deny:
86+
- pkg: math/rand$
87+
desc: Use math/rand/v2 instead, see https://go.dev/blog/randv2
88+
- pkg: "github.com/sirupsen/logrus"
89+
desc: not allowed
90+
- pkg: "github.com/pkg/errors"
91+
desc: Should be replaced by standard lib errors package
92+
93+
dupl:
94+
# token count (default: 150)
95+
threshold: 300
96+
97+
embeddedstructfieldcheck:
98+
# Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.
99+
forbid-mutex: true
100+
101+
errcheck:
102+
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
103+
check-type-assertions: true
104+
check-blank: true
105+
106+
exhaustive:
107+
# Program elements to check for exhaustiveness.
108+
# Default: [ switch ]
109+
check:
110+
- switch
111+
- map
112+
default-signifies-exhaustive: true
113+
114+
fatcontext:
115+
# Check for potential fat contexts in struct pointers.
116+
# May generate false positives.
117+
# Default: false
118+
check-struct-pointers: true
119+
120+
funcorder:
121+
# Checks if the exported methods of a structure are placed before the non-exported ones.
122+
struct-method: false
123+
124+
gocognit:
125+
min-complexity: 55
126+
127+
gocritic:
128+
enable-all: true
129+
disabled-checks:
130+
- paramTypeCombine
131+
# The list of supported checkers can be found at https://go-critic.com/overview.
132+
settings:
133+
captLocal:
134+
# Whether to restrict checker to params only.
135+
paramsOnly: false
136+
underef:
137+
# Whether to skip (*x).method() calls where x is a pointer receiver.
138+
skipRecvDeref: false
139+
hugeParam:
140+
# Default: 80
141+
sizeThreshold: 200
142+
143+
govet:
144+
enable-all: true
145+
146+
godot:
147+
scope: toplevel
148+
149+
inamedparam:
150+
# Skips check for interface methods with only a single parameter.
151+
skip-single-param: true
152+
153+
nakedret:
154+
# Default: 30
155+
max-func-lines: 4
156+
157+
nestif:
158+
min-complexity: 12
159+
160+
nolintlint:
161+
# Exclude following linters from requiring an explanation.
162+
# Default: []
163+
allow-no-explanation: [funlen, gocognit, golines]
164+
# Enable to require an explanation of nonzero length after each nolint directive.
165+
require-explanation: true
166+
# Enable to require nolint directives to mention the specific linter being suppressed.
167+
require-specific: true
168+
169+
revive:
170+
enable-all-rules: true
171+
rules:
172+
- name: add-constant
173+
severity: warning
174+
disabled: true
175+
- name: cognitive-complexity
176+
arguments: [55]
177+
- name: cyclomatic
178+
arguments: [60]
179+
- name: function-length
180+
arguments: [150, 225]
181+
- name: line-length-limit
182+
arguments: [150]
183+
- name: nested-structs
184+
disabled: true
185+
- name: max-public-structs
186+
arguments: [10]
187+
- name: flag-parameter # fixes are difficult
188+
disabled: true
189+
190+
rowserrcheck:
191+
# database/sql is always checked.
192+
# Default: []
193+
packages:
194+
- github.com/jmoiron/sqlx
195+
196+
perfsprint:
197+
# optimize fmt.Sprintf("x: %s", y) into "x: " + y
198+
strconcat: false
199+
200+
staticcheck:
201+
checks:
202+
- all
203+
204+
usetesting:
205+
# Enable/disable `os.TempDir()` detections.
206+
# Default: false
207+
os-temp-dir: true
208+
209+
varnamelen:
210+
max-distance: 70
211+
min-name-length: 2
212+
213+
exclusions:
214+
# Default: []
215+
presets:
216+
- common-false-positives
217+
rules:
218+
# Allow "err" and "ok" vars to shadow existing declarations, otherwise we get too many false positives.
219+
- text: '^shadow: declaration of "(err|ok)" shadows declaration'
220+
linters:
221+
- govet
222+
- text: "parameter 'ctx' seems to be unused, consider removing or renaming it as _"
223+
linters:
224+
- revive
225+
- text: "parameter name 'w' is too short for the scope of its usage"
226+
linters:
227+
- varnamelen
228+
- text: "parameter name 'r' is too short for the scope of its usage"
229+
linters:
230+
- varnamelen
231+
- text: "fieldalignment:"
232+
linters:
233+
- govet
234+
- path: _test\.go
235+
linters:
236+
- dupl
237+
- gosec
238+
- godot
239+
- govet # alignment
240+
- noctx
241+
- perfsprint
242+
- revive
243+
- varnamelen

Makefile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# BEGIN: lint-install .
2+
# http://github.com/codeGROOVE-dev/lint-install
3+
4+
.PHONY: deploy
5+
deploy:
6+
./hacks/deploy.sh
7+
8+
.PHONY: lint
9+
lint: _lint
10+
11+
LINT_ARCH := $(shell uname -m)
12+
LINT_OS := $(shell uname)
13+
LINT_OS_LOWER := $(shell echo $(LINT_OS) | tr '[:upper:]' '[:lower:]')
14+
LINT_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
15+
16+
# shellcheck and hadolint lack arm64 native binaries: rely on x86-64 emulation
17+
ifeq ($(LINT_OS),Darwin)
18+
ifeq ($(LINT_ARCH),arm64)
19+
LINT_ARCH=x86_64
20+
endif
21+
endif
22+
23+
LINTERS :=
24+
FIXERS :=
25+
26+
27+
GOLANGCI_LINT_CONFIG := $(LINT_ROOT)/.golangci.yml
28+
GOLANGCI_LINT_VERSION ?= v2.5.0
29+
GOLANGCI_LINT_BIN := $(LINT_ROOT)/out/linters/golangci-lint-$(GOLANGCI_LINT_VERSION)-$(LINT_ARCH)
30+
$(GOLANGCI_LINT_BIN):
31+
mkdir -p $(LINT_ROOT)/out/linters
32+
rm -rf $(LINT_ROOT)/out/linters/golangci-lint-*
33+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LINT_ROOT)/out/linters $(GOLANGCI_LINT_VERSION)
34+
mv $(LINT_ROOT)/out/linters/golangci-lint $@
35+
36+
LINTERS += golangci-lint-lint
37+
golangci-lint-lint: $(GOLANGCI_LINT_BIN)
38+
find . -name go.mod -execdir "$(GOLANGCI_LINT_BIN)" run -c "$(GOLANGCI_LINT_CONFIG)" \;
39+
40+
FIXERS += golangci-lint-fix
41+
golangci-lint-fix: $(GOLANGCI_LINT_BIN)
42+
find . -name go.mod -execdir "$(GOLANGCI_LINT_BIN)" run -c "$(GOLANGCI_LINT_CONFIG)" --fix \;
43+
44+
.PHONY: _lint $(LINTERS)
45+
_lint: $(LINTERS)
46+
47+
.PHONY: fix $(FIXERS)
48+
fix: $(FIXERS)
49+
50+
# END: lint-install .

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module github.com/r2r/dashboard
22

3-
go 1.21
3+
go 1.24.0
4+
5+
require github.com/codeGROOVE-dev/gsm v0.0.0-20251007153111-74e7bbe21f47

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/codeGROOVE-dev/gsm v0.0.0-20251007153111-74e7bbe21f47 h1:stZnLJroJ2aLVQ9Zgu4TdxuKax0cSb7CBVWmbVrI18A=
2+
github.com/codeGROOVE-dev/gsm v0.0.0-20251007153111-74e7bbe21f47/go.mod h1:KV+w19ubP32PxZPE1hOtlCpTaNpF0Bpb32w5djO8UTg=

hacks/deploy.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
#!/bin/sh
2-
PROJECT="ready-to-review"
3-
export KO_DOCKER_REPO="gcr.io/${PROJECT}/dashboard"
1+
#!/usr/bin/env bash -eux -o pipefail
2+
# Deploys Go program to Cloud Run - from cwd or arg[1].
3+
cd "${1:-.}"
44

5-
gcloud run deploy dashboard --image="$(ko publish .)" --region us-central1 --project "${PROJECT}"
5+
PROJECT="ready-two-review"
6+
REGION="us-central1"
7+
APP=$(basename "$(go list -m)")
8+
SA="$APP@$PROJECT.iam.gserviceaccount.com"
9+
10+
gcloud iam service-accounts describe "$SA" &>/dev/null ||
11+
gcloud iam service-accounts create "$APP" --project="$PROJECT"
12+
13+
grep -q gcr.io $HOME/.docker/config.json ||
14+
gcloud auth configure-docker gcr.io
15+
16+
KO_DOCKER_REPO="gcr.io/$PROJECT/$APP" ko publish . |
17+
xargs -I{} gcloud run deploy "$APP" --image={} --region="$REGION" \
18+
--service-account="$SA" --project="$PROJECT"

0 commit comments

Comments
 (0)