Skip to content

Commit

Permalink
Merge pull request #5 from d-tsuji/feature/#4
Browse files Browse the repository at this point in the history
fix: ci fail (#4) and golangci-linter error
  • Loading branch information
d-tsuji committed Jan 24, 2021
2 parents 9313e54 + d24fef6 commit 136ec8f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 19 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/test.yaml
Expand Up @@ -10,18 +10,16 @@ jobs:
- ubuntu-latest
- macOS-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Setup Go
uses: actions/setup-go@v1
- name: setup go
uses: actions/setup-go@v2
with:
go-version: 1.x
- name: Add $GOPATH/bin to $PATH
run: echo "::add-path::$(go env GOPATH)/bin"
- name: Test
run: make test-cover
- name: checkout
uses: actions/checkout@v2
- name: Lint
run: make lint
- name: Test
run: make test-cover
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
Expand Down
27 changes: 27 additions & 0 deletions .golangci.yml
@@ -0,0 +1,27 @@
run:
timeout: 10m

linters:
disable-all: true
enable:
- errcheck
- goimports
- gosimple
- govet
- misspell
- staticcheck
- structcheck
- unused

issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
- gosimple

linters-settings:
govet:
enable-all: true
disable:
- shadow
10 changes: 7 additions & 3 deletions Makefile
Expand Up @@ -3,6 +3,7 @@
BIN := qiisync
BUILD_LDFLAGS := "-s -w"
GOBIN ?= $(shell go env GOPATH)/bin
GOLANGCILINT_VERSION := 1.35.2
export GO111MODULE=on

repo_name := d-tsuji/qiisync
Expand All @@ -14,8 +15,11 @@ deps:
go mod tidy

devel-deps: deps
GO111MODULE=off go get -u \
golang.org/x/lint/golint
sh -c '\
tmpdir=$$(mktemp -d); \
cd $$tmpdir; \
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCILINT_VERSION}; \
rm -rf $$tmpdir'

build:
go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) ./cmd/qiisync
Expand All @@ -29,7 +33,7 @@ test-cover: deps

lint: devel-deps
go vet ./...
$(GOBIN)/golint -set_exit_status ./...
golangci-lint run --config .golangci.yml

clean:
rm -rf $(BIN)
Expand Down
4 changes: 2 additions & 2 deletions broker.go
Expand Up @@ -251,7 +251,7 @@ func (b *Broker) store(path string, article *Article) error {
if err != nil {
return err
}
f.WriteString(fullContext)
_, _ = f.WriteString(fullContext)

return os.Chtimes(path, article.Item.UpdatedAt, article.Item.UpdatedAt)
}
Expand Down Expand Up @@ -377,7 +377,7 @@ func (b *Broker) UploadFresh(a *Article) (bool, error) {
return false, err
}

if a.Item.UpdatedAt.After(ra.Item.UpdatedAt) == false {
if !a.Item.UpdatedAt.After(ra.Item.UpdatedAt) {
Logf("", "article is not updated. remote=%s > local=%s", ra.Item.UpdatedAt, a.Item.UpdatedAt)
return false, nil
}
Expand Down
6 changes: 3 additions & 3 deletions broker_test.go
Expand Up @@ -124,7 +124,7 @@ func Test_fetchRemoteArticleNoID(t *testing.T) {
ArticleHeader: &ArticleHeader{ID: ""},
})
if err == nil {
t.Errorf("expected error occured if no article ID")
t.Errorf("expected error occurred if no article ID")
return
}
}
Expand Down Expand Up @@ -833,7 +833,7 @@ func TestPatchArticleNoID(t *testing.T) {

err := broker.patchArticle(&PostItem{ID: ""})
if err == nil {
t.Errorf("expected error occured if no article ID")
t.Errorf("expected error occurred if no article ID")
return
}
}
Expand Down Expand Up @@ -861,7 +861,7 @@ func TestPatchInvalidResponse(t *testing.T) {
ID: "c686397e4a0f4f11683d",
})
if err == nil {
t.Errorf("expected error occured if cannot decode json")
t.Errorf("expected error occurred if cannot decode json")
return
}
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/qiisync/main.go
Expand Up @@ -19,7 +19,7 @@ func main() {
commandPost,
commandUpdate,
}
app.Version = fmt.Sprintf("%s", qiisync.Version)
app.Version = qiisync.Version
err := app.Run(os.Args)
if err != nil {
if err != errCommandHelp {
Expand Down Expand Up @@ -60,7 +60,7 @@ var commandPost = &cli.Command{
Action: func(c *cli.Context) error {
filename := c.Args().First()
if filename == "" {
cli.ShowCommandHelp(c, "post")
_ = cli.ShowCommandHelp(c, "post")
return errCommandHelp
}

Expand Down Expand Up @@ -142,7 +142,7 @@ var commandUpdate = &cli.Command{
Action: func(c *cli.Context) error {
filename := c.Args().First()
if filename == "" {
cli.ShowCommandHelp(c, "update")
_ = cli.ShowCommandHelp(c, "update")
return errCommandHelp
}

Expand Down

0 comments on commit 136ec8f

Please sign in to comment.