本文整理汇总了Golang中github.com/bitrise-io/bitrise/configs.InitPaths函数的典型用法代码示例。如果您正苦于以下问题:Golang InitPaths函数的具体用法?Golang InitPaths怎么用?Golang InitPaths使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InitPaths函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSuccess
// Test - Bitrise activateAndRunWorkflow
// Trivial success test
func TestSuccess(t *testing.T) {
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
target:
steps:
- script:
title: Should success
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
_, found := config.Workflows["target"]
require.Equal(t, true, found)
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "target", config, []envmanModels.EnvironmentItemModel{})
require.NoError(t, err)
require.Equal(t, 1, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
require.Equal(t, "0", os.Getenv("BITRISE_BUILD_STATUS"))
require.Equal(t, "0", os.Getenv("STEPLIB_BUILD_STATUS"))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:33,代码来源:run_test.go
示例2: TestWorkflowEnvironmentOverWrite
// Test - Bitrise Environments
// Test for same env in before and target workflow, actual workflow should overwrite environemnt and use own value
func TestWorkflowEnvironmentOverWrite(t *testing.T) {
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
before:
envs:
- ENV: env1
steps:
- script:
inputs:
- content: |
#!/bin/bash
set -v
echo ${ENV}
if [[ "$ENV" != "env1" ]] ; then
exit 1
fi
target:
title: target
envs:
- ENV: env2
before_run:
- before
steps:
- script:
inputs:
- content: |
#!/bin/bash
set -v
echo ${ENV}
if [[ "$ENV" != "env2" ]] ; then
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
_, found := config.Workflows["target"]
require.Equal(t, true, found)
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "target", config, []envmanModels.EnvironmentItemModel{})
require.NoError(t, err)
require.Equal(t, 2, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
require.Equal(t, "0", os.Getenv("BITRISE_BUILD_STATUS"))
require.Equal(t, "0", os.Getenv("STEPLIB_BUILD_STATUS"))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:59,代码来源:run_test.go
示例3: TestDeleteEnvironment
func TestDeleteEnvironment(t *testing.T) {
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
test:
steps:
- script:
is_skippable: true
title: "Envman add DELETE_TEST"
inputs:
- content: |
#!/bin/bash
envman add --key DELETE_TEST --value "delete test"
- script:
title: "Test env DELETE_TEST"
inputs:
- content: |
#!/bin/bash
set -v
echo "DELETE_TEST: $DELETE_TEST"
if [ -z "$DELETE_TEST" ] ; then
exit 1
fi
- script:
title: "Delete env DELETE_TEST"
inputs:
- content: |
#!/bin/bash
envman add --key DELETE_TEST --value ""
- script:
title: "Test env DELETE_TEST"
inputs:
- content: |
#!/bin/bash
set -v
echo "DELETE_TEST: $DELETE_TEST"
if [ ! -z "$DELETE_TEST" ] ; then
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "test", config, []envmanModels.EnvironmentItemModel{})
require.NoError(t, err)
require.Equal(t, 4, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:55,代码来源:run_test.go
示例4: TestStepInputEnvironment
// Test - Bitrise Environments
// Step input should visible only for actual step and invisible for other steps
func TestStepInputEnvironment(t *testing.T) {
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
before:
steps:
- script:
inputs:
- working_dir: $HOME
target:
title: target
before_run:
- before
steps:
- script:
title: "${working_dir} should not exist"
inputs:
- content: |
#!/bin/bash
set -v
echo ${ENV}
if [ ! -z "$working_dir" ] ; then
echo ${working_dir}
exit 3
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
_, found := config.Workflows["target"]
require.Equal(t, true, found)
if os.Getenv("working_dir") != "" {
require.Equal(t, nil, os.Unsetenv("working_dir"))
}
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "target", config, []envmanModels.EnvironmentItemModel{})
require.NoError(t, err)
require.Equal(t, 2, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
require.Equal(t, "0", os.Getenv("BITRISE_BUILD_STATUS"))
require.Equal(t, "0", os.Getenv("STEPLIB_BUILD_STATUS"))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:55,代码来源:run_test.go
示例5: TestEvaluateInputs
func TestEvaluateInputs(t *testing.T) {
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
test:
envs:
- TEST_KEY: "test value"
steps:
- script:
title: "Template test"
inputs:
- content: |
#!/bin/bash
set -v
{{if .IsCI}}
exit 1
{{else}}
exit 0
{{end}}
opts:
is_template: true
- script:
title: "Template test"
inputs:
- content: |
#!/bin/bash
set -v
{{if enveq "TEST_KEY" "test value"}}
exit 0
{{else}}
exit 1
{{end}}
opts:
is_template: true
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "test", config, []envmanModels.EnvironmentItemModel{})
require.Equal(t, nil, err)
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
require.Equal(t, 2, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:51,代码来源:run_util_test.go
示例6: TestStepmanJSONStepLibStepInfo
func TestStepmanJSONStepLibStepInfo(t *testing.T) {
// setup
require.NoError(t, configs.InitPaths())
// Valid params -- Err should empty, output filled
require.Equal(t, nil, StepmanSetup("https://github.com/bitrise-io/bitrise-steplib"))
outStr, err := StepmanJSONStepLibStepInfo("https://github.com/bitrise-io/bitrise-steplib", "script", "0.9.0")
require.Equal(t, nil, err)
require.NotEqual(t, "", outStr)
// Invalid params -- Err should empty, output filled
outStr, err = StepmanJSONStepLibStepInfo("https://github.com/bitrise-io/bitrise-steplib", "script", "2")
require.NotEqual(t, nil, err)
require.Equal(t, "", outStr)
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:16,代码来源:tools_test.go
示例7: TestFailedStepOutputs
func TestFailedStepOutputs(t *testing.T) {
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
test:
steps:
- script:
is_skippable: true
title: "Envman add"
inputs:
- content: |
#!/bin/bash
set -v
envman add --key FAILED_OUTPUT_TEST --value "failed step output"
exit 1
- script:
title: "Test failed output"
inputs:
- content: |
#!/bin/bash
set -v
echo "FAILED_OUTPUT_TEST: $FAILED_OUTPUT_TEST"
if [[ "$FAILED_OUTPUT_TEST" != "failed step output" ]] ; then
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "test", config, []envmanModels.EnvironmentItemModel{})
require.NoError(t, err)
require.Equal(t, 1, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 1, len(buildRunResults.FailedSkippableSteps))
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:41,代码来源:run_test.go
示例8: TestExpandEnvs
func TestExpandEnvs(t *testing.T) {
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
test:
envs:
- ENV0: "Hello"
- ENV1: "$ENV0 world"
steps:
- script:
inputs:
- content: |
#!/bin/bash
envman add --key ENV2 --value "$ENV1 !"
- script:
inputs:
- content: |
#!/bin/bash
echo "ENV2: $ENV2"
if [ "$ENV2" != "Hello world !" ] ; then
echo "Actual ($ENV2), excpected (Hello world !)"
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "test", config, []envmanModels.EnvironmentItemModel{})
require.NoError(t, err)
require.Equal(t, 2, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:40,代码来源:run_util_test.go
示例9: TestInvalidStepID
func TestInvalidStepID(t *testing.T) {
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
target:
title: Invalid step id
steps:
- invalid-step:
- invalid-step:
- invalid-step:
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
results, err := runWorkflowWithConfiguration(time.Now(), "target", config, []envmanModels.EnvironmentItemModel{})
require.Equal(t, 1, len(results.StepmanUpdates))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:23,代码来源:run_util_test.go
示例10: Test0Steps1Workflows
// Test - Bitrise activateAndRunWorkflow
// If workflow contains no steps
func Test0Steps1Workflows(t *testing.T) {
workflow := models.WorkflowModel{}
require.NoError(t, os.Setenv("BITRISE_BUILD_STATUS", "0"))
defer func() { require.NoError(t, os.Unsetenv("BITRISE_BUILD_STATUS")) }()
require.NoError(t, os.Setenv("STEPLIB_BUILD_STATUS", "0"))
defer func() { require.NoError(t, os.Unsetenv("STEPLIB_BUILD_STATUS")) }()
config := models.BitriseDataModel{
FormatVersion: "1.0.0",
DefaultStepLibSource: "https://github.com/bitrise-io/bitrise-steplib.git",
Workflows: map[string]models.WorkflowModel{
"zero_steps": workflow,
},
}
_, err := config.Validate()
require.NoError(t, err)
buildRunResults := models.BuildRunResultsModel{
StartTime: time.Now(),
StepmanUpdates: map[string]int{},
}
require.NoError(t, configs.InitPaths())
buildRunResults, err = runWorkflowWithConfiguration(time.Now(), "zero_steps", config, []envmanModels.EnvironmentItemModel{})
require.NoError(t, err)
require.Equal(t, 0, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
require.Equal(t, "0", os.Getenv("BITRISE_BUILD_STATUS"))
require.Equal(t, "0", os.Getenv("STEPLIB_BUILD_STATUS"))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:39,代码来源:run_test.go
示例11: TestRemoveConfigRedundantFieldsAndFillStepOutputs
func TestRemoveConfigRedundantFieldsAndFillStepOutputs(t *testing.T) {
// setup
require.NoError(t, configs.InitPaths())
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
remove_test:
steps:
- script:
inputs:
- content: |
#!/bin/bash
set -v
exit 2
opts:
is_expand: true
- timestamp:
title: Generate timestamps
`
config, warnings, err := ConfigModelFromYAMLBytes([]byte(configStr))
require.Equal(t, nil, err)
require.Equal(t, 0, len(warnings))
require.Equal(t, nil, RemoveConfigRedundantFieldsAndFillStepOutputs(&config))
for workflowID, workflow := range config.Workflows {
if workflowID == "remove_test" {
for _, stepListItem := range workflow.Steps {
for stepID, step := range stepListItem {
if stepID == "script" {
for _, input := range step.Inputs {
key, _, err := input.GetKeyValuePair()
require.Equal(t, nil, err)
if key == "content" {
opts, err := input.GetOptions()
require.Equal(t, nil, err)
// script content should keep is_expand: true, becouse it's diffenet from spec default
require.Equal(t, true, *opts.IsExpand)
}
}
} else if stepID == "timestamp" {
// timestamp title should be nil, becouse it's the same as spec value
require.Equal(t, (*string)(nil), step.Title)
for _, output := range step.Outputs {
key, _, err := output.GetKeyValuePair()
require.Equal(t, nil, err)
if key == "UNIX_TIMESTAMP" {
// timestamp outputs should filled with key-value & opts.Title
opts, err := output.GetOptions()
require.Equal(t, nil, err)
require.Equal(t, "unix style", *opts.Title)
require.Equal(t, (*bool)(nil), opts.IsExpand)
require.Equal(t, (*bool)(nil), opts.IsDontChangeValue)
require.Equal(t, (*bool)(nil), opts.IsRequired)
}
}
}
}
}
}
}
// timestamp outputs should filled with key-value & opts.Title
}
开发者ID:godrei,项目名称:bitrise,代码行数:74,代码来源:util_test.go
示例12: TestStepOutputEnvironment
// Outputs exported with `envman add` should be accessible for subsequent Steps.
func TestStepOutputEnvironment(t *testing.T) {
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
out-test:
title: Output Test
steps:
- script:
inputs:
- content: envman -l=debug add --key MY_TEST_1 --value 'Test value 1'
- script:
inputs:
- content: |-
if [[ "${MY_TEST_1}" != "Test value 1" ]] ; then
echo " [!] MY_TEST_1 invalid: ${MY_TEST_1}"
exit 1
fi
- script:
title: Should fail
inputs:
- content: |-
envman add --key MY_TEST_2 --value 'Test value 2'
# exported output, but test fails
exit 22
- script:
is_always_run: true
inputs:
- content: |-
if [[ "${MY_TEST_2}" != "Test value 2" ]] ; then
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
_, found := config.Workflows["out-test"]
require.Equal(t, true, found)
_, err = config.Validate()
require.NoError(t, err)
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "out-test", config, []envmanModels.EnvironmentItemModel{})
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
require.Equal(t, 3, len(buildRunResults.SuccessSteps))
require.Equal(t, 1, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
// the exported output envs should NOT be exposed here, should NOT be available!
require.Equal(t, "", os.Getenv("MY_TEST_1"))
require.Equal(t, "", os.Getenv("MY_TEST_2"))
// standard, Build Status ENV test
require.Equal(t, "1", os.Getenv("BITRISE_BUILD_STATUS"))
require.Equal(t, "1", os.Getenv("STEPLIB_BUILD_STATUS"))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:62,代码来源:run_test.go
示例13: TestBuildStatusEnv
// Test - Bitrise BuildStatusEnv
// Checks if BuildStatusEnv is set correctly
func TestBuildStatusEnv(t *testing.T) {
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
before1:
steps:
- script:
title: Should success
- script:
title: Should fail, but skippable
is_skippable: true
inputs:
- content: |
#!/bin/bash
set -v
exit 2
- script:
title: Should success
before2:
steps:
- script:
title: Should success
target:
steps:
- script:
title: Should success
inputs:
- content: |
#!/bin/bash
set -v
if [[ "$BITRISE_BUILD_STATUS" != "0" ]] ; then
exit 1
fi
if [[ "$STEPLIB_BUILD_STATUS" != "0" ]] ; then
exit 1
fi
- script:
title: Should fail, but skippable
is_skippable: true
inputs:
- content: |
#!/bin/bash
set -v
echo 'This is a before workflow'
exit 2
- script:
title: Should success
inputs:
- content: |
#!/bin/bash
set -v
if [[ "$BITRISE_BUILD_STATUS" != "0" ]] ; then
exit 1
fi
if [[ "$STEPLIB_BUILD_STATUS" != "0" ]] ; then
exit 1
fi
- script:
title: Should fail
inputs:
- content: |
#!/bin/bash
set -v
exit 1
- script:
title: Should success
is_always_run: true
inputs:
- content: |
#!/bin/bash
set -v
if [[ "$BITRISE_BUILD_STATUS" != "1" ]] ; then
echo "should fail"
fi
if [[ "$STEPLIB_BUILD_STATUS" != "1" ]] ; then
echo "should fail"
fi
- script:
title: Should skipped
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
_, found := config.Workflows["target"]
require.Equal(t, true, found)
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "target", config, []envmanModels.EnvironmentItemModel{})
require.NoError(t, err)
require.Equal(t, 3, len(buildRunResults.SuccessSteps))
require.Equal(t, 1, len(buildRunResults.FailedSteps))
//.........这里部分代码省略.........
开发者ID:bitrise-io,项目名称:bitrise,代码行数:101,代码来源:run_test.go
示例14: TestEnvOrders
func TestEnvOrders(t *testing.T) {
t.Log("Only secret env - secret env should be use")
{
inventoryStr := `
envs:
- ENV_ORDER_TEST: "should be the 1."
`
inventory, err := bitrise.InventoryModelFromYAMLBytes([]byte(inventoryStr))
require.NoError(t, err)
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
test:
steps:
- script:
inputs:
- content: |
#!/bin/bash
set -v
echo "ENV_ORDER_TEST: $ENV_ORDER_TEST"
if [[ "$ENV_ORDER_TEST" != "should be the 1." ]] ; then
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
_, err = runWorkflowWithConfiguration(time.Now(), "test", config, inventory.Envs)
require.NoError(t, err)
}
t.Log("Secret env & app env also defined - app env should be use")
{
inventoryStr := `
envs:
- ENV_ORDER_TEST: "should be the 1."
`
inventory, err := bitrise.InventoryModelFromYAMLBytes([]byte(inventoryStr))
require.NoError(t, err)
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
app:
envs:
- ENV_ORDER_TEST: "should be the 2."
workflows:
test:
steps:
- script:
inputs:
- content: |
#!/bin/bash
set -v
echo "ENV_ORDER_TEST: $ENV_ORDER_TEST"
if [[ "$ENV_ORDER_TEST" != "should be the 2." ]] ; then
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
_, err = runWorkflowWithConfiguration(time.Now(), "test", config, inventory.Envs)
require.NoError(t, err)
}
t.Log("Secret env & app env && workflow env also defined - workflow env should be use")
{
inventoryStr := `
envs:
- ENV_ORDER_TEST: "should be the 1."
`
inventory, err := bitrise.InventoryModelFromYAMLBytes([]byte(inventoryStr))
require.NoError(t, err)
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
app:
envs:
- ENV_ORDER_TEST: "should be the 2."
//.........这里部分代码省略.........
开发者ID:bitrise-io,项目名称:bitrise,代码行数:101,代码来源:run_test.go
示例15: TestBitriseSourceDir
func TestBitriseSourceDir(t *testing.T) {
currPth, err := pathutil.NormalizedOSTempDirPath("bitrise_source_dir_test")
require.NoError(t, err)
testPths := []string{}
for i := 0; i < 4; i++ {
testPth := filepath.Join(currPth, fmt.Sprintf("_test%d", i))
require.NoError(t, os.RemoveAll(testPth))
require.NoError(t, os.Mkdir(testPth, 0777))
// eval symlinks: the Go generated temp folder on OS X is a symlink
// from /var/ to /private/var/
testPth, err = filepath.EvalSymlinks(testPth)
require.NoError(t, err)
defer func() { require.NoError(t, os.RemoveAll(testPth)) }()
testPths = append(testPths, testPth)
}
t.Log("BITRISE_SOURCE_DIR defined in Secret")
{
inventoryStr := `
envs:
- BITRISE_SOURCE_DIR: "` + testPths[0] + `"
`
inventory, err := bitrise.InventoryModelFromYAMLBytes([]byte(inventoryStr))
require.NoError(t, err)
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
test:
steps:
- script:
inputs:
- content: |
#!/bin/bash
set -v
echo "BITRISE_SOURCE_DIR: $BITRISE_SOURCE_DIR"
if [[ "$BITRISE_SOURCE_DIR" != "` + testPths[0] + `" ]] ; then
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
_, err = runWorkflowWithConfiguration(time.Now(), "test", config, inventory.Envs)
require.NoError(t, err)
}
t.Log("BITRISE_SOURCE_DIR defined in Secret, and in App")
{
inventoryStr := `
envs:
- BITRISE_SOURCE_DIR: "` + testPths[0] + `"
`
inventory, err := bitrise.InventoryModelFromYAMLBytes([]byte(inventoryStr))
require.NoError(t, err)
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
app:
envs:
- BITRISE_SOURCE_DIR: "` + testPths[1] + `"
workflows:
test:
steps:
- script:
inputs:
- content: |
#!/bin/bash
set -v
echo "BITRISE_SOURCE_DIR: $BITRISE_SOURCE_DIR"
if [[ "$BITRISE_SOURCE_DIR" != "` + testPths[1] + `" ]] ; then
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
_, err = runWorkflowWithConfiguration(time.Now(), "test", config, inventory.Envs)
require.NoError(t, err)
}
t.Log("BITRISE_SOURCE_DIR defined in Secret, App and Workflow")
{
inventoryStr := `
//.........这里部分代码省略.........
开发者ID:bitrise-io,项目名称:bitrise,代码行数:101,代码来源:run_test.go
示例16: before
func before(c *cli.Context) error {
/*
return err will print app's help also,
use log.Fatal to avoid print help.
*/
initLogFormatter()
initHelpAndVersionFlags()
initAppHelpTemplate()
// Debug mode?
if c.Bool(DebugModeKey) {
// set for other tools, as an ENV
if err := os.Setenv(configs.DebugModeEnvKey, "true"); err != nil {
log.Fatalf("Failed to set DEBUG env, error: %s", err)
}
configs.IsDebugMode = true
log.Warn("=> Started in DEBUG mode")
}
// Log level
// If log level defined - use it
logLevelStr := c.String(LogLevelKey)
if logLevelStr == "" && configs.IsDebugMode {
// if no Log Level defined and we're in Debug Mode - set loglevel to debug
logLevelStr = "debug"
log.Warn("=> LogLevel set to debug")
}
if logLevelStr == "" {
// if still empty: set the default
logLevelStr = "info"
}
level, err := log.ParseLevel(logLevelStr)
if err != nil {
log.Fatalf("Failed parse log level, error: %s", err)
}
if err := os.Setenv(configs.LogLevelEnvKey, level.String()); err != nil {
log.Fatalf("Failed to set LOGLEVEL env, error: %s", err)
}
log.SetLevel(level)
// CI Mode check
if c.Bool(CIKey) {
// if CI mode indicated make sure we set the related env
// so all other tools we use will also get it
if err := os.Setenv(configs.CIModeEnvKey, "true"); err != nil {
log.Fatalf("Failed to set CI env, error: %s", err)
}
configs.IsCIMode = true
}
if err := configs.InitPaths(); err != nil {
log.Fatalf("Failed to initialize required paths, error: %s", err)
}
if err := plugins.InitPaths(); err != nil {
log.Fatalf("Failed to initialize required plugin paths, error: %s", err)
}
// Pull Request Mode check
if c.Bool(PRKey) {
// if PR mode indicated make sure we set the related env
// so all other tools we use will also get it
if err := os.Setenv(configs.PRModeEnvKey, "true"); err != nil {
log.Fatalf("Failed to set PR env, error: %s", err)
}
configs.IsPullRequestMode = true
}
pullReqID := os.Getenv(configs.PullRequestIDEnvKey)
if pullReqID != "" {
configs.IsPullRequestMode = true
}
IsPR := os.Getenv(configs.PRModeEnvKey)
if IsPR == "true" {
configs.IsPullRequestMode = true
}
return nil
}
开发者ID:godrei,项目名称:bitrise,代码行数:83,代码来源:cli.go
示例17: TestSkipIfEmpty
func TestSkipIfEmpty(t *testing.T) {
t.Log("skip_if_empty=true && value=empty => should not add")
{
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
skip_if_empty:
envs:
- TEST: test
- TEST:
opts:
skip_if_empty: true
steps:
- script:
is_skippable: true
title: "Envman add DELETE_TEST"
inputs:
- content: |
#!/bin/bash
if [ -z $TEST ] ; then
echo "TEST shuld exist"
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "skip_if_empty", config, []envmanModels.EnvironmentItemModel{})
require.NoError(t, err)
require.Equal(t, 1, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
}
t.Log("skip_if_empty=false && value=empty => should add")
{
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
skip_if_empty:
envs:
- TEST: test
- TEST:
opts:
skip_if_empty: false
steps:
- script:
is_skippable: true
title: "Envman add DELETE_TEST"
inputs:
- content: |
#!/bin/bash
if [ ! -z $TEST ] ; then
echo "TEST env shuld not exist"
exit 1
fi
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "skip_if_empty", config, []envmanModels.EnvironmentItemModel{})
require.NoError(t, err)
require.Equal(t, 1, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
require.Equal(t, 0, len(buildRunResults.SkippedSteps))
}
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:79,代码来源:run_test.go
示例18: TestStepOutputsInTemplate
func TestStepOutputsInTemplate(t *testing.T) {
inventoryStr := `
envs:
- TEMPLATE_TEST0: "true"
`
inventory, err := bitrise.InventoryModelFromYAMLBytes([]byte(inventoryStr))
require.NoError(t, err)
configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
app:
envs:
- TEMPLATE_TEST1: "true"
workflows:
test:
envs:
- TEMPLATE_TEST2: "true"
steps:
- script:
title: "Envman add"
inputs:
- content: |
#!/bin/bash
set -v
envman add --key TEMPLATE_TEST3 --value "true"
- script:
title: "TEMPLATE_TEST0"
run_if: |-
{{enveq "TEMPLATE_TEST0" "true"}}
- script:
title: "TEMPLATE_TEST1"
run_if: |-
{{enveq "TEMPLATE_TEST1" "true"}}
- script:
title: "TEMPLATE_TEST2"
run_if: |-
{{enveq "TEMPLATE_TEST2" "true"}}
- script:
title: "TEMPLATE_TEST3"
run_if: |-
{{enveq "TEMPLATE_TEST3" "true"}}
- script:
title: "TEMPLATE_TEST_NO_VALUE"
run_if: |-
{{enveq "TEMPLATE_TEST_NO_VALUE" "true"}}
`
require.NoError(t, configs.InitPaths())
config, warnings, err := bitrise.ConfigModelFromYAMLBytes([]byte(configStr))
require.NoError(t, err)
require.Equal(t, 0, len(warnings))
buildRunResults, err := runWorkflowWithConfiguration(time.Now(), "test", config, inventory.Envs)
require.NoError(t, err)
require.Equal(t, 5, len(buildRunResults.SuccessSteps))
require.Equal(t, 0, len(buildRunResults.FailedSteps))
require.Equal(t, 0, len(buildRunResults.FailedSkippableSteps))
require.Equal(t, 1, len(buildRunResults.SkippedSteps))
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:63,代码来源:run_test.go
注:本文中的github.com/bitrise-io/bitrise/configs.InitPaths函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论