Skip to content

Commit

Permalink
Merge pull request #35 from screwdriver-cd/commands
Browse files Browse the repository at this point in the history
Switching to the new steps/commands layout
  • Loading branch information
jer authored Aug 9, 2016
2 parents 884e14f + 5716b45 commit 391b125
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import (
)

// Run will be used to execute steps
func Run(jobDef []screwdriver.JobDef) error {
func Run(jobDefs []screwdriver.JobDef) error {
return nil
}
2 changes: 1 addition & 1 deletion launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func prNumber(jobName string) string {
if matched == nil || len(matched) != 2 {
return ""
}

log.Println("Build is a PR: ", matched[1])
return matched[1]
}

Expand Down
8 changes: 6 additions & 2 deletions launch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,14 @@ func TestPipelineDefFromYaml(t *testing.T) {
testBuildID := "BUILDID"
testJobID := "JOBID"
testRoot := "/sd/workspace"

mainJob := screwdriver.JobDef{
Image: "node:4",
Steps: map[string]string{
"install": "npm install",
Commands: []screwdriver.CommandDef{
screwdriver.CommandDef{
Name: "install",
Cmd: "npm install",
},
},
Environment: map[string]string{
"NUMBER": "3",
Expand Down
18 changes: 12 additions & 6 deletions screwdriver/screwdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func New(url, token string) (API, error) {
return API(api), nil
}

// BuildStatus is a Screwdriver Build Status payload
// BuildStatus is a Screwdriver Build Status payload.
type BuildStatus struct {
Status string `json:"status"`
}
Expand All @@ -56,32 +56,38 @@ type Validator struct {
Yaml string `json:"yaml"`
}

// Pipeline is a Screwdriver Pipeline definition
// Pipeline is a Screwdriver Pipeline definition.
type Pipeline struct {
ID string `json:"id"`
ScmURL string `json:"scmUrl"`
}

// PipelineDef contains the step definitions and jobs for a Pipeline
// PipelineDef contains the step definitions and jobs for a Pipeline.
type PipelineDef struct {
Jobs map[string][]JobDef `json:"jobs"`
Workflow []string `json:"workflow"`
}

// JobDef contains the step and environment definitions of a single Job
// JobDef contains the step and environment definitions of a single Job.
type JobDef struct {
Image string `json:"image"`
Steps map[string]string `json:"steps"`
Commands []CommandDef `json:"commands"`
Environment map[string]string `json:"environment"`
}

// Job is a Screwdriver Job
// Job is a Screwdriver Job.
type Job struct {
ID string `json:"id"`
PipelineID string `json:"pipelineId"`
Name string `json:"name"`
}

// CommandDef is the definition of a single executable command.
type CommandDef struct {
Name string `json:"name"`
Cmd string `json:"command"`
}

// Build is a Screwdriver Build
type Build struct {
ID string `json:"id"`
Expand Down
50 changes: 28 additions & 22 deletions screwdriver/screwdriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,31 +182,37 @@ func TestPipeline404(t *testing.T) {

func TestPipelineFromYaml(t *testing.T) {
json := `{
"jobs": {
"main": [
{
"image": "node:4",
"steps": {
"install": "npm install"
},
"environment": {
"ARRAY": "[\"a\",\"b\"]",
"BOOL": "true",
"OBJECT": "{\"a\":\"cat\",\"b\":\"dog\"}",
"NUMBER": "3",
"DECIMAL": "3.1415927",
"STRING": "test"
}
}
]
},
"workflow": []
}`
"jobs": {
"main": [
{
"image": "node:4",
"commands": [
{
"name": "install",
"command": "npm install"
}
],
"environment": {
"ARRAY": "[\"a\",\"b\"]",
"BOOL": "true",
"OBJECT": "{\"a\":\"cat\",\"b\":\"dog\"}",
"NUMBER": "3",
"DECIMAL": "3.1415927",
"STRING": "test"
}
}
]
},
"workflow": []
}`

mainJob := JobDef{
Image: "node:4",
Steps: map[string]string{
"install": "npm install",
Commands: []CommandDef{
CommandDef{
Name: "install",
Cmd: "npm install",
},
},
Environment: map[string]string{
"ARRAY": `["a","b"]`,
Expand Down

0 comments on commit 391b125

Please sign in to comment.