-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moved existing code from https://github.com/bitrise-steplib/bitrise-step-activate-bazel-cache. Will be released under a new Step ID in the steplib. - This Github repo is now managed from Terraform (bitrise-io/bitrise-github-steps#139). - Added e2e test (the livegrep sample), that runs only on Ubuntu 20 at the moment, will have to fix this in a later PR. - The Step now uses the build cache CLI. - Removed the now unused BITRISE_CACHE_ENDPOINT output of the step. Inputs are not yet added.
- Loading branch information
Showing
6 changed files
with
203 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Bitrise Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 +1,44 @@ | ||
# bitrise-step-activate-build-cache-for-bazel | ||
# Activate Bitrise Build Cache for Bazel | ||
|
||
[![Step changelog](https://shields.io/github/v/release/bitrise-steplib/bitrise-step-activate-build-cache-for-bazel?include_prereleases&label=changelog&color=blueviolet)](https://github.com/bitrise-steplib/bitrise-step-activate-build-cache-for-bazel/releases) | ||
|
||
Activates Bitrise Remote Build Cache for subsequent Bazel builds in the workflows. | ||
|
||
|
||
<details> | ||
<summary>Description</summary> | ||
|
||
This Step activates Bitrise's remote build cache add-on for subsequent Bazel executions in the workflow. | ||
|
||
After this Step executes, Bazel builds will automatically read from the remote cache and push new entries if it's enabled. | ||
|
||
</details> | ||
|
||
## 🧩 Get started | ||
|
||
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). | ||
|
||
## ⚙️ Configuration | ||
|
||
<details> | ||
<summary>Inputs</summary> | ||
There are no inputs defined in this step | ||
</details> | ||
|
||
<details> | ||
<summary>Outputs</summary> | ||
There are no outputs defined in this step | ||
</details> | ||
|
||
## 🙋 Contributing | ||
|
||
We welcome [pull requests](https://github.com/bitrise-steplib/bitrise-step-activate-build-cache-for-bazel/pulls) and [issues](https://github.com/bitrise-steplib/bitrise-step-activate-build-cache-for-bazel/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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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 | ||
|
||
generate_readme: | ||
steps: | ||
- git::https://github.com/bitrise-steplib/steps-readme-generator.git: { } |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
format_version: "11" | ||
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git | ||
|
||
workflows: | ||
test_bazel_build: | ||
title: livegrep sample currently supports Ubuntu 20.04 only, skipping on other stacks | ||
steps: | ||
- bitrise-run: | ||
run_if: |- | ||
{{ or (enveq "BITRISEIO_STACK_ID" "linux-docker-android-20.04") (not .IsCI) }} | ||
is_skippable: true | ||
inputs: | ||
- workflow_id: utility_bazel_build | ||
- bitrise_config_path: ./e2e/bitrise.yml | ||
|
||
utility_bazel_build: | ||
envs: | ||
- TEST_APP_URL: https://github.com/bitrise-samples/livegrep.git | ||
- TEST_APP_BRANCH: main | ||
before_run: | ||
- _setup | ||
steps: | ||
- path::./: | ||
title: Test Current Step | ||
run_if: "true" | ||
is_skippable: false | ||
- change-workdir: | ||
title: Switch working dir to _tmp | ||
inputs: | ||
- path: ./_tmp | ||
- script: | ||
title: Run Bazel build | ||
deps: | ||
brew: | ||
- name: bazel | ||
inputs: | ||
- content: |- | ||
#!/bin/env bash | ||
if [ $(uname -s) = "Linux" ]; then | ||
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64 | ||
chmod +x bazelisk-linux-amd64 | ||
mv bazelisk-linux-amd64 /usr/local/bin/bazel | ||
fi | ||
bazel build --verbose_failures //... | ||
_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 | ||
- branch: $TEST_APP_BRANCH |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/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 Bazel** Step to your Workflow. | ||
However, you don't have an active 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 [[email protected]](mailto:[email protected]) to activate it. | ||
EOF_MSG | ||
|
||
set -eo pipefail | ||
|
||
echo "Checking whether Bitrise Build Cache is activated for the current 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="v0.9.0" | ||
curl --retry 5 -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 | ||
|
||
# run the Bitrise Build Cache CLI | ||
/tmp/bin/bitrise-build-cache enable-for bazel | ||
|
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
title: |- | ||
Activate Bitrise Build Cache for Bazel | ||
summary: | | ||
Activates Bitrise Remote Build Cache for subsequent Bazel builds in the workflows. | ||
description: | | ||
This Step activates Bitrise's remote build cache add-on for subsequent Bazel executions in the workflow. | ||
After this Step executes, Bazel builds will automatically read from the remote cache and push new entries if it's enabled. | ||
website: https://github.com/bitrise-steplib/bitrise-step-activate-build-cache-for-bazel | ||
source_code_url: https://github.com/bitrise-steplib/bitrise-step-activate-build-cache-for-bazel | ||
support_url: https://github.com/bitrise-steplib/bitrise-step-activate-build-cache-for-bazel/issues | ||
|
||
type_tags: | ||
- utility | ||
|
||
run_if: .IsCI | ||
is_skippable: true | ||
|
||
toolkit: | ||
bash: | ||
entry_file: step.sh | ||
|
||
inputs: [] |