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

Commit

Permalink
updates mods (#1880)
Browse files Browse the repository at this point in the history
* packing

* adding new docker tempaltes

* Removing some last things about GOPATH

* passing broken tests assuming GOPATH

* updates mods

* fix api test

Co-authored-by: Antonio Pagano <[email protected]>
  • Loading branch information
markbates and paganotoni authored Jan 19, 2020
1 parent e93e070 commit 6773bfc
Show file tree
Hide file tree
Showing 40 changed files with 109 additions and 924 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:


tests-off:
name: (GOPATH) ${{matrix.go-version}} ${{matrix.os}}
name: ${{matrix.go-version}} ${{matrix.os}}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -19,8 +19,6 @@ jobs:
fetch-depth: 1
path: src/github.com/${{ github.repository }}
- name: Test
env:
GOPATH: ${{runner.workspace}}
run: |
go mod tidy -v
go test -tags "sqlite integration_test" -cover -race ./...
Expand Down
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
FROM gobuffalo/buffalo:latest
ENV GOPROXY=https://proxy.golang.org

ARG CODECOV_TOKEN

ENV BP=$GOPATH/src/github.com/gobuffalo/buffalo
ENV GOPROXY https://proxy.golang.org
ENV GO111MODULE on
ENV BP /src/buffalo

RUN rm -rf $BP
RUN mkdir -p $BP
WORKDIR $BP

WORKDIR $BP
COPY . .
RUN bash ./it.sh

RUN go mod tidy
RUN go test -tags "sqlite integration_test" -cover -race -v ./...
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ build:

test:
$(GO_BIN) test -tags ${TAGS} -cover ./...
packr2
make tidy

ci-deps:
Expand Down
2 changes: 0 additions & 2 deletions buffalo/cmd/plugins/available.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ var PluginsCmd = &cobra.Command{
func init() {
PluginsCmd.AddCommand(addCmd)
PluginsCmd.AddCommand(listCmd)
PluginsCmd.AddCommand(generateCmd)
PluginsCmd.AddCommand(removeCmd)
PluginsCmd.AddCommand(installCmd)
PluginsCmd.AddCommand(cacheCmd)

Available.Add("generate", generateCmd)
Available.ListenFor("buffalo:setup:.+", Listen)
}
80 changes: 0 additions & 80 deletions buffalo/cmd/plugins/generate.go

This file was deleted.

5 changes: 0 additions & 5 deletions genny/build/bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"github.com/gobuffalo/genny"
"github.com/gobuffalo/genny/gogen/gomods"
)

func buildCmd(opts *Options) (*exec.Cmd, error) {
Expand All @@ -15,10 +14,6 @@ func buildCmd(opts *Options) (*exec.Cmd, error) {
}
buildArgs := []string{opts.GoCommand}

if !gomods.On() {
buildArgs = append(buildArgs, "-i")
}

if len(opts.Mod) != 0 {
buildArgs = append(buildArgs, "-mod", opts.Mod)
}
Expand Down
4 changes: 2 additions & 2 deletions genny/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func Test_New(t *testing.T) {
// we should never leave any files modified or dropped
r.Len(res.Files, 0)

cmds := []string{"go get -tags bar ./...", "go build -i -tags bar -o bin/foo"}
cmds := []string{"go get -tags bar ./...", "go build -tags bar -o bin/foo"}
r.Len(res.Commands, len(cmds))
for i, c := range res.Commands {
eq(r, cmds[i], c)
Expand Down Expand Up @@ -87,7 +87,7 @@ func Test_NewWithoutBuildDeps(t *testing.T) {

res := run.Results()

cmds := []string{"go build -i -tags bar -o bin/foo"}
cmds := []string{"go build -tags bar -o bin/foo"}
r.Len(res.Commands, len(cmds))
for i, c := range res.Commands {
eq(r, cmds[i], c)
Expand Down
7 changes: 3 additions & 4 deletions genny/docker/templates/multi/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# https://docs.docker.com/engine/userguide/eng-image/multistage-build/
FROM gobuffalo/buffalo:{{.opts.Version}} as builder

ENV GO111MODULE on
ENV GOPROXY http://proxy.golang.org

RUN mkdir -p $GOPATH/src/{{.opts.App.PackagePkg}}
WORKDIR $GOPATH/src/{{.opts.App.PackagePkg}}

Expand All @@ -17,10 +20,6 @@ RUN npm install --no-progress
{{end -}}

ADD . .
{{if .opts.App.WithModules -}}
ENV GO111MODULE=on
{{end -}}
RUN go get ./...
RUN buffalo build --static -o /bin/app

FROM alpine
Expand Down
4 changes: 3 additions & 1 deletion genny/docker/templates/standard/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM gobuffalo/buffalo:{{.opts.Version}}

ENV GO111MODULE on
ENV GOPROXY http://proxy.golang.org

RUN mkdir -p $GOPATH/src/{{.opts.App.PackagePkg}}
WORKDIR $GOPATH/src/{{.opts.App.PackagePkg}}

Expand All @@ -17,7 +20,6 @@ RUN npm install --no-progress
{{end -}}

ADD . .
RUN go get $(go list ./... | grep -v /vendor/)
RUN buffalo build --static -o /bin/app

# Uncomment to run the binary in "production" mode:
Expand Down
16 changes: 0 additions & 16 deletions genny/newapp/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/gobuffalo/buffalo/genny/newapp/core"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/genny/gogen"
"github.com/gobuffalo/genny/gogen/gomods"
"github.com/gobuffalo/packr/v2"
)

Expand Down Expand Up @@ -34,20 +33,5 @@ func New(opts *Options) (*genny.Group, error) {

gg.Add(g)

// DEP/MODS/go get should be last
if !opts.App.WithModules {
g := genny.New()
g.Command(gogen.Get("./...", "-t"))
gg.Add(g)
}

if opts.App.WithModules {
g, err := gomods.Tidy(opts.App.Root, false)
if err != nil {
return gg, err
}
gg.Add(g)
}

return gg, nil
}
6 changes: 3 additions & 3 deletions genny/newapp/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func init() {
func Test_New(t *testing.T) {
r := require.New(t)

app := meta.New(".")
app := meta.Named("api", ".")
(&app).PackageRoot("api")
app.WithModules = false
app.AsAPI = true
app.AsWeb = false
Expand All @@ -39,8 +40,7 @@ func Test_New(t *testing.T) {
res := run.Results()

cmds := []string{
"go get -t ./...",
"go get -t ./...",
"go mod init api",
}
r.Len(res.Commands, len(cmds))

Expand Down
28 changes: 0 additions & 28 deletions genny/newapp/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import (
"github.com/gobuffalo/buffalo/genny/refresh"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/buffalo/runtime"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/genny/gogen"
"github.com/gobuffalo/genny/gogen/gomods"
"github.com/gobuffalo/meta"
)

Expand All @@ -28,17 +25,6 @@ func New(opts *Options) (*genny.Group, error) {

app := opts.App

if app.WithModules {
g, err := gomods.Init(app.PackagePkg, app.Root)
if err != nil {
return gg, err
}
g.Command(gogen.Get("github.com/gobuffalo/buffalo@" + runtime.Version))
g.Command(gogen.Get("./..."))

gg.Add(g)
}

plugs, err := plugdeps.List(app)
if err != nil && (errx.Unwrap(err) != plugdeps.ErrMissingConfig) {
return nil, err
Expand Down Expand Up @@ -102,19 +88,5 @@ func New(opts *Options) (*genny.Group, error) {
}
gg.Merge(ig)

if !app.WithModules {
g := genny.New()
g.Command(gogen.Get("./...", "-t"))
gg.Add(g)
}

if app.WithModules {
g, err := gomods.Tidy(app.Root, false)
if err != nil {
return gg, err
}
gg.Add(g)
}

return gg, nil
}
57 changes: 0 additions & 57 deletions genny/newapp/core/core_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package core

import (
"path/filepath"
"testing"

"github.com/gobuffalo/buffalo/genny/docker"
"github.com/gobuffalo/buffalo/runtime"
"github.com/gobuffalo/envy"
"github.com/gobuffalo/genny/gentest"
"github.com/gobuffalo/logger"
"github.com/gobuffalo/meta"
"github.com/gobuffalo/packr/v2/plog"
"github.com/stretchr/testify/require"
)

Expand All @@ -20,56 +16,6 @@ func init() {
}

func Test_New(t *testing.T) {
r := require.New(t)
plog.Logger = logger.New(logger.DebugLevel)
app := meta.Named("coke", filepath.Join(envy.GoPath(), "src"))
app.WithModules = false

gg, err := New(&Options{
App: app,
})
r.NoError(err)

run := gentest.NewRunner()
run.WithGroup(gg)

r.NoError(run.Run())

res := run.Results()

cmds := []string{
"go get -t ./...",
}
r.NoError(gentest.CompareCommands(cmds, res.Commands))

expected := commonExpected
for _, e := range expected {
_, err = res.Find(e)
r.NoError(err)
}

f, err := res.Find("actions/render.go")
r.NoError(err)

body := f.String()
r.Contains(body, `r = render.New(render.Options{})`)
unexpected := []string{
"Dockerfile",
"database.yml",
"models/models.go",
"go.mod",
".buffalo.dev.yml",
"assets/css/application.scss.css",
"public/assets/application.js",
}

for _, u := range unexpected {
_, err = res.Find(u)
r.Error(err)
}
}

func Test_New_Mods(t *testing.T) {
r := require.New(t)
envy.Temp(func() {
envy.Set(envy.GO111MODULE, "on")
Expand All @@ -92,9 +38,6 @@ func Test_New_Mods(t *testing.T) {

cmds := []string{
"go mod init coke",
"go get github.com/gobuffalo/buffalo@" + runtime.Version,
"go get ./...",
"go mod tidy",
}
r.NoError(gentest.CompareCommands(cmds, res.Commands))

Expand Down
Loading

0 comments on commit 6773bfc

Please sign in to comment.