Skip to content

Commit

Permalink
Fix pwd path diffing (#65)
Browse files Browse the repository at this point in the history
* fix pwd diffing

* Fix statecom nil pointer

tests were crashing due to a nil pointer from a bad key in the service
state com map

* Fix conf

the test conf no longer followed the build process
  • Loading branch information
cpg1111 authored Sep 21, 2016
1 parent 6ebe0ac commit 750fc8f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ docker:
docker build -t maestro_bin_deps -f Dockerfile_bin .
docker build -t maestro -f Dockerfile_fully_loaded .
e2e-test:
docker run --rm -t \
docker run --rm -it \
-v ${HOME}/.ssh/:/root/.ssh/ \
-v `pwd`:/etc/maestro/ \
-v ${DOCKER_CERT_PATH}:${DOCKER_CERT_PATH} \
Expand Down
21 changes: 11 additions & 10 deletions pipeline/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,40 @@ import (
)

func build(srv *DepService, index string, stateCom *statecom.StateCom, done chan string, errChan chan error, shouldDeploy *bool) {
stateCom.Services[index].SetState("building", true)
buildName := srv.build.conf.Name
stateCom.Services[buildName].SetState("building", true)
err := srv.build.execBuild()
if err != nil {
stateCom.Services[index].SetState("built", false)
stateCom.Services[buildName].SetState("built", false)
errChan <- err
return
}
stateCom.Services[index].SetState("built", true)
stateCom.Services[buildName].SetState("built", true)
log.Println("Run tests")
stateCom.Services[index].SetState("testing", true)
stateCom.Services[buildName].SetState("testing", true)
err = RunTests(srv.build)
if err != nil {
stateCom.Services[index].SetState("tested", false)
stateCom.Services[buildName].SetState("tested", false)
errChan <- err
return
}
log.Println("Tests done")
stateCom.Services[index].SetState("tested", true)
stateCom.Services[buildName].SetState("tested", true)
if !*shouldDeploy {
stateCom.Services[index].SetState("finished", true)
stateCom.Services[buildName].SetState("finished", true)
log.Println("No Deploy")
done <- index
return
}
log.Println("Checking deployment...")
stateCom.Services[index].SetState("deploying", true)
stateCom.Services[buildName].SetState("deploying", true)
err = check(srv.build)
if err != nil {
stateCom.Services[index].SetState("finished", false)
stateCom.Services[buildName].SetState("finished", false)
errChan <- err
return
}
stateCom.Services[index].SetState("finished", true)
stateCom.Services[buildName].SetState("finished", true)
srv.build.shouldBuild = false
done <- index
return
Expand Down
10 changes: 5 additions & 5 deletions test_conf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ Tag="0.0.1"
TagType=""
Path="."
BuildLogFilePath="./test.log"
BuildCMD=["docker build -f Dockerfile_build -t maestro_build .", "docker run -v $(pwd)/dist:/opt/bin/ && docker build -t cpg1111/maestro ."]
TestCMD=["go test -v ./..."]
BuildCMD=["make"]
TestCMD=["make test"]
CheckCMD=["docker ps -a"]
CreateCMD=["docker push cpg1111/maestro"]
UpdateCMD=["docker rm -f test && docker run -n test -d test"]
CreateCMD=["make docker"]
UpdateCMD=["make docker"]
DependsOn=[]
[HealthCheck]
Type="PTRACE_ATTACH"
ExpectedCondition="nil"
Retrys=3

[CleanUp]
AdditionalCMDs=["docker inspect cpg1111/maestro"]
AdditionalCMDs=["docker inspect maestro"]
InDaemon=false
[[CleanUp.Artifacts]]
RuntimeFilePath="./dist/maestro"
Expand Down
1 change: 1 addition & 0 deletions util/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
git "gopkg.in/libgit2/git2go.v24"
)

// CommitToTree takes a commit hash and fetches its git tree
func CommitToTree(repo *git.Repository, hash string) (*git.Tree, error) {
commitObj, commitErr := repo.RevparseSingle(hash)
if commitErr != nil {
Expand Down
7 changes: 6 additions & 1 deletion util/formatPath.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ func FmtDiffPath(clonePath, srvPath string) (newStr string) {
if strings.Index(srvPath, clonePath) == -1 && strings.Index(srvPath, clonePath[1:]) > -1 {
clonePath = clonePath[1:]
}
if clonePath[len(clonePath)-1] != '/' {
if clonePath[len(clonePath)-1] != '/' && srvPath[len(srvPath)-1] == '/' {
clonePath = fmt.Sprintf("%s/", clonePath)
}
newStr = strings.Replace(srvPath, clonePath, "", 1)
fmt.Println(newStr, clonePath, len(newStr))
if len(newStr) <= 1 {
newStr = "*"
return
}
if newStr[len(newStr)-1] != '/' {
newStr = fmt.Sprintf("%s/", newStr)
}
Expand Down

0 comments on commit 750fc8f

Please sign in to comment.