Skip to content

Commit

Permalink
Add setup key to packed orb examples
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Harvey <[email protected]>
  • Loading branch information
adamdmharvey committed Oct 7, 2022
1 parent 37e2fc3 commit fdb0614
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ type OrbSchema struct {

type ExampleUsageSchema struct {
Version string `yaml:"version,omitempty"`
Setup bool `yaml:"setup,omitempty"`
Orbs interface{} `yaml:"orbs,omitempty"`
Jobs interface{} `yaml:"jobs,omitempty"`
Workflows interface{} `yaml:"workflows"`
Expand Down
31 changes: 27 additions & 4 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3311,6 +3311,20 @@ Windows Server 2010
- run:
name: Say hello
command: <<include(scripts/script.sh)>>
examples:
example:
description: |
An example of how to use the orb.
usage:
version: 2.1
orbs:
orb-name: company/[email protected]
setup: true
workflows:
create-pipeline:
jobs:
orb-name: create-pipeline-x
`))
script = clitest.OpenTmpFile(tempSettings.Home, filepath.Join("scripts", "script.sh"))
script.Write([]byte(`echo Hello, world!`))
Expand All @@ -3330,16 +3344,25 @@ Windows Server 2010
It("Includes a script in the packed Orb file", func() {
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ShouldNot(HaveOccurred())

Eventually(session.Out).Should(gbytes.Say(`commands:
orb:
steps:
Eventually(session.Out).Should(gbytes.Say(`steps:
- run:
command: echo Hello, world!
name: Say hello
`))
Eventually(session).Should(gexec.Exit(0))
})

It("Includes the setup key when an orb example uses a dynamic pipeline", func() {
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ShouldNot(HaveOccurred())
Eventually(session.Out).Should(gbytes.Say(`orbs:
orb-name: company/[email protected]
setup: true
version: 2.1
workflows:
`))
Eventually(session).Should(gexec.Exit(0))
})

})
})

0 comments on commit fdb0614

Please sign in to comment.