diff --git a/cmd/orb.go b/cmd/orb.go index 326b0a616..1f8ef230c 100644 --- a/cmd/orb.go +++ b/cmd/orb.go @@ -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"` diff --git a/cmd/orb_test.go b/cmd/orb_test.go index ded63dbe3..2ab23c889 100644 --- a/cmd/orb_test.go +++ b/cmd/orb_test.go @@ -3311,6 +3311,20 @@ Windows Server 2010 - run: name: Say hello command: <> + +examples: + example: + description: | + An example of how to use the orb. + usage: + version: 2.1 + orbs: + orb-name: company/orb-name@1.2.3 + 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!`)) @@ -3330,10 +3344,7 @@ 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 @@ -3341,6 +3352,18 @@ Windows Server 2010 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/orb-name@1.2.3 + setup: true + version: 2.1 + workflows: +`)) + Eventually(session).Should(gexec.Exit(0)) + }) + }) Describe("Orb diff", func() {