Skip to content

Commit

Permalink
Add collapse test for nesting orbs and local commands, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Jun 22, 2018
1 parent 998a258 commit fa63a02
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 1 deletion.
21 changes: 20 additions & 1 deletion cmd/collapse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,26 @@ var _ = Describe("collapse with testdata", func() {
BeforeEach(func() {
var err error
command = exec.Command(pathCLI, "collapse", "-r", "testdata/hugo-collapse/.circleci")
results, err = ioutil.ReadFile("testdata/hugo-collapse/out.yml")
results, err = ioutil.ReadFile("testdata/hugo-collapse/result.yml")
Expect(err).ShouldNot(HaveOccurred())
})

It("collapse all YAML contents as expected", func() {
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
session.Wait()
Expect(err).ShouldNot(HaveOccurred())
Eventually(session.Err.Contents()).Should(BeEmpty())
Eventually(session.Out.Contents()).Should(MatchYAML(results))
Eventually(session).Should(gexec.Exit(0))
})
})

Describe("local orbs folder with mixed inline and local commands, jobs, etc", func() {
BeforeEach(func() {
var err error
var path string = "nested-orbs-and-local-commands-etc"
command = exec.Command(pathCLI, "collapse", "-r", filepath.Join("testdata", path, "test"))
results, err = ioutil.ReadFile(filepath.Join("testdata", path, "result.yml"))
Expect(err).ShouldNot(HaveOccurred())
})

Expand Down
File renamed without changes.
112 changes: 112 additions & 0 deletions cmd/testdata/nested-orbs-and-local-commands-etc/result.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
commands:
foo:
parameters:
mybool:
default: true
type: boolean
steps:
- run: echo in foo
- when:
condition: << parameters.mybool >>
steps:
- run: echo bool is true
- unless:
condition: << parameters.mybool >>
steps:
- run: echo bool is false
say:
description: A simple command that echoes whatever is passed
parameters:
saywhat:
description: What shall we say?
type: string
steps:
- run: echo << parameters.saywhat >>
executors:
parallel:
parallelism: 4
jobs:
bar:
machine:
docker_layer_caching: << parameters.mybool >>
enabled: << parameters.mybool >>
parameters:
mybool:
default: false
type: boolean
myotherbool:
default: false
type: boolean
mysteps:
default: []
type: steps
steps:
- checkout
- when:
condition: << parameters.mybool >>
steps:
- << parameters.mysteps >>
- when:
condition: << parameters.mybool >>
steps:
- foo:
mybool: << parameters.myotherbool >>
build-false:
machine: true
steps:
- foo:
mybool: false
build-true:
machine: true
steps:
- foo
sayhello:
description: A job that does very little other than demonstrate what a parameterized
job looks like
machine: true
parameters:
saywhat:
default: World
description: To whom shall we say hello?
type: string
steps:
- say:
saywhat: Hello << parameters.saywhat >>
orbs:
foo:
commands:
zomg:
description: a command inside a folder in an orb
parameters:
tm:
description: Tell me something.
type: string
steps:
- run: echo "You don't say... << parameters.saywhat >>"
description: A simple encapsulation of common tasks in Hugo
executors:
default:
docker:
- image: cibuilds/hugo:<< parameters.image >>
parameters:
tag:
description: The tag to use on the image
type: string
version: 2
workflows:
version: 2
workflow:
jobs:
- build-true
- build-false
- bar:
mybool: true
myotherbool: false
- bar:
mybool: false
myotherbool: true
- bar:
mybool: true
mysteps:
- run: echo i am a steps param, hear me shout

71 changes: 71 additions & 0 deletions cmd/testdata/nested-orbs-and-local-commands-etc/test/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
version: 2

commands:
foo:
parameters:
mybool:
type: boolean
default: true
steps:
- run: "echo in foo"
- when:
condition: << parameters.mybool >>
steps:
- run: echo bool is true
- unless:
condition: << parameters.mybool >>
steps:
- run: echo bool is false

jobs:
build-true:
machine: true
steps:
- foo
build-false:
machine: true
steps:
- foo:
mybool: false
bar:
parameters:
mybool:
type: boolean
default: false
myotherbool:
type: boolean
default: false
mysteps:
type: steps
default: []
machine:
docker_layer_caching: << parameters.mybool >>
enabled: << parameters.mybool >>
steps:
- checkout
- when:
condition: << parameters.mybool >>
steps:
- << parameters.mysteps >>
- when:
condition: << parameters.mybool >>
steps:
- foo:
mybool: << parameters.myotherbool >>

workflows:
version: 2
workflow:
jobs:
- build-true
- build-false
- bar:
mybool: true
myotherbool: false
- bar:
mybool: false
myotherbool: true
- bar:
mybool: true
mysteps:
- run: echo i am a steps param, hear me shout
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
description: "A simple command that echoes whatever is passed"
parameters:
saywhat:
description: "What shall we say?"
type: string
steps:
# note: the interpolation syntax is subject to change
- run: echo << parameters.saywhat >>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
parallelism: 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
description: A job that does very little other than demonstrate what a parameterized job looks like
parameters:
saywhat:
description: "To whom shall we say hello?"
type: string
default: "World"
machine: true
steps:
- say:
saywhat: Hello << parameters.saywhat >>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: "a command inside a folder in an orb"
parameters:
tm:
description: "Tell me something."
type: string
steps:
- run: echo "You don't say... << parameters.saywhat >>"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
description: "A simple encapsulation of common tasks in Hugo"

executors:
default:
parameters:
tag:
description: "The tag to use on the image"
type: string
docker:
- image: cibuilds/hugo:<< parameters.image >>

0 comments on commit fa63a02

Please sign in to comment.