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

Redo github actions #295

Merged
merged 3 commits into from
May 16, 2024
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
51 changes: 19 additions & 32 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,33 @@
name: golangci-lint
on:
workflow_dispatch:
push:
branches:
- main
- master
pull_request:
branches:
- main
types: [ opened, synchronize ]
# When a new revision is pushed to a PR, cancel all in-progress CI runs for that
# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
GOFLAGS: "-trimpath"
GO_VERSION: 1.19
jobs:
resolve-modules:
name: Resolve Modules
# runs-on: [self-hosted, linux, x64]
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Sources
uses: actions/checkout@v2
- id: set-matrix
run: ./tools/resolve-modules.sh
golangci:
name: Linter
needs: resolve-modules
runs-on: ubuntu-latest
golangci-lint:
strategy:
matrix: ${{ fromJson(needs.resolve-modules.outputs.matrix) }}
matrix:
go: ["1.21", "1.22"]
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
# stable: 'false' # Keep this line to be able to use rc and beta version of Go (ex: 1.18.0-rc1).
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v2
- name: lint
uses: golangci/golangci-lint-action@v3.2.0
go-version: ${{ matrix.go }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6.0.1
with:
version: latest
# skip cache because of flaky behaviors
skip-build-cache: true
skip-pkg-cache: true
working-directory: ${{ matrix.workdir }}
args: --timeout 5m --issues-exit-code=0
args: '--timeout 5m'
# only-new-issues: true #show only new issues if it's a pull request. options working-directory and only-new-issues are incompatible
25 changes: 0 additions & 25 deletions .github/workflows/manual-linter.yml

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/pull-request.yml

This file was deleted.

29 changes: 12 additions & 17 deletions .github/workflows/manual-go-test.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Manual Go Test Run

name: Test
on:
workflow_dispatch:

push:
branches:
- master
pull_request:
types: [ opened, synchronize ]
# When a new revision is pushed to a PR, cancel all in-progress CI runs for that
# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
Expand All @@ -16,28 +19,20 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- os: linux
run: ubuntu-latest
os: [ubuntu-latest]
go: ["1.21", "1.22"]
# MacOS is disabled due to the high cost multiplier on GH Actions.
#- os: darwin
# run: macos-latest
# Windows not allowed currently because of line-ending conversion issues.
#- os: windows
# run: windows-latest
continue-on-error: true
steps:
- name: Check out code
uses: actions/checkout@v3

- id: go_version
name: Read go version
run: echo "::set-output name=go_version::$(cat .go-version)"

- name: Install Go (${{ steps.go_version.outputs.go_version }})
uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.go_version.outputs.go_version }}

go-version: ${{ matrix.go }}
- name: Unit Test Golang
run: go test ./...
timeout-minutes: 30
73 changes: 41 additions & 32 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,54 @@
run:
timeout: 10m
tests: true

linters-settings:
errcheck:
exclude-functions:
- (io.Writer).Write
- io.Copy
- io.WriteString
revive:
enable-all-rules: false
rules:
- name: empty-lines
testifylint:
disable-all: true
enable:
- bool-compare
- compares
- error-is-as
- error-nil
- expected-actual
- nil-compare

linters:
disable-all: true
enable:
- bodyclose
- dupl
- errcheck
- gocritic
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- prealloc
- revive
- staticcheck
- testifylint
- typecheck
- varcheck
- unconvert
- unused
- structcheck
- deadcode
- gosimple
- goimports
- errcheck
- staticcheck
- stylecheck
- gosec
- asciicheck
- bodyclose
- exportloopref
- rowserrcheck
- makezero
- durationcheck
- prealloc
- predeclared

linters-settings:
staticcheck:
checks: ["S1002","S1004","S1007","S1009","S1010","S1012","S1019","S1020","S1021","S1024","S1030","SA2*","SA3*","SA4009","SA5*","SA6000","SA6001","SA6005", "-SA2002"]
stylecheck:
checks: ["-ST1003"]
gosec:
severity: "low"
confidence: "low"
excludes:
- G101
- G112
issues:
exclude-dirs:
- bin
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- dupl
- errcheck
- gosec
- rowserrcheck
- makezero
8 changes: 4 additions & 4 deletions ast/argmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func TestArg2Map(t *testing.T) {
{Name: "A", Value: &Value{Kind: NullValue}},
{Name: "B", Value: &Value{Kind: NullValue}},
}, nil)
require.Equal(t, nil, args["A"])
require.Equal(t, nil, args["B"])
require.Nil(t, args["A"])
require.Nil(t, args["B"])
require.Contains(t, args, "A")
require.Contains(t, args, "B")
})
Expand All @@ -55,8 +55,8 @@ func TestArg2Map(t *testing.T) {
"VarA": nil,
"VarB": nil,
})
require.Equal(t, nil, args["A"])
require.Equal(t, nil, args["B"])
require.Nil(t, args["A"])
require.Nil(t, args["B"])
require.Contains(t, args, "A")
require.Contains(t, args, "B")
})
Expand Down
2 changes: 1 addition & 1 deletion ast/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func UnmarshalSelectionSet(b []byte) (SelectionSet, error) {
return nil, err
}

var result = make([]Selection, 0)
result := make([]Selection, 0)
for _, item := range tmp {
var field Field
if err := json.Unmarshal(item, &field); err == nil {
Expand Down
2 changes: 1 addition & 1 deletion ast/document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestQueryDocMethods(t *testing.T) {
}
`})

require.Nil(t, err)
require.NoError(t, err)
t.Run("GetOperation", func(t *testing.T) {
require.EqualValues(t, "Bob", doc.Operations.ForName("Bob").Name)
require.Nil(t, doc.Operations.ForName("Alice"))
Expand Down
6 changes: 4 additions & 2 deletions ast/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ type PathElement interface {
isPathElement()
}

var _ PathElement = PathIndex(0)
var _ PathElement = PathName("")
var (
_ PathElement = PathIndex(0)
_ PathElement = PathName("")
)

func (path Path) String() string {
if path == nil {
Expand Down
4 changes: 2 additions & 2 deletions ast/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestPath_MarshalJSON(t *testing.T) {
for _, spec := range specs {
t.Run(spec.Value.String(), func(t *testing.T) {
b, err := json.Marshal(spec.Value)
require.Nil(t, err)
require.NoError(t, err)

require.Equal(t, spec.Expected, string(b))
})
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestPath_UnmarshalJSON(t *testing.T) {
t.Run(spec.Value, func(t *testing.T) {
var path Path
err := json.Unmarshal([]byte(spec.Value), &path)
require.Nil(t, err)
require.NoError(t, err)

require.Equal(t, spec.Expected, path)
})
Expand Down
1 change: 0 additions & 1 deletion formatter/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ func executeGoldenTesting(t *testing.T, cfg *goldenConfig) {
t.Fatal(err)
}
return

} else if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion gqlerror/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestErrorFormatting(t *testing.T) {
err := ErrorLocf("", 66, 2, "kabloom")

require.Equal(t, `input:66: kabloom`, err.Error())
require.Equal(t, nil, err.Extensions["file"])
require.Nil(t, err.Extensions["file"])
})

t.Run("with filename", func(t *testing.T) {
Expand Down
Loading