• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang models.StepInfoModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/bitrise-io/stepman/models.StepInfoModel的典型用法代码示例。如果您正苦于以下问题:Golang StepInfoModel类的具体用法?Golang StepInfoModel怎么用?Golang StepInfoModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了StepInfoModel类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestPrintRunningStepFooter

func TestPrintRunningStepFooter(t *testing.T) {
	stepInfo := stepmanModels.StepInfoModel{
		Title:   longStr,
		Version: longStr,
	}

	result := models.StepRunResultsModel{
		StepInfo: stepInfo,
		Status:   models.StepRunStatusCodeSuccess,
		Idx:      0,
		RunTime:  10000000,
		Error:    errors.New(longStr),
		ExitCode: 1,
	}
	PrintRunningStepFooter(result, true)
	PrintRunningStepFooter(result, false)

	stepInfo.Title = ""
	result = models.StepRunResultsModel{
		StepInfo: stepInfo,
		Status:   models.StepRunStatusCodeSuccess,
		Idx:      0,
		RunTime:  0,
		Error:    nil,
		ExitCode: 0,
	}
	PrintRunningStepFooter(result, true)
	PrintRunningStepFooter(result, false)
}
开发者ID:viktorbenei,项目名称:bitrise,代码行数:29,代码来源:print_test.go


示例2: TestPrintSummary

func TestPrintSummary(t *testing.T) {
	PrintSummary(models.BuildRunResultsModel{})

	stepInfo := stepmanModels.StepInfoModel{
		Title:   longStr,
		Version: longStr,
	}

	result1 := models.StepRunResultsModel{
		StepInfo: stepInfo,
		Status:   models.StepRunStatusCodeSuccess,
		Idx:      0,
		RunTime:  10000000,
		Error:    errors.New(longStr),
		ExitCode: 1,
	}

	stepInfo.Title = ""
	result2 := models.StepRunResultsModel{
		StepInfo: stepInfo,
		Status:   models.StepRunStatusCodeSuccess,
		Idx:      0,
		RunTime:  0,
		Error:    nil,
		ExitCode: 0,
	}

	buildResults := models.BuildRunResultsModel{
		StartTime:      time.Now(),
		StepmanUpdates: map[string]int{},
		SuccessSteps:   []models.StepRunResultsModel{result1, result2},
	}

	PrintSummary(buildResults)
}
开发者ID:viktorbenei,项目名称:bitrise,代码行数:35,代码来源:print_test.go


示例3: TestGetRunningStepFooterMainSection

func TestGetRunningStepFooterMainSection(t *testing.T) {
	stepInfo := stepmanModels.StepInfoModel{
		Title:   longStr,
		Version: longStr,
	}

	result := models.StepRunResultsModel{
		StepInfo: stepInfo,
		Status:   models.StepRunStatusCodeFailed,
		Idx:      0,
		RunTime:  10000000,
		Error:    errors.New(longStr),
		ExitCode: 1,
	}

	cell := getRunningStepFooterMainSection(result)
	require.Equal(t, "| 🚫  | \x1b[31;1mThis is a very long string,\nthis is a very ... (exit code: 1)\x1b[0m| 0.01 sec |", cell)

	stepInfo.Title = ""
	result = models.StepRunResultsModel{
		StepInfo: stepInfo,
		Status:   models.StepRunStatusCodeSuccess,
		Idx:      0,
		RunTime:  0,
		Error:    nil,
		ExitCode: 0,
	}

	cell = getRunningStepFooterMainSection(result)
	require.Equal(t, "| ✅  | \x1b[32;1m\x1b[0m                                                             | 0.00 sec |", cell)
}
开发者ID:birmacher,项目名称:bitrise,代码行数:31,代码来源:print_test.go


示例4: TestGetTrimmedStepName

func TestGetTrimmedStepName(t *testing.T) {
	stepInfo := stepmanModels.StepInfoModel{
		Title:   longStr,
		Version: longStr,
	}

	result := models.StepRunResultsModel{
		StepInfo: stepInfo,
		Status:   models.StepRunStatusCodeSuccess,
		Idx:      0,
		RunTime:  10000000,
		Error:    errors.New(longStr),
		ExitCode: 1,
	}

	stepName := getTrimmedStepName(result)
	require.Equal(t, "This is a very long string,\nthis is a very long string,\nth...", stepName)

	stepInfo.Title = ""
	result = models.StepRunResultsModel{
		StepInfo: stepInfo,
		Status:   models.StepRunStatusCodeSuccess,
		Idx:      0,
		RunTime:  0,
		Error:    nil,
		ExitCode: 0,
	}

	stepName = getTrimmedStepName(result)
	require.Equal(t, "", stepName)
}
开发者ID:birmacher,项目名称:bitrise,代码行数:31,代码来源:print_test.go


