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

Commit

Permalink
Merge pull request #206 from gobuffalo/development
Browse files Browse the repository at this point in the history
Updating `main`
  • Loading branch information
paganotoni authored Aug 5, 2022
2 parents e5eb754 + a49a62a commit 4f1ca47
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 36 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gobuffalo/cli
go 1.16

require (
github.com/BurntSushi/toml v1.1.0
github.com/BurntSushi/toml v1.2.0
github.com/fatih/color v1.13.0
github.com/gobuffalo/attrs v1.0.2
github.com/gobuffalo/buffalo-pop/v3 v3.0.6
Expand All @@ -15,7 +15,7 @@ require (
github.com/gobuffalo/grift v1.5.1
github.com/gobuffalo/logger v1.0.6
github.com/gobuffalo/meta v0.3.2
github.com/gobuffalo/plush/v4 v4.1.13
github.com/gobuffalo/plush/v4 v4.1.14
github.com/gobuffalo/pop/v6 v6.0.6
github.com/gobuffalo/refresh v1.13.1
github.com/google/go-cmp v0.5.8
Expand All @@ -26,7 +26,7 @@ require (
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.8.0
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
golang.org/x/tools v0.1.11
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/tools v0.1.12
gopkg.in/yaml.v2 v2.4.0
)
19 changes: 13 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
Expand Down Expand Up @@ -182,8 +183,9 @@ github.com/gobuffalo/nulls v0.4.1 h1:k7QVCJfMplv9VRQQLb4N1d8tXUdGvcdMNfp4BfMnG2M
github.com/gobuffalo/nulls v0.4.1/go.mod h1:pp8e1hWTRJZFpMl4fj/CVbSMlaxjeGKkFq4RuBZi3w8=
github.com/gobuffalo/packd v1.0.1 h1:U2wXfRr4E9DH8IdsDLlRFwTZTK7hLfq9qT/QHXGVe/0=
github.com/gobuffalo/packd v1.0.1/go.mod h1:PP2POP3p3RXGz7Jh6eYEf93S7vA2za6xM7QT85L4+VY=
github.com/gobuffalo/plush/v4 v4.1.13 h1:tru7S39kYaefzM+dk+W1bib65ZVkS1nV+6ARB7yPWn0=
github.com/gobuffalo/plush/v4 v4.1.13/go.mod h1:s3hUyj/JlwEiJ039OBJevojq9xT40D1pgekw0o88CVU=
github.com/gobuffalo/plush/v4 v4.1.14 h1:F3IRVRHVBVJZA4g//zbq0lyF+QBjNtZIGC6e/2k86L8=
github.com/gobuffalo/plush/v4 v4.1.14/go.mod h1:s3hUyj/JlwEiJ039OBJevojq9xT40D1pgekw0o88CVU=
github.com/gobuffalo/pop/v6 v6.0.6 h1:M/CJ9RLibCTN0OtsgASmVtKqyEXJAreF8oamZrHscc4=
github.com/gobuffalo/pop/v6 v6.0.6/go.mod h1:toTxNJnsSuSlyK6w0yGb4YXSNIHsi2chQYC2CjBF9Ac=
github.com/gobuffalo/refresh v1.13.1 h1:P5/F+aGusF2Jg829tVf/SSGBmMyaFQekYGFG+0t90Xw=
Expand Down Expand Up @@ -554,6 +556,7 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=
go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
Expand Down Expand Up @@ -684,8 +687,9 @@ golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 h1:NWy5+hlRbC7HK+PmcXVUmW1IMyFce7to56IUvhUFm7Y=
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -718,8 +722,9 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -800,8 +805,9 @@ golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
Expand Down Expand Up @@ -879,8 +885,9 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY=
golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/new/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Cmd() *cobra.Command {
cmd.Flags().Bool("skip-yarn", false, "use npm instead of yarn for frontend dependencies management")
cmd.Flags().Bool("skip-docker", false, "skips generating the Dockerfile")
cmd.Flags().String("db-type", "postgres", fmt.Sprintf("specify the type of database you want to use [%s]", strings.Join(pop.AvailableDialects, ", ")))
cmd.Flags().String("ci-provider", "none", "specify the type of ci file you would like buffalo to generate [none, travis, gitlab-ci, circleci]")
cmd.Flags().String("ci-provider", "none", "specify the type of ci file you would like buffalo to generate [none, circleci, github, gitlab-ci, travis]")
cmd.Flags().String("vcs", "git", "specify the Version control system you would like to use [none, git, bzr]")
cmd.Flags().String("module", "", "specify the root module (package) name. [defaults to 'automatic']")

Expand Down
12 changes: 7 additions & 5 deletions internal/genny/ci/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
//go:embed templates/*
var templates embed.FS

// New generator for adding travis, gitlab, or circleci
// New generator for adding circleci, github, gitlab or travis
func New(opts *Options) (*genny.Generator, error) {
g := genny.New()

Expand All @@ -38,16 +38,18 @@ func New(opts *Options) (*genny.Generator, error) {

var fname string
switch opts.Provider {
case "travis", "travis-ci":
fname = "dot-travis.yml.tmpl"
case "circleci":
fname = "dot-circleci/config.yml.tmpl"
case "github":
fname = "dot-github/workflows/test.yml.tmpl"
case "gitlab", "gitlab-ci":
if opts.App.WithPop {
fname = "dot-gitlab-ci.yml.tmpl"
} else {
fname = "dot-gitlab-ci-no-pop.yml.tmpl"
}
case "circleci":
fname = "dot-circleci/config.yml.tmpl"
case "travis", "travis-ci":
fname = "dot-travis.yml.tmpl"
default:
return g, fmt.Errorf("could not find a template for %s", opts.Provider)
}
Expand Down
63 changes: 44 additions & 19 deletions internal/genny/ci/ci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"gopkg.in/yaml.v2"
)

func Test_New(t *testing.T) {
func Test_New_Circle(t *testing.T) {
r := require.New(t)

g, err := New(&Options{
Provider: "travis",
Provider: "circleci",
DBType: "postgres",
})
r.NoError(err)
Expand All @@ -27,18 +27,36 @@ func Test_New(t *testing.T) {
r.Len(res.Files, 1)

f := res.Files[0]
r.Equal(".travis.yml", f.Name())
travisYml := struct {
Language string
Go []string
Env []string
Services []string
BeforeScript []string `yaml:"before_script"`
GoImportPath string `yaml:"go_import_path"`
Install []string
Script string
r.Equal(".circleci/config.yml", f.Name())
circleYml := struct {
Version int
}{}
r.NoError(yaml.NewDecoder(f).Decode(&travisYml), ".travis.yml is a valid YAML file")
r.NoError(yaml.NewDecoder(f).Decode(&circleYml), "config.yml is a valid YAML file")
}

func Test_New_Github(t *testing.T) {
r := require.New(t)

g, err := New(&Options{
Provider: "github",
DBType: "postgres",
})
r.NoError(err)

run := gentest.NewRunner()
r.NoError(run.With(g))
r.NoError(run.Run())

res := run.Results()
r.Len(res.Commands, 0)
r.Len(res.Files, 1)

f := res.Files[0]
r.Equal(".github/workflows/test.yml", f.Name())
githubYml := struct {
Name string
}{}
r.NoError(yaml.NewDecoder(f).Decode(&githubYml), "test.yml is a valid YAML file")
}

func Test_New_Gitlab(t *testing.T) {
Expand Down Expand Up @@ -89,11 +107,11 @@ func Test_New_Gitlab_No_pop(t *testing.T) {
r.NotContains(f.String(), "postgres:5432")
}

func Test_New_Circle(t *testing.T) {
func Test_New_Travis(t *testing.T) {
r := require.New(t)

g, err := New(&Options{
Provider: "circleci",
Provider: "travis",
DBType: "postgres",
})
r.NoError(err)
Expand All @@ -107,9 +125,16 @@ func Test_New_Circle(t *testing.T) {
r.Len(res.Files, 1)

f := res.Files[0]
r.Equal(".circleci/config.yml", f.Name())
circleYml := struct {
Version int
r.Equal(".travis.yml", f.Name())
travisYml := struct {
Language string
Go []string
Env []string
Services []string
BeforeScript []string `yaml:"before_script"`
GoImportPath string `yaml:"go_import_path"`
Install []string
Script string
}{}
r.NoError(yaml.NewDecoder(f).Decode(&circleYml), "config.yml is a valid YAML file")
r.NoError(yaml.NewDecoder(f).Decode(&travisYml), ".travis.yml is a valid YAML file")
}
2 changes: 1 addition & 1 deletion internal/genny/ci/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// Available CI implementations
var Available = []string{"travis", "gitlab", "circleci"}
var Available = []string{"circleci", "github", "gitlab", "travis"}

// Options for CI
type Options struct {
Expand Down
43 changes: 43 additions & 0 deletions internal/genny/ci/templates/dot-github/workflows/test.yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: test

on:
push:
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
{{ if eq .opts.DBType "postgres" -}}
services:
postgres:
image: postgres:9.6-alpine
env:
POSTGRES_DB: {{.opts.App.Name.File}}_test
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
{{- end }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ~1.18
cache: true
- name: setup
run: |
go install github.com/gobuffalo/cli/cmd/buffalo@latest
- name: test
{{ if eq .opts.DBType "postgres" -}}
env:
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/{{.opts.App.Name.File}}_test?sslmode=disable
{{- end }}
run: |
buffalo test

0 comments on commit 4f1ca47

Please sign in to comment.