From fdb06140c989cf5a1cf128df034a219030615ab5 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Thu, 6 Oct 2022 23:17:37 -0400 Subject: [PATCH] Add setup key to packed orb examples Signed-off-by: Adam Harvey --- cmd/orb.go | 1 + cmd/orb_test.go | 31 +++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/cmd/orb.go b/cmd/orb.go index 2650a720e..c20f4e62b 100644 --- a/cmd/orb.go +++ b/cmd/orb.go @@ -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"` diff --git a/cmd/orb_test.go b/cmd/orb_test.go index f10100bb7..191287e8a 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,5 +3352,17 @@ 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)) + }) + }) })