Skip to content

Commit 6d16c05

Browse files
Redo github actions (#295)
* Redo github actions Signed-off-by: Steve Coffman <[email protected]> * Update golangci-lint to match gqlgen Signed-off-by: Steve Coffman <[email protected]> * Linter fixes Signed-off-by: Steve Coffman <[email protected]> --------- Signed-off-by: Steve Coffman <[email protected]>
1 parent 3c0d3ac commit 6d16c05

32 files changed

+183
-262
lines changed

.github/workflows/lint.yml

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,33 @@
11
name: golangci-lint
22
on:
3+
workflow_dispatch:
34
push:
45
branches:
5-
- main
6+
- master
67
pull_request:
7-
branches:
8-
- main
8+
types: [ opened, synchronize ]
9+
# When a new revision is pushed to a PR, cancel all in-progress CI runs for that
10+
# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
915
env:
1016
GOFLAGS: "-trimpath"
11-
GO_VERSION: 1.19
1217
jobs:
13-
resolve-modules:
14-
name: Resolve Modules
15-
# runs-on: [self-hosted, linux, x64]
16-
runs-on: ubuntu-latest
17-
outputs:
18-
matrix: ${{ steps.set-matrix.outputs.matrix }}
19-
steps:
20-
- name: Checkout Sources
21-
uses: actions/checkout@v2
22-
- id: set-matrix
23-
run: ./tools/resolve-modules.sh
24-
golangci:
25-
name: Linter
26-
needs: resolve-modules
27-
runs-on: ubuntu-latest
18+
golangci-lint:
2819
strategy:
29-
matrix: ${{ fromJson(needs.resolve-modules.outputs.matrix) }}
20+
matrix:
21+
go: ["1.21", "1.22"]
22+
runs-on: ubuntu-latest
3023
steps:
31-
- name: Install Go
32-
uses: actions/setup-go@v3
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-go@v5
3326
with:
34-
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
35-
go-version: ${{ env.GO_VERSION }}
36-
- uses: actions/checkout@v2
37-
- name: lint
38-
uses: golangci/[email protected]
27+
go-version: ${{ matrix.go }}
28+
- name: golangci-lint
29+
uses: golangci/[email protected]
3930
with:
4031
version: latest
41-
# skip cache because of flaky behaviors
42-
skip-build-cache: true
43-
skip-pkg-cache: true
44-
working-directory: ${{ matrix.workdir }}
45-
args: --timeout 5m --issues-exit-code=0
32+
args: '--timeout 5m'
4633
# only-new-issues: true #show only new issues if it's a pull request. options working-directory and only-new-issues are incompatible

.github/workflows/manual-linter.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/pull-request.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
name: Manual Go Test Run
2-
1+
name: Test
32
on:
43
workflow_dispatch:
5-
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [ opened, synchronize ]
69
# When a new revision is pushed to a PR, cancel all in-progress CI runs for that
710
# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency
811
concurrency:
@@ -16,28 +19,20 @@ jobs:
1619
strategy:
1720
fail-fast: false
1821
matrix:
19-
include:
20-
- os: linux
21-
run: ubuntu-latest
22+
os: [ubuntu-latest]
23+
go: ["1.21", "1.22"]
2224
# MacOS is disabled due to the high cost multiplier on GH Actions.
2325
#- os: darwin
2426
# run: macos-latest
2527
# Windows not allowed currently because of line-ending conversion issues.
2628
#- os: windows
2729
# run: windows-latest
30+
continue-on-error: true
2831
steps:
29-
- name: Check out code
30-
uses: actions/checkout@v3
31-
32-
- id: go_version
33-
name: Read go version
34-
run: echo "::set-output name=go_version::$(cat .go-version)"
35-
36-
- name: Install Go (${{ steps.go_version.outputs.go_version }})
37-
uses: actions/setup-go@v3
32+
- uses: actions/checkout@v4
33+
- uses: actions/setup-go@v5
3834
with:
39-
go-version: ${{ steps.go_version.outputs.go_version }}
40-
35+
go-version: ${{ matrix.go }}
4136
- name: Unit Test Golang
4237
run: go test ./...
4338
timeout-minutes: 30

.golangci.yaml

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,54 @@
11
run:
2-
timeout: 10m
2+
tests: true
3+
4+
linters-settings:
5+
errcheck:
6+
exclude-functions:
7+
- (io.Writer).Write
8+
- io.Copy
9+
- io.WriteString
10+
revive:
11+
enable-all-rules: false
12+
rules:
13+
- name: empty-lines
14+
testifylint:
15+
disable-all: true
16+
enable:
17+
- bool-compare
18+
- compares
19+
- error-is-as
20+
- error-nil
21+
- expected-actual
22+
- nil-compare
23+
324
linters:
425
disable-all: true
526
enable:
27+
- bodyclose
28+
- dupl
29+
- errcheck
30+
- gocritic
31+
- gofmt
32+
- goimports
33+
- gosimple
34+
- govet
635
- ineffassign
36+
- misspell
37+
- nakedret
38+
- prealloc
39+
- revive
40+
- staticcheck
41+
- testifylint
742
- typecheck
8-
- varcheck
43+
- unconvert
944
- unused
10-
- structcheck
11-
- deadcode
12-
- gosimple
13-
- goimports
14-
- errcheck
15-
- staticcheck
16-
- stylecheck
17-
- gosec
18-
- asciicheck
19-
- bodyclose
20-
- exportloopref
21-
- rowserrcheck
22-
- makezero
23-
- durationcheck
24-
- prealloc
25-
- predeclared
2645

27-
linters-settings:
28-
staticcheck:
29-
checks: ["S1002","S1004","S1007","S1009","S1010","S1012","S1019","S1020","S1021","S1024","S1030","SA2*","SA3*","SA4009","SA5*","SA6000","SA6001","SA6005", "-SA2002"]
30-
stylecheck:
31-
checks: ["-ST1003"]
32-
gosec:
33-
severity: "low"
34-
confidence: "low"
35-
excludes:
36-
- G101
37-
- G112
3846
issues:
47+
exclude-dirs:
48+
- bin
3949
exclude-rules:
50+
# Exclude some linters from running on tests files.
4051
- path: _test\.go
4152
linters:
53+
- dupl
4254
- errcheck
43-
- gosec
44-
- rowserrcheck
45-
- makezero

ast/argmap_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func TestArg2Map(t *testing.T) {
3232
{Name: "A", Value: &Value{Kind: NullValue}},
3333
{Name: "B", Value: &Value{Kind: NullValue}},
3434
}, nil)
35-
require.Equal(t, nil, args["A"])
36-
require.Equal(t, nil, args["B"])
35+
require.Nil(t, args["A"])
36+
require.Nil(t, args["B"])
3737
require.Contains(t, args, "A")
3838
require.Contains(t, args, "B")
3939
})
@@ -55,8 +55,8 @@ func TestArg2Map(t *testing.T) {
5555
"VarA": nil,
5656
"VarB": nil,
5757
})
58-
require.Equal(t, nil, args["A"])
59-
require.Equal(t, nil, args["B"])
58+
require.Nil(t, args["A"])
59+
require.Nil(t, args["B"])
6060
require.Contains(t, args, "A")
6161
require.Contains(t, args, "B")
6262
})

