mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
Merge pull request #35 from capcom6/ci/linting
[ci] use of golangci-lint
This commit is contained in:
commit
6215080cfd
4
.github/workflows/docker-publish.yml
vendored
4
.github/workflows/docker-publish.yml
vendored
@ -14,10 +14,10 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# step 2: set up go
|
||||
- name: Set up Go 1.20
|
||||
- name: Set up Go 1.21
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: ">=1.20"
|
||||
go-version: "1.21"
|
||||
|
||||
# step 3: install dependencies
|
||||
- name: Install all Go dependencies
|
||||
|
||||
52
.github/workflows/golangci-lint.yml
vendored
Normal file
52
.github/workflows/golangci-lint.yml
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
name: golangci-lint
|
||||
on:
|
||||
push:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
# Optional: allow read access to pull request. Use with `only-new-issues` option.
|
||||
# pull-requests: read
|
||||
|
||||
jobs:
|
||||
golangci:
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: "1.21"
|
||||
cache: false
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
# Require: The version of golangci-lint to use.
|
||||
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
|
||||
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
|
||||
version: latest
|
||||
|
||||
# Optional: working directory, useful for monorepos
|
||||
# working-directory: somedir
|
||||
|
||||
# Optional: golangci-lint command line arguments.
|
||||
#
|
||||
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
|
||||
# The location of the configuration file can be changed by using `--config=`
|
||||
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
|
||||
args: --timeout=5m
|
||||
|
||||
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||
# only-new-issues: true
|
||||
|
||||
# Optional: if set to true, then all caching functionality will be completely disabled,
|
||||
# takes precedence over all other caching options.
|
||||
# skip-cache: true
|
||||
|
||||
# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
|
||||
# skip-pkg-cache: true
|
||||
|
||||
# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
|
||||
# skip-build-cache: true
|
||||
|
||||
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
|
||||
# install-mode: "goinstall"
|
||||
5
Makefile
5
Makefile
@ -26,8 +26,11 @@ db-upgrade-raw:
|
||||
run:
|
||||
go run cmd/$(project_name)/main.go
|
||||
|
||||
lint:
|
||||
golangci-lint run ./...
|
||||
|
||||
test:
|
||||
go test -cover ./...
|
||||
go test -race -coverprofile=coverage.out -covermode=atomic ./...
|
||||
|
||||
build:
|
||||
go build -o tmp/$(project_name) ./cmd/$(project_name)
|
||||
|
||||
@ -206,7 +206,9 @@ func (s *MessagesService) filterTimeouted(messages []models.Message) []models.Me
|
||||
v.Recipients[i].State = models.MessageStateFailed
|
||||
v.Recipients[i].Error = types.AsPointer(ErrorTTLExpired)
|
||||
}
|
||||
s.Messages.UpdateState(&v)
|
||||
if err := s.Messages.UpdateState(&v); err != nil {
|
||||
s.Logger.Error("Can't update message state", zap.Error(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
||||
@ -75,7 +75,7 @@ func (c *Client) doRequest(ctx context.Context, method, path string, headers map
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
_, _ = io.Copy(io.Discard, resp.Body)
|
||||
resp.Body.Close()
|
||||
}()
|
||||
|
||||
|
||||
@ -26,12 +26,12 @@ func TestClient_Send(t *testing.T) {
|
||||
|
||||
if string(req) != `{"message":"","phoneNumbers":null}` {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
w.Write(req)
|
||||
_, _ = w.Write(req)
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
w.Write([]byte(`{}`))
|
||||
_, _ = w.Write([]byte(`{}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user