-
Notifications
You must be signed in to change notification settings - Fork 0
feat: ACI-3938 Activate xcode step #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
3597d0d
82b7762
b7ce728
31710dd
16308a2
c3a56cf
288f207
0a183f2
994fd96
2e26647
eb56c2b
24c581b
469da02
1cdf47d
5f114f0
1999c73
ea64f47
3e97864
c571783
ce8d5f4
825deae
b21605c
12043c3
ec248bc
76929c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| .bitrise* | ||
| .idea | ||
| .vscode | ||
| README.md.backup | ||
| _tmp/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,16 @@ | ||
| # bitrise-step-xcode-enable-compilation-cache | ||
| # Bitrise Build Cache Add-On for Xcode | ||
|
|
||
| Enables the Bitrise Build Cache Add-On for Xcode. | ||
|
|
||
| ## What this step does | ||
|
|
||
| - Configures the build using the Build Cache CLI so Bitrise Remote Build Cache is used. | ||
| - Ensures all subsequent Xcode builds in the workflow will read from the remote cache and push new entries. | ||
| - Adds an alias to `~/.zshrc` and `~/.bashrc`, making the CLI available in all subsequent steps. | ||
| - From this point on, all calls to `xcodebuild` are wrapped so the underlying Xcode command has compilation caching enabled. | ||
| - Saves analytical data (command, duration, cache information, environment) to Bitrise. The data is available on the Build cache page: https://app.bitrise.io/build-cache | ||
|
|
||
| ## Notes | ||
|
|
||
| - The alias persists only for subsequent steps in the current workflow run. | ||
| - Ensure your workflow uses `xcodebuild` (or compatible tooling) to benefit from the remote cache. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| format_version: "11" | ||
| default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git | ||
|
|
||
| workflows: | ||
| check: | ||
| steps: | ||
| - git::https://github.com/bitrise-steplib/steps-check.git: | ||
| inputs: | ||
| - skip_go_checks: "yes" | ||
| - workflow: lint | ||
|
|
||
| e2e: | ||
| steps: | ||
| - git::https://github.com/bitrise-steplib/steps-check.git: | ||
| inputs: | ||
| - workflow: e2e | ||
| - skip_go_checks: "yes" | ||
|
|
||
| generate_readme: | ||
| steps: | ||
| - git::https://github.com/bitrise-steplib/steps-readme-generator.git@main: { } | ||
|
|
||
| test_run_the_step: | ||
| steps: | ||
| - path::./: | ||
| run_if: true |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,95 @@ | ||||||
| format_version: "11" | ||||||
| default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git | ||||||
|
|
||||||
| app: | ||||||
| envs: | ||||||
| - TEST_APP_URL: https://github.com/bitrise-io/swift-package-deckofplayingcards | ||||||
| - BRANCH: main | ||||||
|
|
||||||
| workflows: | ||||||
| test_xcc: | ||||||
| after_run: | ||||||
| - _setup | ||||||
| - _run | ||||||
| - _check | ||||||
| _run: | ||||||
| steps: | ||||||
| - path::./: | ||||||
| title: Execute step | ||||||
| run_if: "true" | ||||||
| is_skippable: false | ||||||
| inputs: | ||||||
| - verbose: "true" | ||||||
| - change-workdir: | ||||||
| title: Switch working dir to _tmp | ||||||
| inputs: | ||||||
| - path: ./_tmp | ||||||
| - script: | ||||||
| title: build app | ||||||
| inputs: | ||||||
| - content: |- | ||||||
| #!/usr/bin/env bash | ||||||
| set -eo pipefail | ||||||
|
|
||||||
| if [ $(uname -s) != "Darwin" ]; then | ||||||
| echo "This workflow only works on macOS stack!" | ||||||
| exit 0 | ||||||
| fi | ||||||
|
|
||||||
| echo "Starting build..." | ||||||
| xcodebuild build -destination 'generic/platform=iOS' \ | ||||||
| -scheme DeckOfPlayingCards \ | ||||||
| CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO -showBuildTimingSummary 2> wrapper.log > xcodebuild.log | ||||||
|
|
||||||
| _check: | ||||||
| steps: | ||||||
| - script: | ||||||
| title: gather info | ||||||
| is_always_run: true | ||||||
| inputs: | ||||||
| - content: |- | ||||||
| set -exo pipefail | ||||||
|
|
||||||
| cp ~/.bitrise-xcelerate/config.json $BITRISE_DEPLOY_DIR || true | ||||||
| cp ~/.bitrise-xcelerate/proxy.err.log $BITRISE_DEPLOY_DIR || true | ||||||
| cp ~/.bitrise-xcelerate/proxy.out.log $BITRISE_DEPLOY_DIR || true | ||||||
| cp xcodebuild.log $BITRISE_DEPLOY_DIR || true | ||||||
| cp wrapper.log $BITRISE_DEPLOY_DIR || true | ||||||
|
|
||||||
| cat "$BITRISE_DEPLOY_DIR/wrapper.log" || true | ||||||
| head -n 20 $BITRISE_DEPLOY_DIR/xcodebuild.log || true | ||||||
| tail -n 20 $BITRISE_DEPLOY_DIR/xcodebuild.log || true | ||||||
| - deploy-to-bitrise-io: { } | ||||||
| - script: | ||||||
| title: Check if the step is working | ||||||
| inputs: | ||||||
| - content: |- | ||||||
| #!/bin/bash | ||||||
| set -ex | ||||||
|
|
||||||
| if [ $(uname -s) != "Darwin" ]; then | ||||||
| echo "This workflow only works on macOS stack!" | ||||||
| exit 0 | ||||||
| fi | ||||||
|
|
||||||
| # We need Xcode beta stack for checkign the cache and the current CI setup dos not suppor that. The CLI has comprehensive tests for this. | ||||||
| # Let's just check that the invocation is saved. | ||||||
|
|
||||||
| if grep -q "Invocation saved" wrapper.log; then | ||||||
| echo "xcodebuild invocation found in log" | ||||||
| else | ||||||
| echo "xcodebuild invocation NOT found in log" | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| _setup: | ||||||
| steps: | ||||||
| - script: | ||||||
| title: Delete _tmp dir | ||||||
| inputs: | ||||||
| - content: rm -rf _tmp | ||||||
| - git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git: | ||||||
| inputs: | ||||||
| - repository_url: $TEST_APP_URL | ||||||
| - clone_into_dir: ./_tmp | ||||||
| - main: $BRANCH | ||||||
|
||||||
| - main: $BRANCH | |
| - branch: $BRANCH |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
| "extends": [ | ||
| "local>bitrise-steplib/.github:renovate-config" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,69 @@ | ||||||
| #!/usr/bin/env bash | ||||||
|
|
||||||
| # 'read' has to be before 'set -e' | ||||||
| read -r -d '' UNAVAILABLE_MESSAGE << EOF_MSG | ||||||
| Bitrise Build Cache is not activated in this build. | ||||||
|
|
||||||
| You have added the **Activate Bitrise Build Cache for Xcode** add-on step to your workflow. | ||||||
|
|
||||||
| However, you don't have an activate Bitrise Build Cache Trial or Subscription for the current workspace yet. | ||||||
|
|
||||||
| You can activate a Trial at [app.bitrise.io/build-cache](https://app.bitrise.io/build-cache), | ||||||
| or contact us at [support@bitrise.io](mailto:support@bitrise.io) to activate it. | ||||||
| EOF_MSG | ||||||
|
|
||||||
| set -eo pipefail | ||||||
|
|
||||||
| echo "Checking whether Bitrise Build Cache is activated for this workspace ..." | ||||||
| if [ "$BITRISEIO_BUILD_CACHE_ENABLED" != "true" ]; then | ||||||
| printf "\n%s\n" "$UNAVAILABLE_MESSAGE" | ||||||
| set -x | ||||||
| bitrise plugin install https://github.com/bitrise-io/bitrise-plugins-annotations.git | ||||||
| bitrise :annotations annotate "$UNAVAILABLE_MESSAGE" --style error || { | ||||||
| echo "Failed to create annotation" | ||||||
| exit 3 | ||||||
| } | ||||||
| exit 2 | ||||||
| fi | ||||||
| echo "Bitrise Build Cache is activated in this workspace, configuring the build environment ..." | ||||||
|
|
||||||
| set -x | ||||||
|
|
||||||
| # download the Bitrise Build Cache CLI | ||||||
| export BITRISE_BUILD_CACHE_CLI_VERSION="v1.0.0" | ||||||
| curl --retry 5 -m 30 -sSfL 'https://raw.githubusercontent.com/bitrise-io/bitrise-build-cache-cli/main/install/installer.sh' | sh -s -- -b /tmp/bin -d $BITRISE_BUILD_CACHE_CLI_VERSION || true | ||||||
zsolt-marta-bitrise marked this conversation as resolved.
Show resolved
Hide resolved
zsolt-marta-bitrise marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| # Fall back to Artifact Registry if the download failed | ||||||
| if [ ! -f /tmp/bin/bitrise-build-cache ]; then | ||||||
| echo "Failed to download Bitrise Build Cache CLI, trying Artifact Registry ..." | ||||||
|
|
||||||
| version="${BITRISE_BUILD_CACHE_CLI_VERSION#v}" | ||||||
| os=$(uname -s | tr '[:upper:]' '[:lower:]') | ||||||
| arch=$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/') | ||||||
| package="bitrise-build-cache_${os}_${arch}.tar.gz" | ||||||
| filename="bitrise-build-cache_${version}_${os}_${arch}.tar.gz" | ||||||
|
|
||||||
| filepath="$package:$version:$filename" | ||||||
|
|
||||||
| echo "Downloading Bitrise Build Cache CLI from Artifact Registry: ${filepath}" | ||||||
|
|
||||||
| curl --retry 5 -m 60 -sSfL "https://artifactregistry.googleapis.com/download/v1/projects/ip-build-cache-prod/locations/us-central1/repositories/build-cache-cli-releases/files/${filepath}:download?alt=media" -o $package | ||||||
| tar -xzf "$package" | ||||||
| mkdir -p /tmp/bin | ||||||
| mv "bitrise-build-cache" /tmp/bin/bitrise-build-cache | ||||||
| rm -rf "$package" | ||||||
zsolt-marta-bitrise marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| fi | ||||||
|
|
||||||
| if [ ! -f /tmp/bin/bitrise-build-cache ]; then | ||||||
| echo "Failed to download Bitrise Build Cache CLI, exiting." | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| if [ "$verbose" != "true" ] && [ "$verbose" != "false" ]; then | ||||||
| echo "Parsing inputs failed: Verbose logging ($verbose) is not a valid option." | ||||||
| fi | ||||||
zsolt-marta-bitrise marked this conversation as resolved.
Show resolved
Hide resolved
zsolt-marta-bitrise marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| # run the Bitrise Build Cache CLI | ||||||
| /tmp/bin/bitrise-build-cache activate xcode --debug="$verbose" | ||||||
|
|
||||||
| alias xcodebuild='~/.bitrise-xcelerate/bin/bitrise-build-cache-cli xcelerate xcodebuild' | ||||||
zsolt-marta-bitrise marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| alias xcodebuild='~/.bitrise-xcelerate/bin/bitrise-build-cache-cli xcelerate xcodebuild' | |
| alias xcodebuild='/tmp/bin/bitrise-build-cache xcelerate xcodebuild' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| title: Build Cache for Xcode | ||
| summary: Activates Bitrise Remote Build Cache add-on for subsequent Xcode builds in the workflow | ||
| description: | | ||
| This Step enables Bitrise's Build Cache Add‑On for Xcode by configuring the environment with the Build Cache CLI. | ||
|
|
||
| After this Step runs, Xcode builds invoked via xcodebuild in subsequent workflow steps will automatically read from the remote cache and push new entries when applicable. | ||
|
|
||
| The Step adds an alias to ~/.zshrc and ~/.bashrc so the wrapper is available in all following steps; from that point all xcodebuild calls are wrapped to enable compilation caching. | ||
| Analytical data (command, duration, cache information, environment) is collected and sent to Bitrise and is available on the Build cache page: https://app.bitrise.io/build-cache | ||
| website: https://github.com/bitrise-steplib/bitrise-step-activate-xcode-remote-cache | ||
| source_code_url: https://github.com/bitrise-steplib/bitrise-step-activate-xcode-remote-cache | ||
| support_url: https://github.com/bitrise-steplib/bitrise-step-activate-xcode-remote-cache | ||
|
|
||
| type_tags: | ||
| - utility | ||
|
|
||
| run_if: .IsCI | ||
| is_skippable: true | ||
|
|
||
| toolkit: | ||
| bash: | ||
| entry_file: step.sh | ||
|
|
||
| inputs: | ||
| - verbose: "false" | ||
| opts: | ||
| title: Verbose logging | ||
| summary: Enable logging additional information for troubleshooting | ||
| is_required: true | ||
| value_options: | ||
| - "true" | ||
| - "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Bug
Invalid parameter name 'main' for bitrise-step-simple-git-clone step. The correct parameter name should be 'branch'.
🔄 Suggestion: