Skip to content

Commit

Permalink
Merge pull request #15 from saschagrunert/ci
Browse files Browse the repository at this point in the history
Fix CI and switch to go 1.18
  • Loading branch information
k8s-ci-robot authored May 30, 2022
2 parents 73c4a19 + 163c525 commit 94d9a46
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 45 deletions.
109 changes: 91 additions & 18 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,96 @@ issues:
- path: fake_.*\.go
linters:
- gocritic
- golint
- dupl
linters:
disable-all: true
enable:
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- deadcode
- decorder
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exportloopref
- forcetypeassert
- funlen
- gci
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- gofmt
- gofumpt
- goheader
- goimports
- golint
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- ifshort
- importas
- ineffassign
- interfacer
- maligned
- maintidx
- makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- tagliatelle
- tenv
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- varcheck
- wastedassign
- whitespace
# - exhaustive
# - exportloopref
# - funlen
# - gci
- wrapcheck
# - cyclop
# - forbidigo
# - exhaustruct
# - gochecknoglobals
# - gochecknoinits
# - gocognit
# - godot
# - goerr113
# - gomnd
# - gosec
# - ireturn
# - lll
# - nestif
# - nlreturn
# - noctx
# - nolintlint
# - scopelint
# - nonamedreturns
# - testpackage
# - varnamelen
# - wsl
linters-settings:
godox:
Expand All @@ -83,31 +113,57 @@ linters-settings:
# Diagnostic
- appendAssign
- argOrder
- badCall
- badCond
- badLock
- badRegexp
- badSorting
- builtinShadowDecl
- caseOrder
- codegenComment
- commentedOutCode
- deferInLoop
- deprecatedComment
- dupArg
- dupBranchBody
- dupCase
- dupSubExpr
- dynamicFmtString
- emptyDecl
- evalOrder
- exitAfterDefer
- externalErrorReassign
- filepathJoin
- flagDeref
- flagName
- mapKey
- nilValReturn
- offBy1
- regexpPattern
- returnAfterHttpError
- sloppyReassign
- sloppyTypeAssert
- sortSlice
- sprintfQuotedString
- sqlQuery
- syncMapLoadAndDelete
- truncateCmp
- unnecessaryDefer
- weakCond
- octalLiteral

# Performance
- appendCombine
- equalFold
- hugeParam
- indexAlloc
- preferDecodeRune
- preferFprint
- preferStringWriter
- preferWriteByte
- rangeExprCopy
- rangeValCopy
- sliceClear
- stringXbytes

# Style
- assignOp
Expand All @@ -116,27 +172,43 @@ linters-settings:
- commentFormatting
- commentedOutImport
- defaultCaseOrder
- deferUnlambda
- docStub
- dupImport
- elseif
- emptyFallthrough
- emptyStringTest
- exposedSyncMutex
- hexLiteral
- httpNoBody
- ifElseChain
- ioutilDeprecated
- methodExprCall
- newDeref
- octalLiteral
- preferFilepathJoin
- redundantSprint
- regexpMust
- regexpSimplify
- ruleguard
- singleCaseSwitch
- sloppyLen
- stringXbytes
- stringConcatSimplify
- stringsCompare
- switchTrue
- timeExprSimplify
- tooManyResultsChecker
- typeAssertChain
- typeDefFirst
- typeSwitchVar
- underef
- unlabelStmt
- unlambda
- unslice
- valSwap
- whyNoLint
- wrapperFunc
- yodaStyleExpr
# - ifElseChain

# Opinionated
- builtinShadow
Expand All @@ -145,6 +217,7 @@ linters-settings:
- nestingReduce
- paramTypeCombine
- ptrToRefParam
- todoCommentWithoutDetail
- typeUnparen
- unnamedResult
- unnecessaryBlock
14 changes: 10 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
module sigs.k8s.io/mdtoc

go 1.15
go 1.18

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/gomarkdown/markdown v0.0.0-20210514010506-3b9f47219fe7
github.com/gomarkdown/markdown v0.0.0-20220527210340-c82b80a9daf2
github.com/mmarkdown/mmark v2.0.40+incompatible
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.1
)

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gomarkdown/markdown v0.0.0-20210514010506-3b9f47219fe7 h1:oKYOfNR7Hp6XpZ4JqolL5u642Js5Z0n7psPVl+S5heo=
github.com/gomarkdown/markdown v0.0.0-20210514010506-3b9f47219fe7/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU=
github.com/gomarkdown/markdown v0.0.0-20220527210340-c82b80a9daf2 h1:VJwys0mqRBeVxECc/DyXgveOqOqI81J9sjQFZHZwJvs=
github.com/gomarkdown/markdown v0.0.0-20220527210340-c82b80a9daf2/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/mmarkdown/mmark v2.0.40+incompatible h1:vMeUeDzBK3H+/mU0oMVfMuhSXJlIA+DE/DMPQNAj5C4=
github.com/mmarkdown/mmark v2.0.40+incompatible/go.mod h1:Uvmoz7tvsWpr7bMVxIpqZPyN3FbOtzDmnsJDFp7ltJs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Expand Down
2 changes: 1 addition & 1 deletion hack/verify-golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -o errexit
set -o nounset
set -o pipefail

VERSION=v1.31.0
VERSION=v1.46.2
URL_BASE=https://raw.githubusercontent.com/golangci/golangci-lint
URL=$URL_BASE/$VERSION/install.sh

Expand Down
14 changes: 12 additions & 2 deletions mdtoc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ func testdata(subpath string) string {
}

func TestDryRun(t *testing.T) {
t.Parallel()
for _, test := range testcases {
test := test
t.Run(test.file, func(t *testing.T) {
t.Parallel()
opts := utilityOptions{
Options: mdtoc.Options{
Dryrun: true,
Expand All @@ -107,9 +110,12 @@ func TestDryRun(t *testing.T) {
}

func TestInplace(t *testing.T) {
t.Parallel()
for _, test := range testcases {
test := test
t.Run(test.file, func(t *testing.T) {
original, err := ioutil.ReadFile(test.file)
t.Parallel()
original, err := os.ReadFile(test.file)
require.NoError(t, err, test.file)

// Create a copy of the test.file to modify.
Expand Down Expand Up @@ -137,7 +143,7 @@ func TestInplace(t *testing.T) {
assert.Error(t, err, test.file)
}

updated, err := ioutil.ReadFile(tmpFile.Name())
updated, err := os.ReadFile(tmpFile.Name())
require.NoError(t, err, test.file)

if test.completeTOC || !test.validTOCTags { // Invalid tags should not modify contents.
Expand All @@ -150,13 +156,17 @@ func TestInplace(t *testing.T) {
}

func TestOutput(t *testing.T) {
t.Parallel()
for _, test := range testcases {
test := test

// Ignore the invalid cases, they're only for inplace tests.
if !test.validTOCTags {
continue
}

t.Run(test.file, func(t *testing.T) {
t.Parallel()
opts := utilityOptions{
Options: mdtoc.Options{
Dryrun: false,
Expand Down
Loading

0 comments on commit 94d9a46

Please sign in to comment.