Skip to content

Commit

Permalink
Merge pull request #794 from adamdmharvey/adamdmharvey/enable-setup-i…
Browse files Browse the repository at this point in the history
…n-examples

feat: Include `setup` key in published Orb examples
  • Loading branch information
JulesFaucherre authored May 4, 2023
2 parents bfe5c99 + 8722150 commit 9e589f2
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 @@ -1059,6 +1059,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,17 +3344,26 @@ 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))
})

})

Describe("Orb diff", func() {
Expand Down

0 comments on commit 9e589f2

Please sign in to comment.