-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup and stabilize (hopefully) (#36)
* and in every home * this morning * paths, paths, and everywhere even more paths * shiny happy people * restore old api
- Loading branch information
Showing
26 changed files
with
602 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
builds: | ||
- | ||
goos: | ||
- darwin | ||
- linux | ||
- windows | ||
env: | ||
- CGO_ENABLED=0 | ||
main: main.go | ||
|
||
checksum: | ||
name_template: 'checksums.txt' | ||
|
||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
<%= if (brew) { %> | ||
brews: | ||
- | ||
name: homebrew-tap | ||
github: | ||
owner: markbates | ||
name: homebrew-tap | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
Copyright (c) 2016 Mark Bates | ||
The MIT License (MIT) | ||
|
||
MIT License | ||
Copyright (c) 2019 Mark Bates | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,66 @@ | ||
TAGS ?= "sqlite" | ||
GO_BIN ?= go | ||
TAGS ?= "" | ||
GO_BIN ?= "go" | ||
|
||
install: | ||
$(GO_BIN) install -v ./grift | ||
$(GO_BIN) install -tags ${TAGS} -v ./. | ||
make tidy | ||
|
||
deps: | ||
$(GO_BIN) get github.com/gobuffalo/release | ||
$(GO_BIN) get -tags ${TAGS} -t ./... | ||
tidy: | ||
ifeq ($(GO111MODULE),on) | ||
$(GO_BIN) mod tidy | ||
else | ||
echo skipping go mod tidy | ||
endif | ||
|
||
deps: | ||
$(GO_BIN) get -tags ${TAGS} -t ./... | ||
make tidy | ||
|
||
build: | ||
$(GO_BIN) build -v . | ||
make tidy | ||
|
||
test: | ||
$(GO_BIN) test -tags ${TAGS} ./... | ||
$(GO_BIN) test -cover -tags ${TAGS} ./... | ||
make tidy | ||
|
||
ci-deps: | ||
$(GO_BIN) get -tags ${TAGS} -t ./... | ||
|
||
ci-test: | ||
$(GO_BIN) test -tags ${TAGS} -race ./... | ||
|
||
cov: | ||
$(GO_BIN) test -coverprofile cover.out -tags ${TAGS} ./... | ||
go tool cover -html cover.out | ||
make tidy | ||
|
||
lint: | ||
go get github.com/golangci/golangci-lint/cmd/golangci-lint | ||
golangci-lint run --enable-all | ||
make tidy | ||
|
||
update: | ||
$(GO_BIN) get -u -tags ${TAGS} | ||
ifeq ($(GO111MODULE),on) | ||
rm go.* | ||
$(GO_BIN) mod init | ||
$(GO_BIN) mod tidy | ||
else | ||
$(GO_BIN) get -u -tags ${TAGS} | ||
endif | ||
make test | ||
make install | ||
ifeq ($(GO111MODULE),on) | ||
$(GO_BIN) mod tidy | ||
endif | ||
make tidy | ||
|
||
release-test: | ||
$(GO_BIN) test -tags ${TAGS} -race ./... | ||
make tidy | ||
|
||
release: | ||
release -y -f version.go | ||
$(GO_BIN) get github.com/gobuffalo/release | ||
make tidy | ||
release -y -f ./cli/version.go --skip-packr | ||
make tidy | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
variables: | ||
GOPROXY: "https://proxy.golang.org" | ||
GOBIN: "$(GOPATH)/bin" # Go binaries path | ||
GOPATH: "$(system.defaultWorkingDirectory)/gopath" # Go workspace path | ||
modulePath: "$(GOPATH)/src/github.com/$(build.repository.name)" # Path to the module"s code | ||
|
||
jobs: | ||
- job: Windows | ||
pool: | ||
vmImage: "vs2017-win2016" | ||
strategy: | ||
matrix: | ||
go 1.12 (on): | ||
go_version: "1.12.13" | ||
GO111MODULE: "on" | ||
go 1.12 (off): | ||
go_version: "1.12.13" | ||
GO111MODULE: "off" | ||
go 1.13.4 (on): | ||
go_version: "1.13.4" | ||
GO111MODULE: "on" | ||
go 1.13.4 (off): | ||
go_version: "1.13.4" | ||
GO111MODULE: "off" | ||
steps: | ||
- template: azure-tests.yml | ||
|
||
- job: macOS | ||
pool: | ||
vmImage: "macOS-10.13" | ||
strategy: | ||
matrix: | ||
go 1.12 (on): | ||
go_version: "1.12.13" | ||
GO111MODULE: "on" | ||
go 1.12 (off): | ||
go_version: "1.12.13" | ||
GO111MODULE: "off" | ||
go 1.13.4 (on): | ||
go_version: "1.13.4" | ||
GO111MODULE: "on" | ||
go 1.13.4 (off): | ||
go_version: "1.13.4" | ||
GO111MODULE: "off" | ||
steps: | ||
- template: azure-tests.yml | ||
|
||
- job: Linux | ||
pool: | ||
vmImage: "ubuntu-16.04" | ||
strategy: | ||
matrix: | ||
go 1.12 (on): | ||
go_version: "1.12.13" | ||
GO111MODULE: "on" | ||
go 1.12 (off): | ||
go_version: "1.12.13" | ||
GO111MODULE: "off" | ||
go 1.13.4 (on): | ||
go_version: "1.13.4" | ||
GO111MODULE: "on" | ||
go 1.13.4 (off): | ||
go_version: "1.13.4" | ||
GO111MODULE: "off" | ||
steps: | ||
- template: azure-tests.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
steps: | ||
- task: GoTool@0 | ||
inputs: | ||
version: $(go_version) | ||
- task: Bash@3 | ||
inputs: | ||
targetType: inline | ||
script: | | ||
mkdir -p "$(GOBIN)" | ||
mkdir -p "$(GOPATH)/pkg" | ||
mkdir -p "$(modulePath)" | ||
shopt -s extglob | ||
mv !(gopath) "$(modulePath)" | ||
displayName: "Setup Go Workspace" | ||
- script: | | ||
go get -t -v ./... | ||
go test -race ./... | ||
workingDirectory: "$(modulePath)" | ||
displayName: "Tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
) | ||
|
||
func Help(ctx context.Context, args []string) error { | ||
stderr := Stderr(ctx) | ||
fmt.Fprintln(stderr, "grift <task name> [task arguments]") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package cli | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_Help(t *testing.T) { | ||
r := require.New(t) | ||
|
||
bb := &bytes.Buffer{} | ||
|
||
ctx := WithStderr(bb, context.Background()) | ||
r.NoError(Help(ctx, []string{})) | ||
|
||
r.Contains(bb.String(), "grift <task name> [task arguments]") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
"io" | ||
"os" | ||
) | ||
|
||
const ( | ||
stdin = "stdin" | ||
stdout = "stdout" | ||
stderr = "stderr" | ||
) | ||
|
||
func WithStdin(r io.Reader, ctx context.Context) context.Context { | ||
return context.WithValue(ctx, stdin, r) | ||
} | ||
|
||
func Stdin(ctx context.Context) io.Reader { | ||
if r, ok := ctx.Value(stdin).(io.Reader); ok { | ||
return r | ||
} | ||
return os.Stdin | ||
} | ||
|
||
func Stdout(ctx context.Context) io.Writer { | ||
if w, ok := ctx.Value(stdout).(io.Writer); ok { | ||
return w | ||
} | ||
return os.Stdout | ||
} | ||
|
||
func Stderr(ctx context.Context) io.Writer { | ||
if w, ok := ctx.Value(stderr).(io.Writer); ok { | ||
return w | ||
} | ||
return os.Stderr | ||
} | ||
|
||
func WithStdout(w io.Writer, ctx context.Context) context.Context { | ||
return context.WithValue(ctx, stdout, w) | ||
} | ||
|
||
func WithStderr(w io.Writer, ctx context.Context) context.Context { | ||
return context.WithValue(ctx, stderr, w) | ||
} |
Oops, something went wrong.