Skip to content

Commit

Permalink
Merge pull request #306 from OpsLevel/db/enforce-linting-in-ci
Browse files Browse the repository at this point in the history
add error check to JSON unmarshal, ci fails if linting fails
  • Loading branch information
davidbloss authored Nov 15, 2023
2 parents b81d606 + ca8bf15 commit 56f16ef
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Feature-20231115-103353.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Feature
body: add error check to JSON unmarshalling
time: 2023-11-15T10:33:53.209882-06:00
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ jobs:
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Tests
- name: Lint code
run: |-
task setup
task lint
task test
- name: Test code
run: task test
- name: Upload Coverage
run: |-
bash <(curl -s https://codecov.io/bash)
5 changes: 0 additions & 5 deletions .golangci.yml

This file was deleted.

4 changes: 3 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tasks:
desc: Formatting and linting
deps: [install-gofumpt]
cmds:
- gofumpt -d .
- test -z "$(gofumpt -d -e . | tee /dev/stderr)"
- go vet ./...
- golangci-lint run

Expand Down Expand Up @@ -60,10 +60,12 @@ tasks:
cmds:
- task: install-go-tool
vars: { GO_TOOL: "gofumpt", GO_TOOL_PATH: "mvdan.cc/gofumpt@latest" }
- echo " 'gofumpt' is installed."

install-golangci-lint:
desc: go install "golangci-lint" and set GOBIN if not set
silent: true
cmds:
- task: install-go-tool
vars: { GO_TOOL: "golangci-lint", GO_TOOL_PATH: "github.com/golangci/golangci-lint/cmd/golangci-lint@latest" }
- echo " 'golangci-lint' is installed."
4 changes: 3 additions & 1 deletion clientGQL_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ func GraphQLQueryTemplate(request string) autopilot.GraphqlQuery {
exp := autopilot.GraphqlQuery{
Variables: nil,
}
json.Unmarshal([]byte(Templated(request)), &exp)
if err := json.Unmarshal([]byte(Templated(request)), &exp); err != nil {
panic(err)
}
return exp
}

Expand Down
4 changes: 3 additions & 1 deletion json.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ func (s JSON) GetGraphQLType() string { return "JSON" }

func NewJSON(data string) JSON {
result := make(JSON)
json.Unmarshal([]byte(data), &result)
if err := json.Unmarshal([]byte(data), &result); err != nil {
panic(err)
}
return result
}

Expand Down

0 comments on commit 56f16ef

Please sign in to comment.