Skip to content

Commit

Permalink
fix: Fix/9345 bitrise cache failure (#9611)
Browse files Browse the repository at this point in the history
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

As suggested by the Bitrise team, the changes in the PR replaces both
the `save` and `restore` step with `deploy` and `pull`, which shares
intermediate files within pipelines instead of caching on a global
level. An extra step added post `pull` step was to copy the pulled files
into the directories that Detox uses to find the builds. Lastly, a small
update was made to the `brew install ccache` command to include the flag
`HOMEBREW_NO_DEPENDENTS_CHECK=1`, which should skip updating packages
that depend on`ccache`, therefore speeding up the step.

## **Related issues**

Fixes: #9345 

## **Manual testing steps**

- Run `pr_smoke_e2e_pipeline` and ensure that both iOS and Android are
building and testing successfully
- Smoke test will be run on this PR

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
N/A

### **Before**

<!-- [screenshots/recordings] -->
N/A

### **After**

<!-- [screenshots/recordings] -->
N/A

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
Cal-L authored May 10, 2024
1 parent 78dd5f1 commit 2648bb6
Showing 1 changed file with 47 additions and 31 deletions.
78 changes: 47 additions & 31 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -526,15 +526,10 @@ workflows:
- content: |-
#!/usr/bin/env bash
envman add --key SKIP_CCACHE_UPLOAD --value "true"
- restore-cache@2:
title: Restore build from cache
inputs:
- key: apk-cache-{{ .CommitHash }}
- script@1:
title: Run detox build
timeout: 1200
run_if: '{{ not (enveq "BITRISE_CACHE_HIT" "exact") }}'
is_always_run: false
is_always_run: true
inputs:
- content: |-
#!/usr/bin/env bash
Expand All @@ -556,11 +551,10 @@ workflows:
- key: '{{ getenv "CCACHE_KEY" }}'
- paths: |-
ccache
- save-cache@1:
title: Save build
- deploy-to-bitrise-io@2.2.3:
inputs:
- key: apk-cache-{{ .CommitHash }}
- paths: android/app/build/outputs
- pipeline_intermediate_files: android/app/build/outputs:INTERMEDIATE_ANDROID_BUILD_DIR
title: Save Android build
- save-cache@1:
title: Save node_modules
inputs:
Expand All @@ -578,10 +572,23 @@ workflows:
- notify_failure
steps:
- restore-gradle-cache@2: {}
- restore-cache@2:
title: Restore cache build
- pull-intermediate-files@1:
inputs:
- key: apk-cache-{{ .CommitHash }}
- artifact_sources: .*
title: Pull Android build
- script@1:
title: Copy Android build for Detox
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
# Create directories for Detox
mkdir -p "$BITRISE_SOURCE_DIR/android/app/build/outputs"
# Copy saved files for Detox usage
# INTERMEDIATE_ANDROID_BUILD_DIR is the cached directory from android_e2e_build's "Save Android build" step
cp -r "$INTERMEDIATE_ANDROID_BUILD_DIR" "$BITRISE_SOURCE_DIR/android/app/build"
- restore-cache@2:
title: Restore cache node_modules
inputs:
Expand Down Expand Up @@ -685,7 +692,7 @@ workflows:
inputs:
- content: |-
#!/usr/bin/env bash
brew install ccache
brew install ccache with HOMEBREW_NO_DEPENDENTS_CHECK=1
ln -s $(which ccache) /usr/local/bin/gcc
ln -s $(which ccache) /usr/local/bin/g++
ln -s $(which ccache) /usr/local/bin/cc
Expand All @@ -703,15 +710,10 @@ workflows:
- content: |-
#!/usr/bin/env bash
envman add --key SKIP_CCACHE_UPLOAD --value "true"
- restore-cache@2:
title: Restore build from cache
inputs:
- key: ipa-cache-{{ .CommitHash }}
- script@1:
title: Run detox build
timeout: 1200
run_if: '{{ not (enveq "BITRISE_CACHE_HIT" "exact") }}'
is_always_run: false
is_always_run: true
inputs:
- content: |-
#!/usr/bin/env bash
Expand All @@ -733,13 +735,12 @@ workflows:
- key: '{{ getenv "CCACHE_KEY" }}'
- paths: |-
ccache
- save-cache@1:
title: Save build
- deploy-to-bitrise-io@2.2.3:
inputs:
- key: ipa-cache-{{ .CommitHash }}
- paths: |-
ios/build/Build
../Library/Detox/ios
- pipeline_intermediate_files: |-
ios/build/Build:INTERMEDIATE_IOS_BUILD_DIR
../Library/Detox/ios:INTERMEDIATE_IOS_DETOX_DIR
title: Save iOS build
- save-cache@1:
title: Save node_modules
inputs:
Expand All @@ -752,10 +753,25 @@ workflows:
after_run:
- notify_failure
steps:
- restore-cache@2:
title: Restore cache build
- pull-intermediate-files@1:
inputs:
- artifact_sources: .*
title: Pull iOS build
- script@1:
title: Copy iOS build for Detox
inputs:
- key: ipa-cache-{{ .CommitHash }}
- content: |-
#!/usr/bin/env bash
set -ex
# Create directories for Detox
mkdir -p "$BITRISE_SOURCE_DIR/ios/build/Build"
mkdir -p "$BITRISE_SOURCE_DIR/../Library/Detox/ios"
# Copy saved files for Detox usage
# INTERMEDIATE_IOS_BUILD_DIR & INTERMEDIATE_IOS_DETOX_DIR are the cached directories by ios_e2e_build's "Save iOS build" step
cp -r "$INTERMEDIATE_IOS_BUILD_DIR" "$BITRISE_SOURCE_DIR/ios/build"
cp -r "$INTERMEDIATE_IOS_DETOX_DIR" "$BITRISE_SOURCE_DIR/../Library/Detox"
- restore-cocoapods-cache@2: {}
- restore-cache@2:
title: Restore cache node_modules
Expand All @@ -775,7 +791,9 @@ workflows:
brew tap wix/brew
title: Set Env Path for caching deps
- script@1:
title: Run detox test
timeout: 1200
is_always_run: false
inputs:
- content: |-
#!/usr/bin/env bash
Expand All @@ -795,8 +813,6 @@ workflows:
export METAMASK_ENVIRONMENT='local'
export METAMASK_BUILD_TYPE='main'
IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:ios:debug:run "$TEST_SUITE_FOLDER" --testNamePattern="$TEST_SUITE"
title: Run detox test
is_always_run: false
- custom-test-results-export@1:
is_always_run: true
is_skippable: false
Expand Down

0 comments on commit 2648bb6

Please sign in to comment.