Skip to content

Commit

Permalink
Use shuttle to run shuttle tests
Browse files Browse the repository at this point in the history
Plus added support for 'no'-plan.
Also resolved a bug where local scripts couldn't run
  • Loading branch information
emilingerslev committed Oct 1, 2018
1 parent d8f9e0b commit 0c99778
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ language: go

script: |
echo "Build shuttle" &&
go build -v -a &&
echo "\n\nRun go tests:" &&
go test ./pkg/... -run Test* &&
echo "\n\nRun shell tests:" &&
./tests.sh
go build &&
./shuttle run test
# .travis.yml
language: go
Expand Down
10 changes: 9 additions & 1 deletion pkg/config/shuttleconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ type DynamicYaml = map[string]interface{}

// ShuttleConfig describes the actual config for each project
type ShuttleConfig struct {
Plan string `yaml:"plan"`
Plan string `yaml:"not_plan"`
PlanRaw interface{} `yaml:"plan"`
Variables DynamicYaml `yaml:"vars"`
Scripts map[string]ShuttlePlanScript `yaml:"scripts"`
}
Expand Down Expand Up @@ -72,5 +73,12 @@ func (c *ShuttleConfig) getConf(projectPath string) *ShuttleConfig {
panic(fmt.Sprintf("Unmarshal: %v", err))
}

switch c.PlanRaw {
case false:
// no plan
default:
c.Plan = c.PlanRaw.(string)
}

return c
}
6 changes: 6 additions & 0 deletions pkg/config/shuttleplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ type ShuttlePlan struct {

// Load loads a plan from project path and shuttle config
func (p *ShuttlePlanConfiguration) Load(planPath string) *ShuttlePlanConfiguration {
if planPath == "" {
return p
}
var configPath = path.Join(planPath, "plan.yaml")
//log.Printf("configpath: %s", configPath)
yamlFile, err := ioutil.ReadFile(configPath)
Expand All @@ -65,6 +68,9 @@ func (p *ShuttlePlanConfiguration) Load(planPath string) *ShuttlePlanConfigurati
// FetchPlan so it exists locally and return path to that plan
func FetchPlan(plan string, projectPath string, localShuttleDirectoryPath string, verbose bool) string {
switch {
case plan == "":
output.Verbose(verbose, "Using no plan")
return ""
case git.IsGitPlan(plan):
output.Verbose(verbose, "Using git plan at '%s'", plan)
return git.GetGitPlan(plan, localShuttleDirectoryPath, verbose)
Expand Down
2 changes: 1 addition & 1 deletion pkg/executors/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ActionExecutionContext struct {

// Execute is the command executor for the plan files
func Execute(p config.ShuttleProjectContext, command string, args []string) {
script, ok := p.Plan.Scripts[command]
script, ok := p.Scripts[command]
if !ok {
output.ExitWithErrorCode(2, fmt.Sprintf("No script found called '%s'", command))
}
Expand Down
18 changes: 18 additions & 0 deletions shuttle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plan: false
scripts:
build:
description: 'build code'
actions:
- shell: 'go build'
test-go:
description: 'run tests written in go'
actions:
- shell: go test ./pkg/... -run Test*
test-shell:
description: 'run tests written in shell'
actions:
- shell: ./tests.sh
test:
actions:
- shell: shuttle run test-go
- shell: shuttle run test-shell

0 comments on commit 0c99778

Please sign in to comment.