-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into renovate/configure
- Loading branch information
Showing
3 changed files
with
238 additions
and
218 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,92 +1,89 @@ | ||
# iOS Build for testing | ||
# Xcode Build for testing for iOS | ||
|
||
Build xctestrun bundle for your project. | ||
[![Step changelog](https://shields.io/github/v/release/bitrise-steplib/steps-xcode-build-for-test?include_prereleases&label=changelog&color=blueviolet)](https://github.com/bitrise-steplib/steps-xcode-build-for-test/releases) | ||
|
||
## How to use this Step | ||
Performs xcodebuild's build-for-testing action | ||
|
||
Can be run directly with the [bitrise CLI](https://github.com/bitrise-io/bitrise), | ||
just `git clone` this repository, `cd` into it's folder in your Terminal/Command Line | ||
and call `bitrise run test`. | ||
<details> | ||
<summary>Description</summary> | ||
|
||
*Check the `bitrise.yml` file for required inputs which have to be | ||
added to your `.bitrise.secrets.yml` file!* | ||
The Step runs Xcode's `xcodebuild` command with the `build-for-testing` option. This builds your app for testing and also creates an `.xctestrun` file. | ||
|
||
Step by step: | ||
### Configuring the Step | ||
|
||
1. Open up your Terminal / Command Line | ||
2. `git clone` the repository | ||
3. `cd` into the directory of the step (the one you just `git clone`d) | ||
5. Create a `.bitrise.secrets.yml` file in the same directory of `bitrise.yml` | ||
(the `.bitrise.secrets.yml` is a git ignored file, you can store your secrets in it) | ||
6. Check the `bitrise.yml` file for any secret you should set in `.bitrise.secrets.yml` | ||
* Best practice is to mark these options with something like `# define these in your .bitrise.secrets.yml`, in the `app:envs` section. | ||
7. Once you have all the required secret parameters in your `.bitrise.secrets.yml` you can just run this step with the [bitrise CLI](https://github.com/bitrise-io/bitrise): `bitrise run test` | ||
At a minimum, the Step needs valid values for three inputs: | ||
|
||
An example `.bitrise.secrets.yml` file: | ||
- **Project (or Workspace) path**: This is the path to the `.xcodeproj` or `.xcworkspace` file. In most cases, leave it on the default value. | ||
- **Scheme name**: The name of your Xcode scheme. By default, the Step will use the scheme that was set when you added the app on Bitrise. | ||
- **Device destination**: The device and platform type to build the tests for. For available values call, `man xcodebuild` and check the Destinations section. | ||
We also recommend checking out our [System reports page](https://github.com/bitrise-io/bitrise.io/tree/master/system_reports) on GitHub: you can check out the available, pre-installed simulators and other tools. | ||
|
||
``` | ||
envs: | ||
- A_SECRET_PARAM_ONE: the value for secret one | ||
- A_SECRET_PARAM_TWO: the value for secret two | ||
``` | ||
Optionally, you can define the configuration to use in the **Configuration name** input. Normally, the scheme defines the configuration type, such as **debug** or **release**. | ||
|
||
## How to create your own step | ||
The Step can also cache your Swift PM dependencies. To enable caching, make sure the **Enable caching of Swift Package Manager packages** input is set to `swift_packages`. | ||
|
||
1. Create a new git repository for your step (**don't fork** the *step template*, create a *new* repository) | ||
2. Copy the [step template](https://github.com/bitrise-steplib/step-template) files into your repository | ||
3. Fill the `step.sh` with your functionality | ||
4. Wire out your inputs to `step.yml` (`inputs` section) | ||
5. Fill out the other parts of the `step.yml` too | ||
6. Provide test values for the inputs in the `bitrise.yml` | ||
7. Run your step with `bitrise run test` - if it works, you're ready | ||
### Troubleshooting | ||
|
||
__For Step development guidelines & best practices__ check this documentation: [https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md](https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md). | ||
In the **Debug** option group, you can: | ||
|
||
**NOTE:** | ||
- Add additional flags to the xcodebuild command. | ||
- Enable verbose logging. | ||
- Change the output directory path and the output tool. | ||
|
||
If you want to use your step in your project's `bitrise.yml`: | ||
### Useful links | ||
|
||
1. git push the step into it's repository | ||
2. reference it in your `bitrise.yml` with the `git::PUBLIC-GIT-CLONE-URL@BRANCH` step reference style: | ||
- [Running Xcode tests](https://devcenter.bitrise.io/testing/running-xcode-tests/) | ||
- [Building from the Command Line with Xcode](https://developer.apple.com/library/archive/technotes/tn2339/_index.html) | ||
|
||
``` | ||
- git::https://github.com/user/my-step.git@branch: | ||
title: My step | ||
inputs: | ||
- my_input_1: "my value 1" | ||
- my_input_2: "my value 2" | ||
``` | ||
### Related Steps | ||
|
||
You can find more examples of step reference styles | ||
in the [bitrise CLI repository](https://github.com/bitrise-io/bitrise/blob/master/_examples/tutorials/steps-and-workflows/bitrise.yml#L65). | ||
- [Xcode Test for iOS](https://www.bitrise.io/integrations/steps/xcode-test) | ||
- [Xcode Analyze](https://www.bitrise.io/integrations/steps/xcode-analyze) | ||
</details> | ||
|
||
## How to contribute to this Step | ||
## 🧩 Get started | ||
|
||
1. Fork this repository | ||
2. `git clone` it | ||
3. Create a branch you'll work on | ||
4. To use/test the step just follow the **How to use this Step** section | ||
5. Do the changes you want to | ||
6. Run/test the step before sending your contribution | ||
* You can also test the step in your `bitrise` project, either on your Mac or on [bitrise.io](https://www.bitrise.io) | ||
* You just have to replace the step ID in your project's `bitrise.yml` with either a relative path, or with a git URL format | ||
* (relative) path format: instead of `- original-step-id:` use `- path::./relative/path/of/script/on/your/Mac:` | ||
* direct git URL format: instead of `- original-step-id:` use `- git::https://github.com/user/step.git@branch:` | ||
* You can find more example of alternative step referencing at: https://github.com/bitrise-io/bitrise/blob/master/_examples/tutorials/steps-and-workflows/bitrise.yml | ||
7. Once you're done just commit your changes & create a Pull Request | ||
Add this step directly to your workflow in the [Bitrise Workflow Editor](https://devcenter.bitrise.io/steps-and-workflows/steps-and-workflows-index/). | ||
|
||
You can also run this step directly with [Bitrise CLI](https://github.com/bitrise-io/bitrise). | ||
|
||
## Share your own Step | ||
## ⚙️ Configuration | ||
|
||
You can share your Step or step version with the [bitrise CLI](https://github.com/bitrise-io/bitrise). If you use the `bitrise.yml` included in this repository, all you have to do is: | ||
<details> | ||
<summary>Inputs</summary> | ||
|
||
1. In your Terminal / Command Line `cd` into this directory (where the `bitrise.yml` of the step is located) | ||
1. Run: `bitrise run test` to test the step | ||
1. Run: `bitrise run audit-this-step` to audit the `step.yml` | ||
1. Check the `share-this-step` workflow in the `bitrise.yml`, and fill out the | ||
`envs` if you haven't done so already (don't forget to bump the version number if this is an update | ||
of your step!) | ||
1. Then run: `bitrise run share-this-step` to share the step (version) you specified in the `envs` | ||
1. Send the Pull Request, as described in the logs of `bitrise run share-this-step` | ||
| Key | Description | Flags | Default | | ||
| --- | --- | --- | --- | | ||
| `project_path` | Xcode Project (`.xcodeproj`) or Workspace (`.xcworkspace`) path. The input value sets xcodebuild's `-project` or `-workspace` option. | required | `$BITRISE_PROJECT_PATH` | | ||
| `scheme` | Xcode Scheme name. The input value sets xcodebuild's `-scheme` option. | required | `$BITRISE_SCHEME` | | ||
| `configuration` | Xcode Build Configuration. If not specified, the default Build Configuration will be used. The input value sets xcodebuild's `-configuration` option. | required | `Debug` | | ||
| `destination` | Destination specifier describes the device to use as a destination. The input value sets xcodebuild's `-destination` option. | required | `generic/platform=iOS` | | ||
| `xcconfig_content` | Build settings to override the project's build settings. Build settings must be separated by newline character (`\n`). Example: ``` COMPILER_INDEX_STORE_ENABLE = NO ONLY_ACTIVE_ARCH[config=Debug][sdk=*][arch=*] = YES ``` The input value sets xcodebuild's `-xcconfig` option. | | `COMPILER_INDEX_STORE_ENABLE = NO` | | ||
| `xcodebuild_options` | Additional options to be added to the executed xcodebuild command. | | | | ||
| `log_formatter` | Defines how xcodebuild command's log is formatted. Available options: - `xcpretty`: The xcodebuild command’s output will be prettified by xcpretty. - `xcodebuild`: Only the last 20 lines of raw xcodebuild output will be visible in the build log. The raw xcodebuild log will be exported in both cases. | required | `xcpretty` | | ||
| `output_dir` | This directory will contain the generated artifacts. | required | `$BITRISE_DEPLOY_DIR` | | ||
| `cache_level` | Defines what cache content should be automatically collected. Available options: - `none`: Disable collecting cache content. - `swift_packages`: Collect Swift PM packages added to the Xcode project. | required | `swift_packages` | | ||
| `verbose_log` | If this input is set, the Step will print additional logs for debugging. | required | `no` | | ||
</details> | ||
|
||
That's all ;) | ||
<details> | ||
<summary>Outputs</summary> | ||
|
||
| Environment Variable | Description | | ||
| --- | --- | | ||
| `BITRISE_TEST_DIR_PATH` | | | ||
| `BITRISE_XCTESTRUN_FILE_PATH` | | | ||
| `BITRISE_TEST_BUNDLE_ZIP_PATH` | | | ||
| `BITRISE_XCODE_RAW_RESULT_TEXT_PATH` | This is the path of the raw build results log file. | | ||
</details> | ||
|
||
## 🙋 Contributing | ||
|
||
We welcome [pull requests](https://github.com/bitrise-steplib/steps-xcode-build-for-test/pulls) and [issues](https://github.com/bitrise-steplib/steps-xcode-build-for-test/issues) against this repository. | ||
|
||
For pull requests, work on your changes in a forked repository and use the Bitrise CLI to [run step tests locally](https://devcenter.bitrise.io/bitrise-cli/run-your-first-build/). | ||
|
||
Learn more about developing steps: | ||
|
||
- [Create your own step](https://devcenter.bitrise.io/contributors/create-your-own-step/) | ||
- [Testing your Step](https://devcenter.bitrise.io/contributors/testing-and-versioning-your-steps/) |
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,166 +1,42 @@ | ||
format_version: 6 | ||
format_version: "11" | ||
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git | ||
|
||
app: | ||
envs: | ||
- ORIG_BITRISE_SOURCE_DIR: $BITRISE_SOURCE_DIR | ||
|
||
workflows: | ||
test: | ||
before_run: | ||
- audit-this-step | ||
- go-tests | ||
after_run: | ||
- test_objc_all | ||
- test_swiftpm | ||
|
||
test_swiftpm: | ||
envs: | ||
- SAMPLE_APP_URL: https://github.com/bitrise-io/sample-apps-ios-swiftpm.git | ||
- SAMPLE_APP_BRANCH: codesign-update | ||
- PROJECT_PATH: sample-swiftpm.xcodeproj | ||
- SCHEME: "sample swiftpm" | ||
after_run: | ||
- _checkout | ||
- _run_and_test_output | ||
|
||
test_objc_all: | ||
envs: | ||
- SAMPLE_APP_URL: https://github.com/bitrise-samples/sample-apps-ios-simple-objc-with-uitest.git | ||
- SAMPLE_APP_BRANCH: renamed-scheme | ||
- PROJECT_PATH: ./ios-simple-objc/ios-simple-objc.xcodeproj | ||
after_run: | ||
- _checkout | ||
- test_build_output_renamed | ||
- test_build_output_spaces | ||
- test_build_output_renamed_custom_build_options | ||
- test_build_output_spaces_custom_build_options | ||
|
||
test_build_output_renamed: | ||
envs: | ||
- SCHEME: "renamed_scheme" | ||
- XCODE_BUILD_OPTIONS: "" | ||
- PROJECT_PATH: $PROJECT_PATH | ||
after_run: | ||
- _run_and_test_output | ||
|
||
test_build_output_spaces: | ||
envs: | ||
- SCHEME: "Scheme with spaces" | ||
- XCODE_BUILD_OPTIONS: "" | ||
- PROJECT_PATH: $PROJECT_PATH | ||
after_run: | ||
- _run_and_test_output | ||
|
||
test_build_output_renamed_custom_build_options: | ||
envs: | ||
- SCHEME: "renamed_scheme" | ||
- XCODE_BUILD_OPTIONS: "-derivedDataPath ./ddata -destination generic/platform=iOS" | ||
- PROJECT_PATH: $PROJECT_PATH | ||
after_run: | ||
- _run_and_test_output | ||
|
||
test_build_output_spaces_custom_build_options: | ||
envs: | ||
- SCHEME: "Scheme with spaces" | ||
- XCODE_BUILD_OPTIONS: "-derivedDataPath ./ddata -destination generic/platform=iOS" | ||
- PROJECT_PATH: $PROJECT_PATH | ||
after_run: | ||
- _run_and_test_output | ||
check: | ||
steps: | ||
- git::https://github.com/bitrise-steplib/steps-check.git: {} | ||
|
||
_run_and_test_output: | ||
envs: | ||
- SCHEME: $SCHEME | ||
- PROJECT_PATH: $PROJECT_PATH | ||
e2e: | ||
steps: | ||
- path::./: | ||
title: Step Test | ||
run_if: true | ||
- git::https://github.com/bitrise-steplib/steps-check.git: | ||
inputs: | ||
- project_path: $PROJECT_PATH | ||
- scheme: $SCHEME | ||
- output_tool: xcodebuild | ||
- xcodebuild_options: $XCODE_BUILD_OPTIONS | ||
after_run: | ||
- _output_test | ||
- workflow: e2e | ||
|
||
_checkout: | ||
sample: | ||
envs: | ||
- TEST_APP_URL: https://github.com/bitrise-samples/sample-apps-ios-simple-objc-with-uitest.git | ||
- TEST_APP_BRANCH: renamed-scheme | ||
- BITRISE_PROJECT_PATH: ios-simple-objc/ios-simple-objc.xcodeproj | ||
- BITRISE_SCHEME: renamed_scheme | ||
steps: | ||
- script: | ||
inputs: | ||
- content: |- | ||
#!/bin/bash | ||
#!/bin/env bash | ||
set -ex | ||
rm -rf "$ORIG_BITRISE_SOURCE_DIR/_tmp" | ||
mkdir -p "$ORIG_BITRISE_SOURCE_DIR/_tmp" | ||
- change-workdir: | ||
title: Switch working dir to _tmp dir | ||
run_if: true | ||
inputs: | ||
- path: "$ORIG_BITRISE_SOURCE_DIR/_tmp" | ||
- is_create_path: true | ||
rm -rf "./_tmp" | ||
- git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git: | ||
inputs: | ||
- repository_url: $SAMPLE_APP_URL | ||
- clone_into_dir: . | ||
- branch: $SAMPLE_APP_BRANCH | ||
- commit: $SAMPLE_APP_COMMIT | ||
- certificate-and-profile-installer: | ||
|
||
_output_test: | ||
steps: | ||
- script: | ||
title: Output check | ||
inputs: | ||
- content: |- | ||
#!/bin/bash | ||
set -e | ||
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 | ||
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_XCTESTRUN_FILE_PATH" =~ "$BITRISE_DEPLOY_DIR/${SCHEME}_iphoneos[0-9]{2}.[0-9]{1,2}-arm64e.xctestrun" ]] ; then | ||
echo "BITRISE_XCTESTRUN_FILE_PATH (\"$BITRISE_XCTESTRUN_FILE_PATH\") should be: \"$BITRISE_DEPLOY_DIR/${SCHEME}_iphoneos{{sdk-version}}-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: | ||
- go-list: | ||
- golint: | ||
- errcheck: | ||
- go-test: | ||
|
||
dep-update: | ||
title: Dep update | ||
description: | | ||
Used for updating bitrise dependencies with dep | ||
steps: | ||
- script: | ||
title: Dependency update | ||
- repository_url: $TEST_APP_URL | ||
- branch: $TEST_APP_BRANCH | ||
- clone_into_dir: ./_tmp | ||
- path::./: | ||
title: Step Test | ||
inputs: | ||
- content: |- | ||
#!/bin/bash | ||
set -ex | ||
go get -u -v github.com/golang/dep/cmd/dep | ||
dep ensure -v | ||
dep ensure -v -update | ||
# Inputs with non-default value or using environment variables | ||
- project_path: ./_tmp/$BITRISE_PROJECT_PATH | ||
- scheme: $BITRISE_SCHEME | ||
|
||
# ---------------------------------------------------------------- | ||
# --- workflows to Share this step into a Step Library | ||
audit-this-step: | ||
generate_readme: | ||
steps: | ||
- script: | ||
inputs: | ||
- content: |- | ||
#!/bin/bash | ||
set -ex | ||
stepman audit --step-yml ./step.yml | ||
- git::https://github.com/bitrise-steplib/steps-readme-generator.git@main: {} |
Oops, something went wrong.