Commit ee7a0010 authored by Kamil Trzciński's avatar Kamil Trzciński 🔴

Fix caching support

- Fix broken tar unpack command
- Suppress tar verbose output
parent 9736cc55
v 0.7.1
- Fix caching support
- Suppress tar verbose output
v 0.7.0
- Refactor code structure
- Refactor bash script adding pre-build and post-build steps
......
......@@ -109,6 +109,7 @@ func (c *ArchiveCommand) processUntracked() {
cmd.Env = os.Environ()
cmd.Stdout = &output
cmd.Stderr = os.Stderr
logrus.Debugln("Executing command:", strings.Join(cmd.Args, " "))
err := cmd.Run()
if err == nil {
reader := bufio.NewReader(&output)
......@@ -133,7 +134,7 @@ func (c *ArchiveCommand) archive() {
return
}
logrus.Infoln("Creating archive", c.Output, "...")
logrus.Infoln("Creating archive", filepath.Base(c.Output), "...")
var files bytes.Buffer
for _, file := range c.sortedFiles() {
files.WriteString(string(file) + "\n")
......@@ -149,7 +150,7 @@ func (c *ArchiveCommand) archive() {
tempFile.Close()
defer os.Remove(tempFile.Name())
logrus.Debugln("Temporary file", tempFile.Name())
logrus.Debugln("Temporary file:", tempFile.Name())
flags := "-zcPv"
if c.Silent {
......@@ -161,14 +162,15 @@ func (c *ArchiveCommand) archive() {
cmd.Stdin = &files
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
logrus.Debugln("Executing command:", strings.Join(cmd.Args, " "))
err = cmd.Run()
if err != nil {
logrus.Fatalln("Failed to create archive", err)
logrus.Fatalln("Failed to create archive:", err)
}
err = os.Rename(tempFile.Name(), c.Output)
if err != nil {
logrus.Warningln("Failed to rename archive", err)
logrus.Warningln("Failed to rename archive:", err)
}
logrus.Infoln("Done!")
......@@ -184,7 +186,7 @@ func (c *ArchiveCommand) Execute(context *cli.Context) {
wd, err := os.Getwd()
if err != nil {
logrus.Fatalln("Failed to get current working directory", err)
logrus.Fatalln("Failed to get current working directory:", err)
}
if c.Output == "" {
logrus.Fatalln("Missing archive file name!")
......@@ -198,7 +200,7 @@ func (c *ArchiveCommand) Execute(context *cli.Context) {
ai, err := os.Stat(c.Output)
if err != nil && !os.IsNotExist(err) {
logrus.Fatalln("Failed to verify archive", c.Output, err)
logrus.Fatalln("Failed to verify archive:", c.Output, err)
}
if ai != nil {
if !c.isChanged(ai.ModTime()) {
......
......@@ -153,14 +153,14 @@ func (b *BashShell) generatePreBuildScript(info common.ShellScriptInfo) string {
// If we have cache, restore it
b.writeIfFile(w, cacheFile)
b.echoColored(w, "Restoring cache...")
b.executeCommand(w, "tar", "-zxfv", "-f", cacheFile)
b.executeCommand(w, "tar", "-zxf", cacheFile)
if cacheFile2 != "" {
b.writeElse(w)
// If we have cache, restore it
b.writeIfFile(w, cacheFile2)
b.echoColored(w, "Restoring cache...")
b.executeCommand(w, "tar", "-zxfv", "-f", cacheFile2)
b.executeCommand(w, "tar", "-zxf", cacheFile2)
b.writeEndIf(w)
}
b.writeEndIf(w)
......@@ -205,7 +205,8 @@ func (b *BashShell) archiveFiles(w io.Writer, list interface{}, archiveType, arc
args := []string{
"archive",
"-output",
"--silent",
"--output",
archivePath,
}
......@@ -213,14 +214,14 @@ func (b *BashShell) archiveFiles(w io.Writer, list interface{}, archiveType, arc
if paths, ok := hash["paths"].([]interface{}); ok {
for _, artifactPath := range paths {
if file, ok := artifactPath.(string); ok {
args = append(args, "-path", file)
args = append(args, "--path", file)
}
}
}
// Archive also untracked files
if untracked, ok := hash["untracked"].(bool); ok && untracked {
args = append(args, "-untracked")
args = append(args, "--untracked")
}
// Skip creating archive
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment