Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding parallel runners #50

Merged
merged 6 commits into from
Feb 1, 2016
Merged

Adding parallel runners #50

merged 6 commits into from
Feb 1, 2016

Conversation

zabawaba99
Copy link
Collaborator

Closes #48

The snag.yml now accepts a 'Runners' tag. This tag represents a group
of commands that are meant to be run in parallel after the build stage.

Each process will be given a chance to start and will then get backgrounded
to allow other processes to run. The output of each command is streamed to
stdout prefix with the pid of the logging command

*out

.DS_Store
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this to your global .gitignore instead of here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended the commit

@Tonkpils
Copy link
Owner

We'll need to update the documentation but if you'd like I'll do that after we merge this

@zabawaba99
Copy link
Collaborator Author

I also wanted to add some tests to it. What do you think about the overall implementation?

@Tonkpils
Copy link
Owner

I also wanted to add some tests to it. What do you think about the overall implementation?

Looks good, nothing that jumps out at me. I'm going to clone it and test out it a bit.

@@ -26,6 +26,7 @@ type config struct {
DepWarnning string
Script []string `yaml:"script"`
Build []string `yaml:"build"`
Runners []string `yaml:"runners"`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit swayed from seeing build vs runners. Maybe we can come up with a better name instead of runners? Though for now this will suffice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too found of the name either. Not too sure what to call it. This is an after/ run hook.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just rather make a change now than have to deprecate it in the near future.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I think simply run describes what will happen to them. If we happen to add functionality down the line that allows these things to be ran sequentially we would have the option of adding async blocks etc...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think run fits nicely. I'll change it.

Closes issue #48

The snag.yml now accepts a 'Runners' tag. This tag represents a group
of commands that are meant to be run in parallel after the build stage.

Each process will be given a chance to start and will then get backgrounded
to allow other processes to run. The output of each command is streamed to
stdout prefix with the pid of the logging command
@zabawaba99
Copy link
Collaborator Author

Did some manual testing and it looks good on my end. Going to start unit testing between tonight and tomorrow morning and push a new commit.

screen shot 2016-01-25 at 9 16 23 pm

@zabawaba99
Copy link
Collaborator Author

Latests changes:

.snag.yml

verbose: true

ignore:
  - .git
  - snag
  - snag.exe

build:
  - go build
  - go vet
  - gofmt -l -s .
  - go test . ./vow -test.short

run:
  - go run test/binary1/main.go
  - go run test/binary2/main.go
  - go run test/binary3/main.go

test/binary1/main.go

package main

import (
    "fmt"
    "time"
)

func main() {
    for i := 0; i < 10; i++ {
        fmt.Printf("Sleep count %d\n", i)
        time.Sleep(time.Second)
    }
}

test/binary2/main.go

package main

import (
    "fmt"
    "os"
    "time"
)

func main() {
    for i := 8; i > 0; i-- {
        fmt.Printf("Failing in %d\n", i)
        time.Sleep(time.Second)
    }

    os.Exit(1)
}

test/binary3/main.go

package main

import (
    "fmt"
    "time"
)

func main() {
    var count int
    for range time.Tick(5 * time.Second) {
        count++
        fmt.Printf("Ticked count %d\n", count)
    }
}

Result:
ezgif com-video-to-gif

@zabawaba99 zabawaba99 changed the title [WIP] Adding parallel runners Adding parallel runners Jan 29, 2016
@Tonkpils
Copy link
Owner

Tonkpils commented Feb 1, 2016

Looks good, I'm going to merge this and we can iterate over it on master

Tonkpils added a commit that referenced this pull request Feb 1, 2016
@Tonkpils Tonkpils merged commit 99ea582 into master Feb 1, 2016
@Tonkpils Tonkpils deleted the parallel branch February 1, 2016 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support parallel execution of tasks
2 participants