mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-01 13:07:49 +02:00
commit
bcc3d300ed
13
.travis.yml
13
.travis.yml
@ -1,11 +1,22 @@
|
||||
language: go
|
||||
go: 1.7.4
|
||||
install:
|
||||
- go get github.com/alecthomas/gometalinter
|
||||
- go get github.com/Masterminds/glide
|
||||
- glide install
|
||||
script:
|
||||
- go test -cover `glide nv`
|
||||
- gometalinter --vendor --disable-all \
|
||||
--enable=deadcode \
|
||||
--enable=ineffassign \
|
||||
--enable=gosimple \
|
||||
--enable=staticcheck \
|
||||
--enable=gofmt \
|
||||
--enable=goimports \
|
||||
--enable=dupl \
|
||||
--enable=misspell \
|
||||
./...
|
||||
after_success:
|
||||
test ! -z "$TRAVIS_TAG" && go run main.go
|
||||
notifications:
|
||||
email: false
|
||||
email: false
|
||||
|
@ -54,7 +54,9 @@ func Load(file string) (config ProjectConfig, err error) {
|
||||
if err != nil {
|
||||
return config, err
|
||||
}
|
||||
err = yaml.Unmarshal(data, &config)
|
||||
if err := yaml.Unmarshal(data, &config); err != nil {
|
||||
return config, err
|
||||
}
|
||||
config.fillBasicData()
|
||||
if err := config.fillFiles(); err != nil {
|
||||
return config, err
|
||||
|
@ -29,73 +29,23 @@ func TestFillFilesMissingFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFillFilesUSENMarkdown(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
os.Chdir("./.test/1")
|
||||
defer os.Chdir(cwd)
|
||||
|
||||
config := ProjectConfig{}
|
||||
err := config.fillFiles()
|
||||
|
||||
assert.NoError(err)
|
||||
assert.Equal([]string{"LICENSE.md", "README.md"}, config.Files)
|
||||
assertFiles(t, "./.test/1", []string{"LICENSE.md", "README.md"})
|
||||
}
|
||||
|
||||
func TestFillFilesRealENMarkdown(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
os.Chdir("./.test/2")
|
||||
defer os.Chdir(cwd)
|
||||
|
||||
config := ProjectConfig{}
|
||||
err := config.fillFiles()
|
||||
|
||||
assert.NoError(err)
|
||||
assert.Equal([]string{"LICENCE.md", "README.md"}, config.Files)
|
||||
assertFiles(t, "./.test/2", []string{"LICENCE.md", "README.md"})
|
||||
}
|
||||
|
||||
func TestFillFilesArbitratryENTXT(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
os.Chdir("./.test/3")
|
||||
defer os.Chdir(cwd)
|
||||
|
||||
config := ProjectConfig{}
|
||||
err := config.fillFiles()
|
||||
|
||||
assert.NoError(err)
|
||||
assert.Equal([]string{"LICENCE.txt", "README.txt"}, config.Files)
|
||||
assertFiles(t, "./.test/3", []string{"LICENCE.txt", "README.txt"})
|
||||
}
|
||||
|
||||
func TestFillFilesArbitratryENNoSuffix(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
os.Chdir("./.test/4")
|
||||
defer os.Chdir(cwd)
|
||||
|
||||
config := ProjectConfig{}
|
||||
err := config.fillFiles()
|
||||
|
||||
assert.NoError(err)
|
||||
assert.Equal([]string{"LICENCE"}, config.Files)
|
||||
assertFiles(t, "./.test/4", []string{"LICENCE"})
|
||||
}
|
||||
|
||||
func TestFillFilesChangelog(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
os.Chdir("./.test/5")
|
||||
defer os.Chdir(cwd)
|
||||
|
||||
config := ProjectConfig{}
|
||||
err := config.fillFiles()
|
||||
|
||||
assert.NoError(err)
|
||||
assert.Equal([]string{"CHANGELOG", "CHANGELOG.md"}, config.Files)
|
||||
assertFiles(t, "./.test/5", []string{"CHANGELOG", "CHANGELOG.md"})
|
||||
}
|
||||
|
||||
func TestValidadeMissingBinaryName(t *testing.T) {
|
||||
@ -118,3 +68,17 @@ func TestValidadeMinimalConfig(t *testing.T) {
|
||||
config := ProjectConfig{BinaryName: "asd", Repo: "asd/asd"}
|
||||
assert.NoError(config.validate())
|
||||
}
|
||||
|
||||
func assertFiles(t *testing.T, dir string, files []string) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
os.Chdir(dir)
|
||||
defer os.Chdir(cwd)
|
||||
|
||||
config := ProjectConfig{}
|
||||
err := config.fillFiles()
|
||||
|
||||
assert.NoError(err)
|
||||
assert.Equal(files, config.Files)
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCurrentTag(t *testing.T) {
|
||||
|
@ -84,16 +84,13 @@ func (Pipe) Run(config config.ProjectConfig) error {
|
||||
return err
|
||||
}
|
||||
func sha(client *github.Client, owner, repo, name string, out bytes.Buffer) (*string, error) {
|
||||
var sha *string
|
||||
file, _, _, err := client.Repositories.GetContents(
|
||||
owner, repo, name, &github.RepositoryContentGetOptions{},
|
||||
)
|
||||
if err == nil {
|
||||
sha = file.SHA
|
||||
} else {
|
||||
sha = github.String(fmt.Sprintf("%s", sha256.Sum256(out.Bytes())))
|
||||
return file.SHA, err
|
||||
}
|
||||
return sha, err
|
||||
return github.String(fmt.Sprintf("%s", sha256.Sum256(out.Bytes()))), err
|
||||
}
|
||||
|
||||
func buildFormulae(config config.ProjectConfig, client *github.Client) (bytes.Buffer, error) {
|
||||
|
@ -51,10 +51,7 @@ func create(system, arch string, config config.ProjectConfig) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := addFile(tw, config.BinaryName+ext(system), binaryPath(system, arch, config.BinaryName)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return addFile(tw, config.BinaryName+ext(system), binaryPath(system, arch, config.BinaryName))
|
||||
}
|
||||
|
||||
func addFile(tw *tar.Writer, name, path string) error {
|
||||
|
@ -2,8 +2,9 @@ package release
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDescription(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user