-
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.
feat: ACI-2928 Create restore Gradle step (#1)
- Loading branch information
1 parent
053d20c
commit 4dfd56f
Showing
7 changed files
with
216 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
test |
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,35 @@ | ||
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 | ||
|
||
audit-this-step: | ||
steps: | ||
- script: | ||
inputs: | ||
- content: |- | ||
#!/bin/bash | ||
set -ex | ||
stepman audit --step-yml ./step.yml | ||
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 |
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 @@ | ||
test |
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,77 @@ | ||
format_version: "11" | ||
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git | ||
|
||
app: | ||
envs: | ||
- CACHE_KEY: gradle-configuration-cache-e2e-test | ||
|
||
workflows: | ||
test_config_cache: | ||
after_run: | ||
- _setup | ||
- _run | ||
- _check | ||
|
||
_run: | ||
steps: | ||
- path::./: | ||
title: Execute step | ||
run_if: "true" | ||
is_skippable: false | ||
inputs: | ||
- verbose: true | ||
- key_override: $CACHE_KEY | ||
|
||
_check: | ||
steps: | ||
- script: | ||
title: Check config cache folder | ||
inputs: | ||
- content: | | ||
#!/usr/bin/env bash | ||
set -ex | ||
config_cache_dir="./.gradle/configuration-cache" | ||
if [ -d "$config_cache_dir" ]; then | ||
if [ "$(ls -A "$config_cache_dir")" ]; then | ||
echo "Config cache exists and is not empty" | ||
else | ||
echo "Config cache folder exists but empty" | ||
exit 1 | ||
fi | ||
else | ||
echo "Config cache folder does not exist" | ||
exit 1 | ||
fi | ||
_setup: | ||
steps: | ||
- script: | ||
title: Setup directory | ||
inputs: | ||
- content: |- | ||
#!/bin/bash | ||
set -ex | ||
rm -rf _tmp | ||
mkdir -p _tmp | ||
cp -r ./e2e/.gradle ./_tmp/ | ||
- change-workdir: | ||
title: Switch working dir to _tmp | ||
inputs: | ||
- path: ./_tmp | ||
# - git::https://github.com/bitrise-steplib/bitrise-step-save-gradle-configuration-cache.git@main: TODO after both steps have been merged | ||
# title: Save cache | ||
# is_skippable: false | ||
# inputs: | ||
# - verbose: true | ||
# - key_override: $CACHE_KEY | ||
# - script: | ||
# title: Clean directory | ||
# inputs: | ||
# - content: |- | ||
# #!/bin/bash | ||
# set -ex | ||
# | ||
# rm -rf .gradle |
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,6 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"local>bitrise-steplib/.github:renovate-config" | ||
] | ||
} |
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,44 @@ | ||
#!/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. | ||
It seems 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" | ||
|
||
set -x | ||
|
||
# download the Bitrise Build Cache CLI | ||
export BITRISE_BUILD_CACHE_CLI_VERSION=${BITRISE_BUILD_CACHE_CLI_VERSION:="v0.15.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 | ||
|
||
cmd="/tmp/bin/bitrise-build-cache restore-gradle-configuration-cache" | ||
|
||
if [ "$verbose" = "true" ]; then | ||
cmd="$cmd -d" | ||
fi | ||
|
||
if [ -n "$key_override" ]; then | ||
cmd="$cmd --key $key_override" | ||
fi | ||
|
||
$cmd |
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,52 @@ | ||
title: Restore Gradle configuration cache | ||
summary: Restores the Gradle configuration cache folder used by Gradle. Uses the Bitrise Build Cache infrastructure. | ||
description: | | ||
This step restores the Gradle configuration cache folder from the Bitrise Build Cache to speed up future builds. | ||
For more information on how configuration caching works, refer to the [Gradle user guide](https://docs.gradle.org/current/userguide/configuration_cache.html). | ||
**IMPORTANT NOTES:** | ||
- You must have an active Bitrise Build Cache Trial or Subscription for your workspace to use this step. | ||
- You also need to set up the encryption key `GRADLE_ENCRYPTION_KEY` in Bitrise Secrets by using the result from running `openssl rand -base64 16`. | ||
- Setting the encryption key is supported only from Gradle version 8.6 onwards, so your project must be using Gradle 8.6 or higher. | ||
website: https://github.com/bitrise-steplib/bitrise-step-restore-gradle-configuration-cache | ||
source_code_url: https://github.com/bitrise-steplib/bitrise-step-restore-gradle-configuration-cache | ||
support_url: https://github.com/bitrise-steplib/bitrise-step-restore-gradle-configuration-cache | ||
|
||
project_type_tags: | ||
- android | ||
- react-native | ||
- flutter | ||
|
||
type_tags: | ||
- utility | ||
|
||
run_if: .IsCI | ||
is_skippable: true | ||
|
||
toolkit: | ||
bash: | ||
entry_file: step.sh | ||
|
||
deps: | ||
brew: | ||
- name: zstd | ||
|
||
inputs: | ||
- key_override: | ||
opts: | ||
title: Cache key override | ||
summary: Override key used for restoring from the cache. By default the app slug and branch is used | ||
description: |- | ||
Custom override key used to restore the cache from a previously saved entry (by the `Save Gradle configuration cache` step). | ||
If not specified, by default a key is generated from the app slug and the current branch. If not specified, the contents can also be restored from a fallback key consisting only of the app slug. This helps reduce cache misses on new feature branches. | ||
is_required: false | ||
- verbose: "false" | ||
opts: | ||
title: Verbose logging | ||
summary: Enable logging additional information for troubleshooting | ||
is_required: true | ||
value_options: | ||
- "true" | ||
- "false" |