Ejemplo n.º 1
0
func Write(data []byte, pathFormat string, a ...interface{}) {
	p := path.Resolve(pathFormat, a...)
	dir.EnsureExists(path.BaseDir(p))
	err := ioutil.WriteFile(p, data, 0777)
	if err != nil {
		cli.Fatalf("unable to write file %s; %s", p, err)
	}
}
Ejemplo n.º 2
0
func (t *TestTarget) DockerRun(c *core.Context) *docker.Run {
	containerName := t.ContainerName(c)
	run := docker.NewRun(c.DockerTag())
	run.Name = containerName
	//run.AddEnv("ARTIFACT_NAME", t.artifactName(c))
	uid := cmd.Stdout("id", "-u")
	gid := cmd.Stdout("id", "-g")
	artifactOwner := fmt.Sprintf("%s:%s", uid, gid)
	run.AddEnv("ARTIFACT_OWNER", artifactOwner)
	artDir := t.artifactDir(c)
	dir.EnsureExists(artDir)
	run.AddVolume(artDir, "/artifacts")
	run.AddVolume(c.WorkDir, "/wd")
	run.Command = fmt.Sprintf("go generate && { [ -d Godeps ] && godep go test ./... || go test ./...; }")
	return run
}
Ejemplo n.º 3
0
// DockerRun returns a configured *docker.Run, which is used to create a new
// container when the old one is stale or does not exist.
func (t *CompileTarget) DockerRun(c *core.Context) *docker.Run {
	containerName := t.ContainerName(c)
	run := docker.NewRun(c.DockerTag())
	run.Name = containerName
	run.AddEnv("ARTIFACT_NAME", t.artifactName(c))
	uid := cmd.Stdout("id", "-u")
	gid := cmd.Stdout("id", "-g")
	artifactOwner := fmt.Sprintf("%s:%s", uid, gid)
	run.AddEnv("ARTIFACT_OWNER", artifactOwner)
	artDir := t.artifactDir(c)
	dir.EnsureExists(artDir)
	run.AddVolume(artDir, "/artifacts")
	run.AddVolume(c.WorkDir, "/wd")
	run.Command = "npm install"
	return run
}
Ejemplo n.º 4
0
func (t *CompileTarget) DockerRun(c *core.Context) *docker.Run {
	containerName := t.ContainerName(c)
	run := docker.NewRun(c.DockerTag())
	run.Name = containerName
	run.AddEnv("ARTIFACT_NAME", t.artifactName(c))
	uid := cmd.Stdout("id", "-u")
	gid := cmd.Stdout("id", "-g")
	artifactOwner := fmt.Sprintf("%s:%s", uid, gid)
	run.AddEnv("ARTIFACT_OWNER", artifactOwner)
	artDir := t.artifactDir(c)
	dir.EnsureExists(artDir)
	run.AddVolume(artDir, "/artifacts")
	run.AddVolume(c.WorkDir, "/wd")
	binName := fmt.Sprintf("%s-%s", c.CanonicalPackageName(), c.BuildVersion)
	run.Command = fmt.Sprintf("[ -d Godeps ] && godep go build -o %s || go build -o %s",
		binName, binName)
	return run
}
Ejemplo n.º 5
0
func getStateFile(action string, g *git.Info) string {
	dirPath := fmt.Sprintf("~/.sous/builds/%s/%s", g.CanonicalRepoName(), action)
	dir.EnsureExists(dirPath)
	return fmt.Sprintf("%s/state", dirPath)
}