-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
409 additions
and
55 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
variables: | ||
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.9: | ||
go_version: "1.9" | ||
go 1.10: | ||
go_version: "1.10" | ||
go 1.11 (on): | ||
go_version: "1.11" | ||
GO111MODULE: "on" | ||
go 1.11 (off): | ||
go_version: "1.11" | ||
GO111MODULE: "off" | ||
steps: | ||
- template: azure-tests.yml | ||
|
||
- job: macOS | ||
pool: | ||
vmImage: "macOS-10.13" | ||
strategy: | ||
matrix: | ||
go 1.9: | ||
go_version: "1.9" | ||
go 1.10: | ||
go_version: "1.10" | ||
go 1.11 (on): | ||
go_version: "1.11" | ||
GO111MODULE: "on" | ||
go 1.11 (off): | ||
go_version: "1.11" | ||
GO111MODULE: "off" | ||
steps: | ||
- template: azure-tests.yml | ||
|
||
- job: Linux | ||
pool: | ||
vmImage: "ubuntu-16.04" | ||
strategy: | ||
matrix: | ||
go 1.9: | ||
go_version: "1.9" | ||
go 1.10: | ||
go_version: "1.10" | ||
go 1.11 (on): | ||
go_version: "1.11" | ||
GO111MODULE: "on" | ||
go 1.11 (off): | ||
go_version: "1.11" | ||
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,41 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/gobuffalo/genny" | ||
"github.com/gobuffalo/release/genny/azure" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var azureOptions = struct { | ||
*azure.Options | ||
dryRun bool | ||
}{ | ||
Options: &azure.Options{}, | ||
} | ||
|
||
var azureCmd = &cobra.Command{ | ||
Use: "azure", | ||
Short: "generates azure pipelines files for Azure DevOps pipelines", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var run *genny.Runner = genny.WetRunner(context.Background()) | ||
if azureOptions.dryRun { | ||
run = genny.DryRunner(context.Background()) | ||
} | ||
|
||
opts := azureOptions.Options | ||
if err := run.WithNew(azure.New(opts)); err != nil { | ||
return errors.WithStack(err) | ||
} | ||
|
||
return run.Run() | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(azureCmd) | ||
azureCmd.Flags().BoolVarP(&azureOptions.dryRun, "dry-run", "d", false, "runs the generator dry") | ||
azureCmd.Flags().BoolVarP(&azureOptions.Force, "force", "f", false, "force files to overwrite existing ones") | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,25 @@ | ||
package azure | ||
|
||
import ( | ||
"github.com/gobuffalo/genny" | ||
"github.com/gobuffalo/packr/v2" | ||
"github.com/gobuffalo/plush" | ||
"github.com/gobuffalo/plushgen" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func New(opts *Options) (*genny.Generator, error) { | ||
g := genny.New() | ||
|
||
if err := opts.Validate(); err != nil { | ||
return g, errors.WithStack(err) | ||
} | ||
box := packr.New("github.com/gobuffalo/release/genny/azure/templates", "../azure/templates") | ||
if err := genny.ForceBox(g, box, opts.Force); err != nil { | ||
return g, errors.WithStack(err) | ||
} | ||
ctx := plush.NewContext() | ||
ctx.Set("opts", opts) | ||
g.Transformer(plushgen.Transformer(ctx)) | ||
return g, 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,28 @@ | ||
package azure | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gobuffalo/genny/gentest" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_New(t *testing.T) { | ||
r := require.New(t) | ||
|
||
g, err := New(&Options{}) | ||
r.NoError(err) | ||
|
||
run := gentest.NewRunner() | ||
run.With(g) | ||
|
||
r.NoError(run.Run()) | ||
|
||
res := run.Results() | ||
|
||
r.Len(res.Commands, 0) | ||
r.Len(res.Files, 2) | ||
|
||
err = gentest.CompareFiles([]string{"azure-pipelines.yml", "azure-tests.yml"}, res.Files) | ||
r.NoError(err) | ||
} |
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,10 @@ | ||
package azure | ||
|
||
type Options struct { | ||
Force bool | ||
} | ||
|
||
// Validate that options are usuable | ||
func (opts *Options) Validate() error { | ||
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 @@ | ||
package azure |
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,59 @@ | ||
variables: | ||
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.9: | ||
go_version: "1.9" | ||
go 1.10: | ||
go_version: "1.10" | ||
go 1.11 (on): | ||
go_version: "1.11" | ||
GO111MODULE: "on" | ||
go 1.11 (off): | ||
go_version: "1.11" | ||
GO111MODULE: "off" | ||
steps: | ||
- template: azure-tests.yml | ||
|
||
- job: macOS | ||
pool: | ||
vmImage: "macOS-10.13" | ||
strategy: | ||
matrix: | ||
go 1.9: | ||
go_version: "1.9" | ||
go 1.10: | ||
go_version: "1.10" | ||
go 1.11 (on): | ||
go_version: "1.11" | ||
GO111MODULE: "on" | ||
go 1.11 (off): | ||
go_version: "1.11" | ||
GO111MODULE: "off" | ||
steps: | ||
- template: azure-tests.yml | ||
|
||
- job: Linux | ||
pool: | ||
vmImage: "ubuntu-16.04" | ||
strategy: | ||
matrix: | ||
go 1.9: | ||
go_version: "1.9" | ||
go 1.10: | ||
go_version: "1.10" | ||
go 1.11 (on): | ||
go_version: "1.11" | ||
GO111MODULE: "on" | ||
go 1.11 (off): | ||
go_version: "1.11" | ||
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
Oops, something went wrong.