Skip to content

Commit

Permalink
Change to v1, using wrstat v5 (#1)
Browse files Browse the repository at this point in the history
* Add github workflows and lint config.

* Make this v1, depending on wrstat v5.
  • Loading branch information
sb10 authored Aug 23, 2024
1 parent 0a348fc commit 7c3dc87
Show file tree
Hide file tree
Showing 21 changed files with 352 additions and 104 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: golangci-lint

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.22.4
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.59.1
only-new-issues: true
29 changes: 29 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: tests

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.22.4'

- name: Run tests
run: make test

- name: Run tests with race detection
run: make race
198 changes: 198 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
run:
deadline: 4m
build-tags:
- netgo
modules-download-mode: readonly

linters-settings:
dupl:
threshold: 100
errcheck:
check-type-assertions: true
check-blank: true
exhaustive:
default-signifies-exhaustive: true
funlen:
lines: 30
statements: 20
gocognit:
min-complexity: 9
gocyclo:
min-complexity: 7
gomnd:
ignored-functions:
- 'strconv.Parse*'
govet:
shadow: true
enable-all: true
disable-all: false
disable:
- fieldalignment
lll:
line-length: 120
misspell:
locale: UK
nakedret:
max-func-lines: 20
nestif:
min-complexity: 2
prealloc:
simple: true
range-loops: true
for-loops: true
unparam:
check-exported: true
unused:
check-exported: false
whitespace:
multi-if: true
multi-func: false
wsl:
allow-cuddle-declarations: false
force-err-cuddling: true

issues:
exclude-rules:
- path: _test\.go
linters:
- funlen
- maintidx
- contextcheck
- gocognit
- gocyclo
- cyclop
- revive
- path: internal
linters:
- gomnd
- funlen
- path: cmd
linters:
- gochecknoinits
- gochecknoglobals
- dupl
- forbidigo
- path: version\.go
linters:
- forbidigo
- path: ch/from\.go
linters:
- gci
- goimports
max-issues-per-linter: 0
max-same-issues: 0
new-from-rev: master

linters:
disable-all: true
enable:
# defaults
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
# extras
- containedctx
- contextcheck
#- copyloopvar
- cyclop
- dogsled
- dupl
- dupword
- durationcheck
- err113
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- fatcontext
- forbidigo
- forcetypeassert
- funlen
- gci
- gocheckcompilerdirectives
- gochecknoglobals
- gochecknoinits
- gochecksumtype
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- goimports
- gosec
- gosmopolitan
- grouper
- importas
- inamedparam
- interfacebloat
#- intrange
- ireturn
- lll
- maintidx
- makezero
- mirror
- misspell
- mnd
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- nosprintfhostport
- perfsprint
- prealloc
- predeclared
- reassign
- revive
- sloglint
- stylecheck
- tagalign
- tenv
- thelper
- tparallel
- unconvert
- unparam
- usestdlibvars
- wastedassign
- whitespace
- wsl

#disable:
# - asasalint
# - asciicheck
# - bidichk
# - bodyclose
# - canonicalheader
# - decorder
# - depguard
# - exhaustruct
# - ginkgolinter
# - gofmt
# - gofumpt
# - goheader
# - gomoddirectives
# - gomodguard
# - goprintffuncname
# - loggercheck
# - musttag
# - nonamedreturns
# - paralleltest
# - promlinter
# - protogetter
# - rowserrcheck
# - spancheck
# - sqlclosecheck
# - tagliatelle
# - testableexamples
# - testifylint
# - testpackage
# - varnamelen
# - wrapcheck
# - zerologlint
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PKG := github.com/wtsi-ssg/wrstat/v4
PKG := github.com/wtsi-ssg/wrstat-ui/v1
VERSION := $(shell git describe --tags --always --long --dirty)
TAG := $(shell git describe --abbrev=0 --tags)
LDFLAGS = -ldflags "-X ${PKG}/cmd.Version=${VERSION}"
Expand Down Expand Up @@ -26,13 +26,13 @@ install:
@cd server/static/wrstat; npm install && npm run build:prod
@echo Starting go install
@go install -tags netgo ${LDFLAGS}
@echo Installed to ${GOPATH}/bin/wrstat
@echo Installed to ${GOPATH}/bin/wrstat-ui

installnonpm: export CGO_ENABLED = 1
installnonpm:
@rm -f ${GOPATH}/bin/wrstat
@go install -tags netgo ${LDFLAGS}
@echo installed to ${GOPATH}/bin/wrstat
@echo installed to ${GOPATH}/bin/wrstat-ui

test: export CGO_ENABLED = 1
test:
Expand Down Expand Up @@ -60,7 +60,7 @@ lintnonpm:
@golangci-lint run --timeout 2m

clean:
@rm -f ./wrstat
@rm -f ./wrstat-ui
@rm -f ./dist.zip

dist: export CGO_ENABLED = 1
Expand All @@ -69,7 +69,7 @@ dist: export CGO_ENABLED = 1
dist:
gopack pack --os linux --arch amd64 -o linux-dist.zip
github-release release --tag ${TAG} --pre-release
github-release upload --tag ${TAG} --name wrstat-linux-x86-64.zip --file linux-dist.zip
@rm -f wrstat linux-dist.zip
github-release upload --tag ${TAG} --name wrstat-ui-linux-x86-64.zip --file linux-dist.zip
@rm -f wrstat-ui linux-dist.zip

.PHONY: test race bench lint build install clean dist
6 changes: 3 additions & 3 deletions cmd/dbinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (
"log/slog"

"github.com/spf13/cobra"
"github.com/wtsi-hgi/wrstat-ui/v4/server"
"github.com/wtsi-ssg/wrstat/v4/basedirs"
"github.com/wtsi-ssg/wrstat/v4/dgut"
"github.com/wtsi-hgi/wrstat-ui/v1/server"
"github.com/wtsi-ssg/wrstat/v5/basedirs"
"github.com/wtsi-ssg/wrstat/v5/dgut"
)

// dbinfoCmd represents the server command.
Expand Down
2 changes: 1 addition & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (

"github.com/inconshreveable/log15"
"github.com/spf13/cobra"
"github.com/wtsi-hgi/wrstat-ui/v4/server"
"github.com/wtsi-hgi/wrstat-ui/v1/server"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/where.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
gas "github.com/wtsi-hgi/go-authserver"
"github.com/wtsi-hgi/wrstat-ui/v4/server"
"github.com/wtsi-hgi/wrstat-ui/v1/server"
)

type Error string
Expand Down
Loading

0 comments on commit 7c3dc87

Please sign in to comment.