Skip to content

Commit

Permalink
export BITRISE_TEST_DIR_PATH and BITRISE_XCTESTRUN_FILE_PATH (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
godrei authored Oct 9, 2018
1 parent 33dd162 commit c8d0d90
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 10 deletions.
7 changes: 5 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,19 @@ workflows:
if [[ "$BITRISE_DEPLOY_DIR/testbundle.zip" != "$BITRISE_TEST_BUNDLE_ZIP_PATH" ]] ; then
echo "BITRISE_TEST_BUNDLE_ZIP_PATH (\"$BITRISE_TEST_BUNDLE_ZIP_PATH\") should be: \"$BITRISE_DEPLOY_DIR/testbundle.zip\""
exit 1
else
echo "BITRISE_APP_DIR_PATH: $BITRISE_APP_DIR_PATH"
fi
if [[ "$BITRISE_DEPLOY_DIR/Debug-iphoneos" != "$BITRISE_TEST_DIR_PATH" ]] ; then
echo "BITRISE_TEST_DIR_PATH (\"$BITRISE_TEST_DIR_PATH\") should be: \"$BITRISE_DEPLOY_DIR/Debug-iphoneos\""
exit 1
fi
if [[ "$BITRISE_DEPLOY_DIR/ios-simple-objc_iphoneos12.0-arm64e.xctestrun" != "$BITRISE_XCTESTRUN_FILE_PATH" ]] ; then
echo "BITRISE_XCTESTRUN_FILE_PATH (\"$BITRISE_XCTESTRUN_FILE_PATH\") should be: \"$BITRISE_DEPLOY_DIR/ios-simple-objc_iphoneos12.0-arm64e.xctestrun\""
exit 1
fi
echo "BITRISE_TEST_BUNDLE_ZIP_PATH: $BITRISE_TEST_BUNDLE_ZIP_PATH"
echo "BITRISE_TEST_DIR_PATH: $BITRISE_TEST_DIR_PATH"
echo "BITRISE_XCTESTRUN_FILE_PATH: $BITRISE_XCTESTRUN_FILE_PATH"
go-tests:
steps:
Expand Down
23 changes: 18 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/bitrise-io/go-utils/pathutil"
"github.com/bitrise-io/go-utils/stringutil"
"github.com/bitrise-io/steps-xcode-archive/utils"
"github.com/bitrise-tools/go-steputils/output"
"github.com/bitrise-tools/go-steputils/stepconf"
"github.com/bitrise-tools/go-steputils/tools"
"github.com/bitrise-tools/go-xcode/xcodebuild"
Expand Down Expand Up @@ -264,21 +265,33 @@ The log file is stored in $BITRISE_DEPLOY_DIR, and its full path is available in
}
log.Printf("Built test directory: %s", builtTestDir)

testBundleZipPath := filepath.Join(absOutputDir, "testbundle.zip")
zipCmd := command.New("zip", "-r", testBundleZipPath, filepath.Base(builtTestDir), filepath.Base(xctestrunPth)).SetDir(symRoot)
outputTestBundleZipPath := filepath.Join(absOutputDir, "testbundle.zip")
zipCmd := command.New("zip", "-r", outputTestBundleZipPath, filepath.Base(builtTestDir), filepath.Base(xctestrunPth)).SetDir(symRoot)
if out, err := zipCmd.RunAndReturnTrimmedCombinedOutput(); err != nil {
if errorutil.IsExitStatusError(err) {
failf("%s failed: %s", zipCmd.PrintableCommandArgs(), out)
} else {
failf("%s failed: %s", zipCmd.PrintableCommandArgs(), err)
}
}
log.Printf("Zipped test bundle: %s", testBundleZipPath)
log.Printf("Zipped test bundle: %s", outputTestBundleZipPath)

if err := tools.ExportEnvironmentWithEnvman("BITRISE_TEST_BUNDLE_ZIP_PATH", testBundleZipPath); err != nil {
outputXCTestrunPth := filepath.Join(absOutputDir, filepath.Base(xctestrunPth))
if err := output.ExportOutputFile(xctestrunPth, outputXCTestrunPth, "BITRISE_XCTESTRUN_FILE_PATH"); err != nil {
failf("Failed to export BITRISE_XCTESTRUN_FILE_PATH: %s", err)
}
log.Donef("The built xctestrun file is available in BITRISE_XCTESTRUN_FILE_PATH env: %s", outputXCTestrunPth)

outputTestDirPath := filepath.Join(absOutputDir, filepath.Base(builtTestDir))
if err := output.ExportOutputDir(builtTestDir, outputTestDirPath, "BITRISE_TEST_DIR_PATH"); err != nil {
failf("Failed to export BITRISE_TEST_DIR_PATH: %s", err)
}
log.Donef("The built test directory is available in BITRISE_TEST_DIR_PATH env: %s", outputTestDirPath)

if err := tools.ExportEnvironmentWithEnvman("BITRISE_TEST_BUNDLE_ZIP_PATH", outputTestBundleZipPath); err != nil {
failf("Failed to export BITRISE_TEST_BUNDLE_ZIP_PATH: %s", err)
}
log.Donef("The zipped test bundle is available in BITRISE_TEST_BUNDLE_ZIP_PATH env")
log.Donef("The zipped test bundle is available in BITRISE_TEST_BUNDLE_ZIP_PATH env: %s", outputTestBundleZipPath)
}

func failf(format string, v ...interface{}) {
Expand Down
8 changes: 7 additions & 1 deletion step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,15 @@ inputs:
- "no"

outputs:
- BITRISE_TEST_DIR_PATH:
opts:
title: "Path to the built test directory (example: PROJECT_DERIVED_DATA/Build/Products/Debug-iphoneos)"
- BITRISE_XCTESTRUN_FILE_PATH:
opts:
title: "Path to the built xctestrun file (example: PROJECT_DERIVED_DATA/Build/Products/ios-simple-objc_iphoneos12.0-arm64e.xctestrun)"
- BITRISE_TEST_BUNDLE_ZIP_PATH:
opts:
title: The generated *.xctestrun and app bundle zip ready for testing
title: "The built test directory and the built xctestrun file compressed as a single zip"
- BITRISE_XCODE_BUILD_RAW_RESULT_TEXT_PATH:
opts:
title: The full, raw build output file path
Expand Down
71 changes: 71 additions & 0 deletions vendor/github.com/bitrise-io/go-utils/ziputil/ziputil.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions vendor/github.com/bitrise-tools/go-steputils/output/output.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c8d0d90

Please sign in to comment.