示例5: TestPrintRunningStepHeader

func TestPrintRunningStepHeader(t *testing.T) {
	stepInfo := stepmanModels.StepInfoModel{
		Title:   "",
		Version: "",
	}
	PrintRunningStepHeader(stepInfo, 0)

	stepInfo.Title = longStr
	stepInfo.Version = ""
	PrintRunningStepHeader(stepInfo, 0)

	stepInfo.Title = ""
	stepInfo.Version = longStr
	PrintRunningStepHeader(stepInfo, 0)

	stepInfo.Title = longStr
	stepInfo.Version = longStr
	PrintRunningStepHeader(stepInfo, 0)
}
开发者ID:viktorbenei,项目名称:bitrise,代码行数:19,代码来源:print_test.go


示例6: stepInfo

func stepInfo(c *cli.Context) error {
	// Input validation
	format := c.String(FormatKey)
	collectionURI := c.String(CollectionKey)
	YMLPath := c.String(StepYMLKey)
	isShort := c.Bool(ShortKey)
	id := c.String(IDKey)
	version := c.String(VersionKey)

	if format == "" {
		format = OutputFormatRaw
	} else if !(format == OutputFormatRaw || format == OutputFormatJSON) {
		return fmt.Errorf("Invalid output format: %s", format)
	}

	if YMLPath == "" && collectionURI == "" {
		return fmt.Errorf("Missing required input: no StepLib, nor step.yml path defined as step info source")
	}

	if YMLPath != "" {
		//
		// Local step info
		step, err := stepman.ParseStepYml(YMLPath, false)
		if err != nil {
			return fmt.Errorf("Failed to parse step.yml (path:%s), err: %s", YMLPath, err)
		}

		inputs, err := getEnvInfos(step.Inputs)
		if err != nil {
			return fmt.Errorf("Failed to get step (path:%s) input infos, err: %s", YMLPath, err)
		}

		outputs, err := getEnvInfos(step.Outputs)
		if err != nil {
			return fmt.Errorf("Failed to get step (path:%s) output infos, err: %s", YMLPath, err)
		}

		stepInfo := models.StepInfoModel{
			StepLib:     YMLPath,
			Description: *step.Description,
			Source:      *step.SourceCodeURL,
			Inputs:      inputs,
			Outputs:     outputs,
		}

		if err := printStepInfo(stepInfo, format, isShort, true); err != nil {
			return fmt.Errorf("Failed to print step info, err: %s", err)
		}
	} else {
		//
		// StepLib step info

		// Input validation
		if id == "" {
			return errors.New("Missing required input: step id")
		}

		// Check if setup was done for collection
		if exist, err := stepman.RootExistForCollection(collectionURI); err != nil {
			return fmt.Errorf("Failed to check if setup was done for steplib (%s), error: %s", collectionURI, err)
		} else if !exist {
			if err := setupSteplib(collectionURI, format != OutputFormatRaw); err != nil {
				return errors.New("Failed to setup steplib")
			}
		}

		// Check if step exist in collection
		collection, err := stepman.ReadStepSpec(collectionURI)
		if err != nil {
			return fmt.Errorf("Failed to read steps spec (spec.json), err: %s", err)
		}

		step, stepFound := collection.GetStep(id, version)
		if !stepFound {
			if version == "" {
				return fmt.Errorf("Collection doesn't contain any version of step (id:%s)", id)
			}
			return fmt.Errorf("Collection doesn't contain step (id:%s) (version:%s)", id, version)
		}

		latest, err := collection.GetLatestStepVersion(id)
		if err != nil {
			return fmt.Errorf("Failed to get latest version of step (id:%s)", id)
		}

		if version == "" {
			version = latest
		}

		inputs, err := getEnvInfos(step.Inputs)
		if err != nil {
			return fmt.Errorf("Failed to get step (id:%s) input infos, err: %s", id, err)
		}

		outputs, err := getEnvInfos(step.Outputs)
		if err != nil {
			return fmt.Errorf("Failed to get step (id:%s) output infos, err: %s", id, err)
		}

		stepInfo := models.StepInfoModel{
//.........这里部分代码省略.........
开发者ID:godrei,项目名称:stepman,代码行数:101,代码来源:step_info.go


示例7: activateAndRunSteps

func activateAndRunSteps(workflow models.WorkflowModel, defaultStepLibSource string, buildRunResults models.BuildRunResultsModel, environments *[]envmanModels.EnvironmentItemModel, isLastWorkflow bool) models.BuildRunResultsModel {
	log.Debugln("[BITRISE_CLI] - Activating and running steps")

	// ------------------------------------------
	// In function global variables - These are global for easy use in local register step run result methods.
	var stepStartTime time.Time

	// ------------------------------------------
	// In function method - Registration methods, for register step run results.
	registerStepRunResults := func(step stepmanModels.StepModel, stepInfoPtr stepmanModels.StepInfoModel,
		stepIdxPtr int, runIf string, resultCode, exitCode int, err error, isLastStep, printStepHeader bool) {

		if printStepHeader {
			bitrise.PrintRunningStepHeader(stepInfoPtr, step, stepIdxPtr)
		}

		stepInfoCopy := stepmanModels.StepInfoModel{
			ID:            stepInfoPtr.ID,
			Title:         stepInfoPtr.Title,
			Version:       stepInfoPtr.Version,
			Latest:        stepInfoPtr.Latest,
			SupportURL:    stepInfoPtr.SupportURL,
			SourceCodeURL: stepInfoPtr.SourceCodeURL,
			GlobalInfo:    stepInfoPtr.GlobalInfo,
		}

		stepResults := models.StepRunResultsModel{
			StepInfo: stepInfoCopy,
			Status:   resultCode,
			Idx:      buildRunResults.ResultsCount(),
			RunTime:  time.Now().Sub(stepStartTime),
			Error:    err,
			ExitCode: exitCode,
		}

		isExitStatusError := true
		if err != nil {
			isExitStatusError = errorutil.IsExitStatusError(err)
		}

		switch resultCode {
		case models.StepRunStatusCodeSuccess:
			buildRunResults.SuccessSteps = append(buildRunResults.SuccessSteps, stepResults)
			break
		case models.StepRunStatusCodeFailed:
			if !isExitStatusError {
				log.Errorf("Step (%s) failed, error: %s", stepInfoCopy.Title, err)
			}

			buildRunResults.FailedSteps = append(buildRunResults.FailedSteps, stepResults)
			break
		case models.StepRunStatusCodeFailedSkippable:
			if !isExitStatusError {
				log.Warnf("Step (%s) failed, but was marked as skippable, error: %s", stepInfoCopy.Title, err)
			} else {
				log.Warnf("Step (%s) failed, but was marked as skippable", stepInfoCopy.Title)
			}

			buildRunResults.FailedSkippableSteps = append(buildRunResults.FailedSkippableSteps, stepResults)
			break
		case models.StepRunStatusCodeSkipped:
			log.Warnf("A previous step failed, and this step (%s) was not marked as IsAlwaysRun, skipped", stepInfoCopy.Title)

			buildRunResults.SkippedSteps = append(buildRunResults.SkippedSteps, stepResults)
			break
		case models.StepRunStatusCodeSkippedWithRunIf:
			log.Warn("The step's (" + stepInfoCopy.Title + ") Run-If expression evaluated to false - skipping")
			if runIf != "" {
				log.Info("The Run-If expression was: ", colorstring.Blue(runIf))
			}

			buildRunResults.SkippedSteps = append(buildRunResults.SkippedSteps, stepResults)
			break
		default:
			log.Error("Unkown result code")
			return
		}

		bitrise.PrintRunningStepFooter(stepResults, isLastStep)
	}

	// ------------------------------------------
	// Main - Preparing & running the steps
	for idx, stepListItm := range workflow.Steps {
		// Per step variables
		stepStartTime = time.Now()
		isLastStep := isLastWorkflow && (idx == len(workflow.Steps)-1)
		stepInfoPtr := stepmanModels.StepInfoModel{}
		stepIdxPtr := idx

		// Per step cleanup
		if err := bitrise.SetBuildFailedEnv(buildRunResults.IsBuildFailed()); err != nil {
			log.Error("Failed to set Build Status envs")
		}

		if err := bitrise.CleanupStepWorkDir(); err != nil {
			registerStepRunResults(stepmanModels.StepModel{}, stepInfoPtr, stepIdxPtr,
				"", models.StepRunStatusCodeFailed, 1, err, isLastStep, true)
			continue
		}
//.........这里部分代码省略.........
开发者ID:godrei,项目名称:bitrise,代码行数:101,代码来源:run_util.go


示例8: stepInfo

func stepInfo(c *cli.Context) error {
	// Input validation
	format := c.String(FormatKey)
	collectionURI := c.String(CollectionKey)
	YMLPath := c.String(StepYMLKey)
	isShort := c.Bool(ShortKey)
	id := c.String(IDKey)
	version := c.String(VersionKey)

	if format == "" {
		format = OutputFormatRaw
	} else if !(format == OutputFormatRaw || format == OutputFormatJSON) {
		return fmt.Errorf("Invalid output format: %s", format)
	}

	if YMLPath == "" && collectionURI == "" {
		return fmt.Errorf("Missing required input: no StepLib, nor step.yml path defined as step info source")
	}

	if YMLPath != "" {
		//
		// Local step info
		step, err := stepman.ParseStepYml(YMLPath, false)
		if err != nil {
			return fmt.Errorf("Failed to parse step.yml (path:%s), err: %s", YMLPath, err)
		}

		inputs, err := getEnvInfos(step.Inputs)
		if err != nil {
			return fmt.Errorf("Failed to get step (path:%s) input infos, err: %s", YMLPath, err)
		}

		outputs, err := getEnvInfos(step.Outputs)
		if err != nil {
			return fmt.Errorf("Failed to get step (path:%s) output infos, err: %s", YMLPath, err)
		}

		stepInfo := models.StepInfoModel{
			StepLib:     YMLPath,
			Description: *step.Description,
			Source:      *step.SourceCodeURL,
			Inputs:      inputs,
			Outputs:     outputs,
		}

		if err := printStepInfo(stepInfo, format, isShort, true); err != nil {
			return fmt.Errorf("Failed to print step info, err: %s", err)
		}
	} else {
		//
		// StepLib step info

		stepVersion, err := ReadStepInfo(collectionURI, id, version, true, format != OutputFormatRaw)
		if err != nil {
			return fmt.Errorf("Failed to read Step information, error: %s", err)
		}

		if version == "" {
			version = stepVersion.Version
		}
		step := stepVersion.Step

		inputs, err := getEnvInfos(step.Inputs)
		if err != nil {
			return fmt.Errorf("Failed to get step (id:%s) input infos, err: %s", id, err)
		}

		outputs, err := getEnvInfos(step.Outputs)
		if err != nil {
			return fmt.Errorf("Failed to get step (id:%s) output infos, err: %s", id, err)
		}

		stepInfo := models.StepInfoModel{
			ID:          id,
			Version:     version,
			Latest:      stepVersion.LatestAvailableVersion,
			Description: *step.Description,
			StepLib:     collectionURI,
			Source:      *step.SourceCodeURL,
			Inputs:      inputs,
			Outputs:     outputs,
		}

		route, found := stepman.ReadRoute(collectionURI)
		if !found {
			return fmt.Errorf("No route found for collection: %s", collectionURI)
		}
		globalStepInfoPth := stepman.GetStepGlobalInfoPath(route, id)
		if globalStepInfoPth != "" {
			globalInfo, found, err := stepman.ParseGlobalStepInfoYML(globalStepInfoPth)
			if err != nil {
				return fmt.Errorf("Failed to get step (path:%s) output infos, err: %s", globalStepInfoPth, err)
			}

			if found {
				stepInfo.GlobalInfo = globalInfo
			}
		}

		if err := printStepInfo(stepInfo, format, isShort, false); err != nil {
//.........这里部分代码省略.........
开发者ID:bitrise-io,项目名称:stepman,代码行数:101,代码来源:step_info.go



注:本文中的github.com/bitrise-io/stepman/models.StepInfoModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang models.StepModel类代码示例发布时间:2022-05-24
下一篇:
Golang models.StepCollectionModel类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap