-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename 'with' group to 'with group' * Update step bundle's step list item type and move workflow run plan creation to the models package * Test step bundles in the workflow run execution plan * Fix bundle envs handling * Fix step list item getters * Code cleanup * Integration test nested bundles * Code cleanup * Code cleanup * Import list order * Remove obsolete tests * Validate circular step bundle reference * Validate step bundle reference cycle with a deterministic order
- Loading branch information
Showing
10 changed files
with
874 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,85 @@ | ||
package integration | ||
|
||
import ( | ||
"encoding/json" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/bitrise-io/go-utils/command" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestStepBundles(t *testing.T) { | ||
func TestStepBundleInputs(t *testing.T) { | ||
configPth := "step_bundles_test_bitrise.yml" | ||
|
||
cmd := command.New(binPath(), "run", "test_step_bundle_inputs", "-c", configPth) | ||
out, err := cmd.RunAndReturnTrimmedCombinedOutput() | ||
require.NoError(t, err, out) | ||
require.Contains(t, out, "Hello Bitrise!") | ||
} | ||
|
||
func TestNestedStepBundle(t *testing.T) { | ||
configPth := "step_bundles_test_bitrise.yml" | ||
|
||
cmd := command.New(binPath(), "run", "--output-format", "json", "test_nested_step_bundle", "-c", configPth) | ||
out, err := cmd.RunAndReturnTrimmedCombinedOutput() | ||
require.NoError(t, err, out) | ||
stepOutputs := collectStepOutputs(out, t) | ||
require.Equal(t, stepOutputs, []string{ | ||
`bundle1 | ||
bundle1_input1: bundle1_input1 | ||
bundle2_input1: bundle2_input1 | ||
`, | ||
`bundle1 | ||
bundle1_input1: bundle1_input1_override | ||
bundle2_input1: bundle2_input1 | ||
`, | ||
`bundle2 | ||
bundle1_input1: | ||
bundle2_input1: bundle2_input1 | ||
`, | ||
`workflow step | ||
bundle1_input1: | ||
bundle2_input1: | ||
`, | ||
}) | ||
} | ||
|
||
func collectStepOutputs(workflowRunOut string, t *testing.T) []string { | ||
type messageLine struct { | ||
Producer string `json:"producer"` | ||
ProducerID string `json:"producer_id"` | ||
Message string `json:"message"` | ||
} | ||
|
||
idxToStep := map[string]int{} | ||
messageToStep := map[string]string{} | ||
stepIDx := 0 | ||
|
||
for _, line := range strings.Split(workflowRunOut, "\n") { | ||
var message messageLine | ||
err := json.Unmarshal([]byte(line), &message) | ||
require.NoError(t, err) | ||
|
||
if message.Producer != "step" { | ||
continue | ||
} | ||
|
||
stepMessage := messageToStep[message.ProducerID] | ||
stepMessage += message.Message | ||
messageToStep[message.ProducerID] = stepMessage | ||
|
||
_, ok := idxToStep[message.ProducerID] | ||
if !ok { | ||
idxToStep[message.ProducerID] = stepIDx | ||
stepIDx++ | ||
} | ||
} | ||
|
||
stepMessages := make([]string, len(idxToStep)) | ||
for step, idx := range idxToStep { | ||
stepMessages[idx] = messageToStep[step] | ||
} | ||
|
||
return stepMessages | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.