Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
Fix Go version check in build action. (#31)
Browse files Browse the repository at this point in the history
* Fix Go version check in build action.

* Update `make setup` to match official golangci-lint install directions.

See: https://golangci-lint.run/usage/install/#local-installation

* Update `make setup`; Install and use goreleaser from `./bin/` directory.

* Comment out dead code; leaving these lines in as they're related to unfished code that is currently unreachable.

* Fix remaining linter warnings.

* Ensure `main` branch is present on CI when running tests.
  • Loading branch information
damien authored Apr 16, 2021
1 parent 2eaa4a6 commit 569f71c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 30 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
# This repo requires the `main` branch to be checked out in order for tests to pass
# Ensure the current branch _and_ the main branch are present
# See: https://github.com/actions/checkout#Fetch-all-history-for-all-tags-and-branches
fetch-depth: 0

- uses: actions/setup-go@v2
with:
go-version: '1.16.2'

- name: Go version
- run: go version
run: go version

- name: Install dependencies
run: make setup
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ all: test
.PHONY: all

setup: ## setup development dependencies
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.39.0
curl -sSfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
.PHONY: setup

lint: ## run the fast go linters
golangci-lint run
lint: setup ## run the fast go linters
./bin/golangci-lint run
.PHONY: lint

release: build ## run a release
./bff bump
git push
goreleaser release --rm-dist
./bin/goreleaser release --rm-dist
.PHONY: release

release-snapshot: ## run a release
goreleaser release --rm-dist --snapshot
./bin/goreleaser release --rm-dist --snapshot
.PHONY: release-snapshot

build: deps ## build the binary
Expand Down
4 changes: 2 additions & 2 deletions cmd/bump.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ var bumpCmd = &cobra.Command{
break
}

if strings.Index(commit.Message, "[breaking]") != -1 {
if strings.Contains(commit.Message, "[breaking]") {
breaking = true
}

if strings.Index(commit.Message, "[feature]") != -1 {
if strings.Contains(commit.Message, "[feature]") {
feature = true
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func GetCommitLog(commit *object.Commit) string {
var commitLog string
commitMsg := strings.Split(commit.Message, "\n")[0]
shortHash := hash[:8]
r := regexp.MustCompile("\\(#\\d+\\)$")
r := regexp.MustCompile(`\(#\d+\)$`)
idx := r.FindStringIndex(commitMsg)
if idx == nil {
commitLog = fmt.Sprintf("* [%s](../../commit/%s) %s", shortHash, hash, commitMsg)
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra"
)

var cfgFile string
// var cfgFile string
var defaultBranchRef string

// rootCmd represents the base command when called without any subcommands
Expand Down
40 changes: 20 additions & 20 deletions pkg/util/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ import (

"github.com/stretchr/testify/assert"

"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
// "gopkg.in/src-d/go-git.v4"
// "gopkg.in/src-d/go-git.v4/plumbing"
// "gopkg.in/src-d/go-git.v4/plumbing/object"
// "gopkg.in/src-d/go-git.v4/plumbing/storer"
)

type validRepo struct{}
// type validRepo struct{}

func (r *validRepo) CommitObject(h plumbing.Hash) (*object.Commit, error) {
return nil, nil
}
// func (r *validRepo) CommitObject(h plumbing.Hash) (*object.Commit, error) {
// return nil, nil
// }

func (r *validRepo) Head() (*plumbing.Reference, error) {
return nil, nil
}
// func (r *validRepo) Head() (*plumbing.Reference, error) {
// return nil, nil
// }

func (r *validRepo) Log(o *git.LogOptions) (object.CommitIter, error) {
return nil, nil
}
// func (r *validRepo) Log(o *git.LogOptions) (object.CommitIter, error) {
// return nil, nil
// }

func (r *validRepo) Reference(name plumbing.ReferenceName, resolved bool) (*plumbing.Reference, error) {
return nil, nil
}
// func (r *validRepo) Reference(name plumbing.ReferenceName, resolved bool) (*plumbing.Reference, error) {
// return nil, nil
// }

func (r *validRepo) Tags() (storer.ReferenceIter, error) {
return nil, nil
}
// func (r *validRepo) Tags() (storer.ReferenceIter, error) {
// return nil, nil
// }

func Test_getGitAuthor(t *testing.T) {
a := assert.New(t)
Expand Down

0 comments on commit 569f71c

Please sign in to comment.