Ejemplo n.º 1
0
// Project is local project.
func tasks(p *do.Project) {
	p.Task("default", do.S{"readme"}, nil)

	p.Task("install", nil, func(c *do.Context) {
		c.Run("go get github.com/robertkrimen/godocdown/godocdown")
	})

	p.Task("lint", nil, func(c *do.Context) {
		c.Run("golint .")
		c.Run("gofmt -w -s .")
		c.Run("go vet .")
		c.Run("go test")
	})

	p.Task("readme", nil, func(c *do.Context) {
		c.Run("godocdown -output README.md")

		packageName, _ := util.PackageName("doc.go")

		// add godoc link
		goa.Pipe(
			f.Load("./README.md"),
			f.Str(str.ReplaceF("--", "\n[godoc](https://godoc.org/"+packageName+")\n", 1)),
			f.Write(),
		)
	}).Src("**/*.go")

	p.Task("test", nil, func(c *do.Context) {
		c.Run("go test")
	})
}
Ejemplo n.º 2
0
func tasks(p *do.Project) {
	if pwd, err := os.Getwd(); err == nil {
		do.Env = fmt.Sprintf("GOPATH=%s/vendor::$GOPATH", pwd)
	}

	p.Task("server", nil, func(c *do.Context) {
		c.Start("main.go ./config/page.yaml", do.M{"$in": "./"})
	}).Src("**/*.go")
}
Ejemplo n.º 3
0
func tasks(p *do.Project) {
	do.Env = `/go/src/app/vendor::$GOPATH`

	p.Task("server", nil, func(c *do.Context) {
		// rebuilds and restarts when a watched file changes
		c.Start("main.go", do.M{"$in": "/go/src/app"})
	}).Src("*.go", "**/*.go").
		Debounce(3000)

}
Ejemplo n.º 4
0
func generateTasks(p *do.Project) {
	p.Task("builder-boilerplate", nil, func(c *do.Context) {
		context := do.M{
			"builders": []string{"CallBuilder", "DeleteBuilder", "InsectBuilder",
				"InsertBuilder", "RawBuilder", "SelectBuilder", "SelectDocBuilder",
				"UpdateBuilder", "UpsertBuilder"},
		}

		s, err := util.StrTemplate(builderTemplate, context)
		c.Check(err, "Unalbe ")

		ioutil.WriteFile("builders_generated.go", []byte(s), 0644)
		c.Run("go fmt builders_generated.go")
	}).Desc("Generates builder boilerplate code")
}
Ejemplo n.º 5
0
func tasks(p *do.Project) {
	p.Task("test", nil, func(c *do.Context) {
		c.Run("go test")
	})

	p.Task("test", do.S{"build"}, func(c *do.Context) {
		c.Run("go test")
	})

	p.Task("dist", do.S{"test", "lint"}, nil)

	p.Task("install", nil, func(c *do.Context) {
		c.Run("go get github.com/golang/lint/golint")
		// Run("go get github.com/mgutz/goa")
		c.Run("go get github.com/robertkrimen/godocdown/godocdown")
	})

	p.Task("lint", nil, func(c *do.Context) {
		c.Run("golint .")
		c.Run("gofmt -w -s .")
		c.Run("go vet .")
	})

	// p.Task("readme", func() {
	// 	Run("godocdown -o README.md")
	// 	// add godoc
	// 	goa.Pipe(
	// 		f.Load("./README.md"),
	// 		f.Str(str.ReplaceF("--", "\n[godoc](https://godoc.org/gopkg.in/godo.v2)\n", 1)),
	// 		f.Write(),
	// 	)
	// })

	p.Task("build", nil, func(c *do.Context) {
		c.Run("go install", do.M{"$in": "cmd/godo"})
	})

	p.Task("interactive", nil, func(c *do.Context) {
		c.Bash(`
			echo name?
			read name
			echo hello $name
		`)
	})

	p.Task("whoami", nil, func(c *do.Context) {
		c.Run("whoami")
	})

	pass := 0
	p.Task("err2", nil, func(*do.Context) {
		if pass == 2 {
			do.Halt("oh oh")
		}
	})

	p.Task("err", do.S{"err2"}, func(*do.Context) {
		pass++
		if pass == 1 {
			return
		}
		do.Halt("foo err")
	}).Src("test/*.txt")

	p.Task("hello", nil, func(c *do.Context) {
		name := c.Args.AsString("default value", "name", "n")
		fmt.Println("Hello", name)
	}).Src("*.hello").Debounce(3000)

	p.Task("server", nil, func(c *do.Context) {
		c.Start("main.go", do.M{"$in": "cmd/example"})
	}).Src("cmd/example/**/*.go")

	p.Task("change-package", nil, func(c *do.Context) {
		// works on mac
		c.Run(`find . -name "*.go" -print | xargs sed -i "" 's|gopkg.in/godo.v1|gopkg.in/godo.v2|g'`)
		// maybe linux?
		//Run(`find . -name "*.go" -print | xargs sed -i 's|gopkg.in/godo.v1|gopkg.in/godo.v2|g'`)
	})
}
Ejemplo n.º 6
0
Archivo: main.go Proyecto: alxmsl/logxi
func tasks(p *do.Project) {
	p.Task("bench", nil, func(c *do.Context) {
		c.Run("LOGXI=* go test -bench . -benchmem", do.M{"$in": "v1/bench"})
	})

	p.Task("build", nil, func(c *do.Context) {
		c.Run("go build", do.M{"$in": "v1/cmd/demo"})
	})

	p.Task("linux-build", nil, func(c *do.Context) {
		c.Bash(`
			set -e
			GOOS=linux GOARCH=amd64 go build
			scp -F ~/projects/provision/matcherino/ssh.vagrant.config demo devmaster1:~/.
		`, do.M{"$in": "v1/cmd/demo"})
	})

	p.Task("etcd-set", nil, func(c *do.Context) {
		kv := c.Args.NonFlags()
		if len(kv) != 2 {
			do.Halt(fmt.Errorf("godo etcd-set -- KEY VALUE"))
		}

		c.Run(
			`curl -L http://127.0.0.1:4001/v2/keys/{{.key}} -XPUT -d value="{{.value}}"`,
			do.M{"key": kv[0], "value": kv[1]},
		)
	})

	p.Task("etcd-del", nil, func(c *do.Context) {
		kv := c.Args.Leftover()
		if len(kv) != 1 {
			do.Halt(fmt.Errorf("godo etcd-del -- KEY"))
		}
		c.Run(
			`curl -L http://127.0.0.1:4001/v2/keys/{{.key}} -XDELETE`,
			do.M{"key": kv[0]},
		)
	})

	p.Task("demo", nil, func(c *do.Context) {
		c.Run("go run main.go", do.M{"$in": "v1/cmd/demo"})
	})

	p.Task("demo2", nil, func(c *do.Context) {
		c.Run("go run main.go", do.M{"$in": "v1/cmd/demo2"})
	})

	p.Task("filter", do.S{"build"}, func(c *do.Context) {
		c.Run("go build", do.M{"$in": "v1/cmd/filter"})
		c.Bash("LOGXI=* ../demo/demo | ./filter", do.M{"$in": "v1/cmd/filter"})
	})

	p.Task("gifcast", do.S{"build"}, func(*do.Context) {
		commands := []pair{
			{
				`create a simple app demo`,
				`cat main.ansi`,
			},
			{
				`running demo displays only warnings and errors with context`,
				`demo`,
			},
			{
				`show all log levels`,
				`LOGXI=* demo`,
			},
			{
				`enable/disable loggers with level`,
				`LOGXI=*=ERR,models demo`,
			},
			{
				`create custom 256 colors colorscheme, pink==200`,
				`LOGXI_COLORS=*=black+h,ERR=200+b,key=blue+h demo`,
			},
			{
				`put keys on newline, set time format, less context`,
				`LOGXI=* LOGXI_FORMAT=pretty,maxcol=80,t=04:05.000,context=0 demo`,
			},
			{
				`logxi defaults to fast, unadorned JSON in production`,
				`demo | cat`,
			},
		}

		// setup time for ecorder, user presses enter when ready
		clear()
		do.Prompt("")

		intro(
			"log XI",
			"structured. faster. friendlier.\n\n\n\n\t::mgutz",
			1*time.Second,
		)

		for _, cmd := range commands {
			typeCommand(cmd.description, cmd.command)
			do.Bash(cmd.command, do.M{"$in": "v1/cmd/demo"})
			time.Sleep(3500 * time.Millisecond)
		}

		clear()
		do.Prompt("")
	})

	p.Task("demo-gif", nil, func(c *do.Context) {
		c.Bash(`cp ~/Desktop/demo.gif images`)
	})

	p.Task("bench-allocs", nil, func(c *do.Context) {
		c.Bash(`go test -bench . -benchmem -run=none | grep "allocs\|^Bench"`, do.M{"$in": "v1/bench"})
	}).Description("Runs benchmarks with allocs")

	p.Task("benchjson", nil, func(c *do.Context) {
		c.Bash("go test -bench=BenchmarkLoggerJSON -benchmem", do.M{"$in": "v1/bench"})
	})

	p.Task("test", nil, func(c *do.Context) {
		c.Run("LOGXI=* go test", do.M{"$in": "v1"})
		//Run("LOGXI=* go test -run=TestColors", M{"$in": "v1"})
	})

	p.Task("isolate", do.S{"build"}, func(c *do.Context) {
		c.Bash("LOGXI=* LOGXI_FORMAT=fit,maxcol=80,t=04:05.000,context=2 demo", do.M{"$in": "v1/cmd/demo"})
	})

	p.Task("install", nil, func(c *do.Context) {
		packages := []string{
			"github.com/mattn/go-colorable",
			"github.com/mattn/go-isatty",
			"github.com/mgutz/ansi",
			"github.com/stretchr/testify/assert",

			// needed for benchmarks in bench/
			"github.com/Sirupsen/logrus",
			"gopkg.in/inconshreveable/log15.v2",
		}
		for _, pkg := range packages {
			c.Run("go get -u " + pkg)
		}
	}).Description("Installs dependencies")

}
Ejemplo n.º 7
0
func tasks(p *do.Project) {
	do.Env = `
	DAT_DRIVER=postgres
	DAT_DSN="dbname=dbr_test user=dbr password=!test host=localhost sslmode=disable"
	`
	generateTasks(p)
	p.Use("pg", pgTasks)

	p.Task("createdb", nil, createdb).Description("Creates test database")

	p.Task("test", nil, func(c *do.Context) {
		c.Run(`go test -race`)
		c.Run(`go test -race`, do.M{"$in": "sqlx-runner"})
	}).Src("**/*.go").
		Desc("test with -race flag")

	p.Task("test-fast", nil, func(c *do.Context) {
		c.Run(`go test`)
		c.Run(`go test`, do.M{"$in": "sqlx-runner"})
	}).Src("**/*.go").
		Desc("fater test without -race flag")

	p.Task("test-dir", nil, func(c *do.Context) {
		dir := c.Args.NonFlags()[0]
		c.Run(`go test`, do.M{"$in": dir})
	})

	p.Task("test-one", nil, func(c *do.Context) {
		c.Run(`LOGXI=* go test -run TestSelectDocDate`, do.M{"$in": "sqlx-runner"})
	}).Src("*.go")

	p.Task("allocs", nil, func(c *do.Context) {
		c.Bash(`
		go test -c
		GODEBUG=allocfreetrace=1 ./dat.test -test.bench=BenchmarkSelectBasicSql -test.run=none -test.benchtime=10ms 2>trace.log
		`)
	})

	p.Task("hello", nil, func(*do.Context) {
		fmt.Println("hello?")
	})

	p.Task("bench", nil, func(c *do.Context) {
		// Bash("go test -bench . -benchmem 2>/dev/null | column -t")
		// Bash("go test -bench . -benchmem 2>/dev/null | column -t", In{"sqlx-runner"})
		c.Bash("go test -bench . -benchmem")
		c.Bash("go test -bench . -benchmem", do.M{"$in": "sqlx-runner"})
	})
	p.Task("bench2", nil, func(c *do.Context) {
		c.Bash("go test -bench . -benchmem", do.M{"$in": "sqlx-runner"})
	})

	p.Task("bench-builder", nil, func(c *do.Context) {
		c.Bash(`
		go test -c
		#GODEBUG=allocfreetrace=1 ./sqlx-runner.test -test.bench=BenchmarkInsertTransactionDat100 -test.run=none -test.benchtime=1s -test.benchmem 2>trace.log
		GODEBUG=allocfreetrace=1 ./sqlx-runner.test -test.run=none -test.bench . -test.benchmem 2>trace.log
		`, do.M{"$in": "sqlx-runner"})
	})

	p.Task("install", nil, func(c *do.Context) {
		c.Run("go install -a", do.M{"$in": "sqlx-runner"})
	})

	p.Task("default", do.S{"builder-boilerplate"}, nil)

	p.Task("example", nil, func(c *do.Context) {
	})

	p.Task("lint", nil, func(c *do.Context) {
		c.Bash(`
		echo Directory=.
		golint

		cd sqlx-runner
		echo
		echo Directory=sqlx-runner
		golint

		cd ../kvs
		echo
		echo Directory=kvs
		golint

		cd ../postgres
		echo
		echo Directory=postgres
		golint
		`)
	})

	p.Task("mocks", nil, func(c *do.Context) {
		// go get github.com/vektra/mockery
		c.Run("mockery --dir=kvs --all")
	})
}