コード例 #1
0
ファイル: run_util.go プロジェクト: godrei/bitrise
func executeStep(step stepmanModels.StepModel, sIDData models.StepIDData, stepAbsDirPath, bitriseSourceDir string) (int, error) {
	toolkitForStep := toolkits.ToolkitForStep(step)
	toolkitName := toolkitForStep.ToolkitName()

	if err := toolkitForStep.PrepareForStepRun(step, sIDData, stepAbsDirPath); err != nil {
		return 1, fmt.Errorf("Failed to prepare the step for execution through the required toolkit (%s), error: %s",
			toolkitName, err)
	}

	cmd, err := toolkitForStep.StepRunCommandArguments(stepAbsDirPath, sIDData)
	if err != nil {
		return 1, fmt.Errorf("Toolkit (%s) rejected the step, error: %s",
			toolkitName, err)
	}

	return tools.EnvmanRun(configs.InputEnvstorePath, bitriseSourceDir, cmd)
}
コード例 #2
0
ファイル: print.go プロジェクト: godrei/bitrise
func getRunningStepHeaderSubSection(step stepmanModels.StepModel, stepInfo stepmanModels.StepInfoModel) string {

	idRow := ""
	{
		id := stepInfo.ID
		idRow = fmt.Sprintf("| id: %s |", id)
		charDiff := len(idRow) - stepRunSummaryBoxWidthInChars
		if charDiff < 0 {
			// shorter than desired - fill with space
			idRow = fmt.Sprintf("| id: %s%s |", id, strings.Repeat(" ", -charDiff))
		} else if charDiff > 0 {
			// longer than desired - trim title
			trimmedWidth := len(id) - charDiff
			if trimmedWidth < 4 {
				log.Errorf("Step id too long, can't present id at all! : %s", id)
			} else {
				idRow = fmt.Sprintf("| id: %s |", stringutil.MaxFirstCharsWithDots(id, trimmedWidth))
			}
		}
	}

	versionRow := ""
	{
		version := stepInfo.Version
		versionRow = fmt.Sprintf("| version: %s |", version)
		charDiff := len(versionRow) - stepRunSummaryBoxWidthInChars
		if charDiff < 0 {
			// shorter than desired - fill with space
			versionRow = fmt.Sprintf("| version: %s%s |", version, strings.Repeat(" ", -charDiff))
		} else if charDiff > 0 {
			// longer than desired - trim title
			trimmedWidth := len(version) - charDiff
			if trimmedWidth < 4 {
				log.Errorf("Step version too long, can't present version at all! : %s", version)
			} else {
				versionRow = fmt.Sprintf("| id: %s |", stringutil.MaxFirstCharsWithDots(version, trimmedWidth))
			}
		}
	}

	collectionRow := ""
	{
		collection := stepInfo.StepLib
		collectionRow = fmt.Sprintf("| collection: %s |", collection)
		charDiff := len(collectionRow) - stepRunSummaryBoxWidthInChars
		if charDiff < 0 {
			// shorter than desired - fill with space
			collectionRow = fmt.Sprintf("| collection: %s%s |", collection, strings.Repeat(" ", -charDiff))
		} else if charDiff > 0 {
			// longer than desired - trim title
			trimmedWidth := len(collection) - charDiff
			if trimmedWidth < 4 {
				log.Errorf("Step collection too long, can't present collection at all! : %s", collection)
			} else {
				collectionRow = fmt.Sprintf("| collection: %s |", stringutil.MaxLastCharsWithDots(collection, trimmedWidth))
			}
		}
	}

	toolkitRow := ""
	{
		toolkitForStep := toolkits.ToolkitForStep(step)
		toolkitName := toolkitForStep.ToolkitName()
		toolkitRow = fmt.Sprintf("| toolkit: %s |", toolkitName)
		charDiff := len(toolkitRow) - stepRunSummaryBoxWidthInChars
		if charDiff < 0 {
			// shorter than desired - fill with space
			toolkitRow = fmt.Sprintf("| toolkit: %s%s |", toolkitName, strings.Repeat(" ", -charDiff))
		} else if charDiff > 0 {
			// longer than desired - trim title
			trimmedWidth := len(toolkitName) - charDiff
			if trimmedWidth < 4 {
				log.Errorf("Step toolkitName too long, can't present toolkitName at all! : %s", toolkitName)
			} else {
				toolkitRow = fmt.Sprintf("| toolkit: %s |", stringutil.MaxLastCharsWithDots(toolkitName, trimmedWidth))
			}
		}
	}

	timeRow := ""
	{
		logTime := time.Now().Format(time.RFC3339)
		timeRow = fmt.Sprintf("| time: %s |", logTime)
		charDiff := len(timeRow) - stepRunSummaryBoxWidthInChars
		if charDiff < 0 {
			// shorter than desired - fill with space
			timeRow = fmt.Sprintf("| time: %s%s |", logTime, strings.Repeat(" ", -charDiff))
		} else if charDiff > 0 {
			// longer than desired - trim title
			trimmedWidth := len(logTime) - charDiff
			if trimmedWidth < 4 {
				log.Errorf("Time too long, can't present time at all! : %s", logTime)
			} else {
				timeRow = fmt.Sprintf("| time: %s |", stringutil.MaxFirstCharsWithDots(logTime, trimmedWidth))
			}
		}
	}

	return fmt.Sprintf("%s\n%s\n%s\n%s\n%s", idRow, versionRow, collectionRow, toolkitRow, timeRow)
}