From fc41cd29f8cda4e30b3ab4a89b6dade8afee288d Mon Sep 17 00:00:00 2001 From: Steve Coffman Date: Wed, 14 Sep 2022 13:03:33 -0400 Subject: [PATCH] Add github actions to lint and test Signed-off-by: Steve Coffman --- .github/ISSUE_TEMPLATE.md | 14 ++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 5 ++++ .github/workflows/lint.yml | 46 ++++++++++++++++++++++++++++++++ .golangci.yaml | 45 +++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/lint.yml create mode 100644 .golangci.yaml diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..750a2f2d --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,14 @@ +### What happened? + +### What did you expect? + +### Minimal graphql.schema and models to reproduce + +### versions + - `go list -m github.com/vektah/gqlparser/v2`? + - `go version`? + + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..528fd681 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,5 @@ +Describe your PR and link to any relevant issues. + +I have: + - [ ] Added tests covering the bug / feature + - [ ] Updated any relevant documentation diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..d5265b68 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,46 @@ +name: golangci-lint +on: + push: + branches: + - main + pull_request: + branches: + - main +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 + strategy: + matrix: ${{ fromJson(needs.resolve-modules.outputs.matrix) }} + steps: + - name: Install Go + uses: actions/setup-go@v3 + 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 + 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 + # only-new-issues: true #show only new issues if it's a pull request. options working-directory and only-new-issues are incompatible \ No newline at end of file diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 00000000..accb6695 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,45 @@ +run: + timeout: 10m +linters: + disable-all: true + enable: + - ineffassign + - typecheck + - varcheck + - 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-rules: + - path: _test\.go + linters: + - errcheck + - gosec + - rowserrcheck + - makezero \ No newline at end of file