Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update build infrastructure #10

Merged
merged 3 commits into from
Sep 20, 2023
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
10 changes: 9 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ on:
- v*
jobs:
test:
strategy:
fail-fast: false
matrix:
go-version:
- stable
- oldstable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ matrix.go-version }}
- name: build
run: go build ./...
- name: test
Expand All @@ -25,4 +33,4 @@ jobs:
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
- uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5
with:
version: v1.53.2
version: v1.54.2
66 changes: 65 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,85 @@
linters:
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- decorder
- dogsled
- dupl
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecknoinits
- goconst
- gocritic
- godot
- gofmt
- gofumpt
- goheader
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
- gosimple
- gosmopolitan
- govet
- grouper
- importas
- ineffassign
- interfacebloat
- ireturn
- loggercheck
- makezero
- mirror
- misspell
- musttag
- nakedret
- nilerr
- nilnil
- noctx
- nolintlint
- nonamedreturns
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- reassign
- rowserrcheck
- sqlclosecheck
- staticcheck
- tagalign
- tagliatelle
- tenv
- testableexamples
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
- zerologlint
disable:
- cyclop
- depguard
- exhaustruct
- funlen
- gochecknoglobals
- gocognit
Expand All @@ -40,14 +89,26 @@ linters:
- gomnd
- gosec
- lll
- maintidx
- maligned
- nestif
- sqlclosecheck
- nlreturn
- revive
- stylecheck
- testpackage
- varnamelen
- wrapcheck
- wsl

linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/twpayne/go-xmlstruct)
gofumpt:
extra-rules: true
module-path: github.com/twpayne/go-xmlstruct
goimports:
local-prefixes: github.com/twpayne/go-xmlstruct

Expand All @@ -57,3 +118,6 @@ issues:
- dupl
- scopelint
path: "_test\\.go"
- linters:
- forbidigo
path: "main\\.go"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ code](https://github.com/twpayne/go-xmlstruct/blob/master/internal/tests/play/pl
Compared to existing Go struct generators like
[zek](https://github.com/miku/zek),
[XMLGen](https://github.com/dutchcoders/XMLGen), and
[chidley](https://github.com/gnewton/chidley), go-xmlstruct offers:
[chidley](https://github.com/gnewton/chidley), go-xmlstruct:

* Takes multiple XML documents as input.
* Generates field types of `bool`, `int`, `string`, or `time.Time` as
Expand Down
2 changes: 1 addition & 1 deletion generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
var (
SkipDir = fs.SkipDir
//lint:ignore ST1012 SkipFile is not an error
SkipFile = errors.New("skip file")
SkipFile = errors.New("skip file") //nolint:errname
)

// A Generator observes XML documents and generates Go structs into which the
Expand Down
7 changes: 6 additions & 1 deletion generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
)

func TestGenerator(t *testing.T) {
t.Parallel()

for _, tc := range []struct {
name string
xmlStr string
Expand Down Expand Up @@ -222,7 +224,7 @@ func TestGenerator(t *testing.T) {
`package main`,
``,
`type A struct {`,
"\tB B `xml:\"b\"`",
"\tB B `xml:\"b\"`", //nolint:dupword
`}`,
``,
`type B struct {`,
Expand Down Expand Up @@ -317,7 +319,10 @@ func TestGenerator(t *testing.T) {
),
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

generator := xmlstruct.NewGenerator(tc.options...)
if tc.xmlStr != "" {
assert.NoError(t, generator.ObserveReader(strings.NewReader(tc.xmlStr)))
Expand Down
2 changes: 2 additions & 0 deletions internal/tests/aixm/aixm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
)

func TestAIXM(t *testing.T) {
t.Parallel()

generator := xmlstruct.NewGenerator(
xmlstruct.WithExportRenames(map[string]string{
"note": "NoteLower", // Disambiguate between Note and note.
Expand Down
2 changes: 2 additions & 0 deletions internal/tests/gml/gml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
)

func TestGML(t *testing.T) {
t.Parallel()

generator := xmlstruct.NewGenerator(
xmlstruct.WithExportRenames(map[string]string{
"note": "LowerNote",
Expand Down
2 changes: 2 additions & 0 deletions internal/tests/gpx/gpx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
)

func TestGPX(t *testing.T) {
t.Parallel()

generator := xmlstruct.NewGenerator(
xmlstruct.WithExportRenames(map[string]string{
"gpx": "GPX",
Expand Down
2 changes: 2 additions & 0 deletions internal/tests/interlis/interlis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestInterlis(t *testing.T) {
t.Parallel()

generator := xmlstruct.NewGenerator(
xmlstruct.WithExportRenames(map[string]string{
"BOUNDARY": "Boundary",
Expand Down
2 changes: 2 additions & 0 deletions internal/tests/osm/osm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestOSM(t *testing.T) {
t.Parallel()

generator := xmlstruct.NewGenerator(
xmlstruct.WithExportRenames(map[string]string{
"osm": "OSM",
Expand Down
2 changes: 2 additions & 0 deletions internal/tests/play/play_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestPlay(t *testing.T) {
t.Parallel()

generator := xmlstruct.NewGenerator(
xmlstruct.WithExportRenames(map[string]string{
"ACT": "Act",
Expand Down
2 changes: 2 additions & 0 deletions internal/tests/xsd/xsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
)

func TestXSD(t *testing.T) {
t.Parallel()

generator := xmlstruct.NewGenerator(
xmlstruct.WithExportRenames(map[string]string{
"appinfo": "AppInfo",
Expand Down
5 changes: 5 additions & 0 deletions xmlstruct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

func TestDefaultExportNameFunc(t *testing.T) {
t.Parallel()

for _, tc := range []struct {
localName string
expected string
Expand Down Expand Up @@ -49,7 +51,10 @@ func TestDefaultExportNameFunc(t *testing.T) {
expected: "SnakeID",
},
} {
tc := tc
t.Run(tc.localName, func(t *testing.T) {
t.Parallel()

xmlName := xml.Name{
Local: tc.localName,
}
Expand Down
Loading