Skip to content

Commit

Permalink
another refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobar79 committed Aug 28, 2024
1 parent 289c0c0 commit b1f30f5
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 30 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/macstadium-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: iOS e2e tests

on: [pull_request, workflow_dispatch]

jobs:
# Job to install dependencies
build:
runs-on: ["self-hosted"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up github keys
run: git config core.sshCommand "ssh -i ~/.ssh/id_ed25519 -F /dev/null"

- name: Clean iOS app
run: yarn clean:ios > /dev/null 2>&1 || true

- name: Set up ENV vars & scripts
env:
CI_SCRIPTS: ${{ secrets.CI_SCRIPTS }}
run: |
source ~/.zshrc
git clone [email protected]:rainbow-me/rainbow-env.git
mv rainbow-env/dotenv .env && rm -rf rainbow-env
eval $CI_SCRIPTS
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- name: Cache Yarn dependencies
uses: actions/cache@v4
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
.yarn/cache
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
yarn install && yarn setup
- name: Upload Yarn cache
uses: actions/upload-artifact@v3
with:
name: yarn-cache
path: |
.yarn/cache
.yarn/install-state.gz
- name: Download Yarn cache
uses: actions/download-artifact@v3
with:
name: yarn-cache
path: .yarn

- name: Version debug
run: |
npx react-native info
- name: Install pods
run: yarn install-bundle && yarn install-pods

# TOPHAT SIM
- name: Build the app in release mode for simulator
run: |
sed -i'' -e "s/IS_TESTING=true/IS_TESTING=false/" .env && rm -f .env-e
xcodebuild -workspace ios/Rainbow.xcworkspace -scheme Rainbow -configuration Release -sdk iphonesimulator -derivedDataPath ios/build
- name: Build the app in release mode for iOS devices
run: |
cd ios && bundle exec fastlane ios build_device
- name: Upload builds to AWS S3
env:
AWS_BUCKET: rainbow-app-team-production
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
COMMIT_HASH: ${{ github.sha }}
run: |
APP_DIR=$(find . -name "*.app" | head -n 1)
cd $APP_DIR && zip -r ../App.zip . && cd ..
aws s3 cp "App.zip" "s3://${AWS_BUCKET}/${BRANCH_NAME}/${COMMIT_HASH}.app.zip"
IPA_PATH=$(find . -name "*.ipa" | head -n 1)
aws s3 cp $IPA_PATH "s3://${AWS_BUCKET}/${BRANCH_NAME}/${COMMIT_HASH}.ipa"
- name: Post comment to PR
if: github.event_name == 'pull_request'
env:
TOPHAT_GITHUB_TOKEN: ${{ secrets.TOPHAT_GITHUB_TOKEN }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
COMMIT_HASH: ${{ github.sha }}
run: |
COMMENT="Launch in [simulator](http://localhost:29070/install/ios?virtual=https://app-team.p.rainbow.me/${BRANCH_NAME}/${COMMIT_HASH}.app.zip) or [device](http://localhost:29070/install/ios?physical=https://app-team.p.rainbow.me/${BRANCH_NAME}/${COMMIT_HASH}.ipa) for ${COMMIT_HASH}"
curl -s -H "Authorization: token $TOPHAT_GITHUB_TOKEN" -X POST \
-d "{\"body\":\"$COMMENT\"}" \
"${{ github.event.pull_request.comments_url }}"
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
run: yarn test

# iOS build and e2e tests
ios:
e2e-ios:
runs-on: ["self-hosted"]
needs: install-deps
steps:
Expand All @@ -100,36 +100,11 @@ jobs:
- name: Install pods
run: yarn install-bundle && yarn install-pods

- name: Build the app in release mode
run: xcodebuild -workspace ios/Rainbow.xcworkspace -scheme Rainbow -configuration Release -sdk iphonesimulator -derivedDataPath ios/build

- name: Upload to AWS S3
env:
AWS_BUCKET: rainbow-app-team-production
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
COMMIT_HASH: ${{ github.sha }}
run: |
APP_DIR=$(find . -name "*.app" | head -n 1)
cd $APP_DIR && zip -r ../App.zip . && cd ..
aws s3 cp "App.zip" "s3://${AWS_BUCKET}/${BRANCH_NAME}/${COMMIT_HASH}.app.zip"
- name: Post comment to PR
if: github.event_name == 'pull_request'
env:
TOPHAT_GITHUB_TOKEN: ${{ secrets.TOPHAT_GITHUB_TOKEN }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
COMMIT_HASH: ${{ github.sha }}
run: |
COMMENT="Launch the iOS app [here](http://localhost:29070/install/ios?virtual=https://app-team.p.rainbow.me/${BRANCH_NAME}/${COMMIT_HASH}.app.zip)"
curl -s -H "Authorization: token $TOPHAT_GITHUB_TOKEN" -X POST \
-d "{\"body\":\"$COMMENT\"}" \
"${{ github.event.pull_request.comments_url }}"

# Detox iOS e2e tests
- name: Run iOS e2e tests with retry
run: |
sed -i'' -e "s/IS_TESTING=false/IS_TESTING=true/" .env && rm -f .env-e
yarn detox build --configuration ios.sim.release
./scripts/run-retry-tests.sh 3
./scripts/run-retry-tests.sh 3
32 changes: 32 additions & 0 deletions ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,36 @@ platform :ios do
)

end
desc "Create new build for iOS devices in release mode"
lane :build_device do

update_info_plist(
plist_path: "Rainbow/Info.plist",
display_name: "Rainbow"
)

update_app_identifier(
app_identifier: "me.rainbow",
xcodeproj: "Rainbow.xcodeproj",
plist_path: "Rainbow/Info.plist",
)

match(
force: true,
type: "adhoc",
app_identifier: ["me.rainbow", "me.rainbow.PriceWidget", "me.rainbow.SelectTokenIntent", "me.rainbow.ImageNotification", "me.rainbow.OpenInRainbow", "me.rainbow.ShareWithRainbow"],
git_url: "[email protected]:rainbow-me/rainbow-code-signing.git",
)

gym(
workspace: "Rainbow.xcworkspace",
scheme: "Rainbow",
include_symbols: false,
export_method: "ad-hoc",
output_directory: "build",
output_name: "Rainbow.ipa",
archive_path: "build/Rainbow.xcarchive"
)

end
end

0 comments on commit b1f30f5

Please sign in to comment.