From ad22f31bcdcfd3e4cf911a1601c21a07716c68e6 Mon Sep 17 00:00:00 2001 From: William Perron Date: Mon, 19 Sep 2022 20:32:09 +0000 Subject: [PATCH] add CI workflow * silence lint errors in certain errchecks * golangci-lint: skip go installation step * silence lint error in ResponseWriter Write call Fixes #13 --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ cmd/themis-server/main.go | 2 +- store.go | 2 +- store_test.go | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a9edef0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: GitHub Actions Demo +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.19 + - uses: actions/checkout@v3 + - name: "fmt" + run: test -z $(go fmt ./...) + - name: lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + skip-go-intallation: true + skip-pkg-cache: true + skip-build-cache: true + args: --timeout 2m + - name: test + run: go test ./... \ No newline at end of file diff --git a/cmd/themis-server/main.go b/cmd/themis-server/main.go index 87a0883..5fb5301 100644 --- a/cmd/themis-server/main.go +++ b/cmd/themis-server/main.go @@ -528,7 +528,7 @@ func handleClaimAutocomplete(ctx context.Context, store *themis.Store, s *discor func serve(address string) error { http.Handle("/health", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("OK")) + w.Write([]byte("OK")) //nolint:errcheck // this is expected to always work, 'trust me bro' guaranteed })) return http.ListenAndServe(address, nil) diff --git a/store.go b/store.go index 5b3f9e6..d17901e 100644 --- a/store.go +++ b/store.go @@ -96,7 +96,7 @@ func (s *Store) Claim(ctx context.Context, userId, player, province string, clai if err != nil { return 0, fmt.Errorf("failed to begin transaction: %w", err) } - defer tx.Commit() + defer tx.Commit() //nolint:errcheck conflicts, err := s.FindConflicts(ctx, userId, province, claimType) if err != nil { diff --git a/store_test.go b/store_test.go index 179abb8..8ab98c5 100644 --- a/store_test.go +++ b/store_test.go @@ -1,3 +1,4 @@ +//nolint:errcheck package themis import (