ast/decode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func UnmarshalSelectionSet(b []byte) (SelectionSet, error) {
1111
return nil, err
1212
}
1313

14-
var result = make([]Selection, 0)
14+
result := make([]Selection, 0)
1515
for _, item := range tmp {
1616
var field Field
1717
if err := json.Unmarshal(item, &field); err == nil {

ast/document_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestQueryDocMethods(t *testing.T) {
1818
}
1919
`})
2020

21-
require.Nil(t, err)
21+
require.NoError(t, err)
2222
t.Run("GetOperation", func(t *testing.T) {
2323
require.EqualValues(t, "Bob", doc.Operations.ForName("Bob").Name)
2424
require.Nil(t, doc.Operations.ForName("Alice"))

ast/path.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ type PathElement interface {
1414
isPathElement()
1515
}
1616

17-
var _ PathElement = PathIndex(0)
18-
var _ PathElement = PathName("")
17+
var (
18+
_ PathElement = PathIndex(0)
19+
_ PathElement = PathName("")
20+
)
1921

2022
func (path Path) String() string {
2123
if path == nil {

ast/path_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestPath_MarshalJSON(t *testing.T) {
5757
for _, spec := range specs {
5858
t.Run(spec.Value.String(), func(t *testing.T) {
5959
b, err := json.Marshal(spec.Value)
60-
require.Nil(t, err)
60+
require.NoError(t, err)
6161

6262
require.Equal(t, spec.Expected, string(b))
6363
})
@@ -88,7 +88,7 @@ func TestPath_UnmarshalJSON(t *testing.T) {
8888
t.Run(spec.Value, func(t *testing.T) {
8989
var path Path
9090
err := json.Unmarshal([]byte(spec.Value), &path)
91-
require.Nil(t, err)
91+
require.NoError(t, err)
9292

9393
require.Equal(t, spec.Expected, path)
9494
})

formatter/formatter_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ func executeGoldenTesting(t *testing.T, cfg *goldenConfig) {
215215
t.Fatal(err)
216216
}
217217
return
218-
219218
} else if err != nil {
220219
t.Fatal(err)
221220
}

gqlerror/error_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestErrorFormatting(t *testing.T) {
3535
err := ErrorLocf("", 66, 2, "kabloom")
3636

3737
require.Equal(t, `input:66: kabloom`, err.Error())
38-
require.Equal(t, nil, err.Extensions["file"])
38+
require.Nil(t, err.Extensions["file"])
3939
})
4040

4141
t.Run("with filename", func(t *testing.T) {

0 commit comments

Comments
 (0)