diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 000000000..79173aee6 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,45 @@ +name: Go +on: + push: + branches: [master] + pull_request: +env: + GOPROXY: "https://proxy.golang.org" + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run golangci-lint + uses: actions-contrib/golangci-lint@v1 + + test: + name: Test + strategy: + matrix: + go-version: [1.13.x, 1.14.x] + platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v2 + - name: Run unit tests + run: go test -v -race -coverprofile=coverage -covermode=atomic ./... + - name: Upload coverage report to Codecov + uses: codecov/codecov-action@v1.0.6 + with: + file: ./coverage + flags: unittests + - name: Cache downloaded modules + uses: actions/cache@v1 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ebdcb7d17..000000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: go -os: linux -dist: xenial -go: - - 1.9.x - - 1.10.x - - 1.11.x - - 1.12.x - - 1.13.x - - 1.14.x -go_import_path: github.com/gogs/git-module -env: - - GO111MODULE=on -install: - - go get -t -v ./... -script: - - go test -v -race -verbose -coverprofile=coverage.txt -covermode=atomic -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index 5fd916907..f47d14951 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # Git Module -[![Build Status](https://img.shields.io/travis/gogs/git-module/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/gogs/git-module) [![Build status](https://img.shields.io/appveyor/ci/unknwon/gogs-git-module?logo=appveyor&style=for-the-badge)](https://ci.appveyor.com/project/unknwon/gogs-git-module/branch/master) [![codecov](https://img.shields.io/codecov/c/github/gogs/git-module/master?logo=codecov&style=for-the-badge)](https://codecov.io/gh/gogs/git-module) [![GoDoc](https://img.shields.io/badge/GoDoc-Reference-blue?style=for-the-badge&logo=go)](https://pkg.go.dev/github.com/gogs/git-module?tab=doc) [![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge&logo=sourcegraph)](https://sourcegraph.com/github.com/gogs/git-module) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/gogs/git-module/Go?logo=github&style=for-the-badge)](https://github.com/gogs/git-module/actions?query=workflow%3AGo) +[![codecov](https://img.shields.io/codecov/c/github/gogs/git-module/master?logo=codecov&style=for-the-badge)](https://codecov.io/gh/gogs/git-module) +[![GoDoc](https://img.shields.io/badge/GoDoc-Reference-blue?style=for-the-badge&logo=go)](https://pkg.go.dev/github.com/gogs/git-module?tab=doc) +[![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge&logo=sourcegraph)](https://sourcegraph.com/github.com/gogs/git-module) Package git-module is a Go module for Git access through shell commands. diff --git a/diff.go b/diff.go index f1c80d871..cc58e54e6 100644 --- a/diff.go +++ b/diff.go @@ -505,5 +505,4 @@ func StreamParseDiff(r io.Reader, done chan<- SteamParseDiffResult, maxFiles, ma Diff: diff, Err: err, } - return } diff --git a/repo_commit.go b/repo_commit.go index 066bec8cc..9976057bf 100644 --- a/repo_commit.go +++ b/repo_commit.go @@ -87,7 +87,7 @@ func (r *Repository) CatFileCommit(rev string, opts ...CatFileCommitOptions) (*C return cache.(*Commit), nil } - commitID, err := r.RevParse(rev, RevParseOptions{Timeout: opt.Timeout}) + commitID, err := r.RevParse(rev, RevParseOptions{Timeout: opt.Timeout}) //nolint if err != nil { return nil, err } diff --git a/repo_diff.go b/repo_diff.go index 68623a753..c52b947d5 100644 --- a/repo_diff.go +++ b/repo_diff.go @@ -85,7 +85,7 @@ func (r *Repository) RawDiff(rev string, diffType RawDiffFormat, w io.Writer, op opt = opts[0] } - commit, err := r.CatFileCommit(rev, CatFileCommitOptions{Timeout: opt.Timeout}) + commit, err := r.CatFileCommit(rev, CatFileCommitOptions{Timeout: opt.Timeout}) //nolint if err != nil { return err } diff --git a/repo_tree.go b/repo_tree.go index 430a6c01d..6afc33e26 100644 --- a/repo_tree.go +++ b/repo_tree.go @@ -100,7 +100,7 @@ func (r *Repository) LsTree(rev string, opts ...LsTreeOptions) (*Tree, error) { } var err error - rev, err = r.RevParse(rev, RevParseOptions{Timeout: opt.Timeout}) + rev, err = r.RevParse(rev, RevParseOptions{Timeout: opt.Timeout}) //nolint if err != nil { return nil, err }