Skip to content

Commit

Permalink
Merge branch 'develop' into brody/swaps-e2e-changes-1
Browse files Browse the repository at this point in the history
  • Loading branch information
BrodyHughes authored Sep 4, 2024
2 parents 84d6c43 + 63936a6 commit 4da32dd
Show file tree
Hide file tree
Showing 108 changed files with 3,868 additions and 2,399 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/macstadium-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: iOS builds
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:

jobs:
# Job to install dependencies
build:
runs-on: ["self-hosted"]
if: github.event.pull_request.draft == false
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: Version debug
run: |
npx react-native info
- name: Install pods
run: yarn install-bundle && yarn install-pods

- uses: irgaly/xcode-cache@v1
with:
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ github.sha }}
restore-keys: xcode-cache-deriveddata-${{ github.workflow }}-

# TOPHAT iOS 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
sed -i '' 's/match AppStore/match AdHoc/g' "ios/Rainbow.xcodeproj/project.pbxproj"
xcodebuild -workspace ios/Rainbow.xcworkspace -scheme Rainbow -configuration Release -sdk iphonesimulator -derivedDataPath ios/build
APP_DIR=$(find . -name "*.app" | head -n 1)
cd $APP_DIR && zip -r ../../../../../../App.zip .
# TOPHAT iOS DEVICE
- name: Build the app in release mode for iOS devices
env:
FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
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_FILE=$(find . -name "App.zip" | head -n 1)
aws s3 cp "${APP_FILE}" "s3://${AWS_BUCKET}/${BRANCH_NAME}/${COMMIT_HASH}.app.zip"
IPA_FILE=./ios/build/Rainbow.ipa
aws s3 cp "${IPA_FILE}" "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
@@ -1,16 +1,15 @@
name: iOS e2e tests

on: [pull_request, workflow_dispatch]

jobs:
ios-e2e:
# Job to install dependencies
install-deps:
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
Expand All @@ -29,8 +28,7 @@ jobs:
git clone [email protected]:rainbow-me/rainbow-env.git
mv rainbow-env/dotenv .env && rm -rf rainbow-env
eval $CI_SCRIPTS
sed -i'' -e "s/IS_TESTING=false/IS_TESTING=true/" .env && rm -f .env-e
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
Expand All @@ -48,7 +46,26 @@ jobs:
- name: Install dependencies
run: |
yarn cache clean --all && yarn install && yarn setup
yarn install && yarn setup
- name: Upload Yarn cache
uses: actions/upload-artifact@v3
with:
name: yarn-cache
path: |
.yarn/cache
.yarn/install-state.gz
# Job for linting and unit tests
linting-and-unit-tests:
runs-on: ["self-hosted"]
needs: install-deps
steps:
- name: Download Yarn cache
uses: actions/download-artifact@v3
with:
name: yarn-cache
path: .yarn

- name: Check for frozen lockfile
run: ./scripts/check-lockfile.sh
Expand All @@ -62,24 +79,36 @@ jobs:
- name: Unit tests
run: yarn test

# iOS build and e2e tests
e2e-ios:
runs-on: ["self-hosted"]
needs: install-deps
steps:
- name: Download Yarn cache
uses: actions/download-artifact@v3
with:
name: yarn-cache
path: .yarn

- name: Rebuild detox cache
run: ./node_modules/.bin/detox clean-framework-cache && ./node_modules/.bin/detox build-framework-cache

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

- name: Fix permissions
run: |
chmod -R +x node_modules/react-native/scripts
chmod -R +x node_modules/@sentry/react-native/scripts
- name: Build the app in release mode
run: yarn detox build --configuration ios.sim.release

# change the '3' here to how many times you want the tests to rerun on failure

- uses: irgaly/xcode-cache@v1
with:
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ github.sha }}
restore-keys: xcode-cache-deriveddata-${{ github.workflow }}-

# Detox iOS e2e tests
- name: Run iOS e2e tests with retry
run: ./scripts/run-retry-tests.sh 3
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
2 changes: 2 additions & 0 deletions android/app/src/main/java/me/rainbow/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import me.rainbow.NativeModules.RNStartTime.RNStartTimePackage
import me.rainbow.NativeModules.RNTextAnimatorPackage.RNTextAnimatorPackage
import me.rainbow.NativeModules.RNZoomableButton.RNZoomableButtonPackage
import me.rainbow.NativeModules.SystemNavigationBar.SystemNavigationBarPackage
import me.rainbow.NativeModules.NavbarHeight.NavbarHeightPackage

class MainApplication : Application(), ReactApplication {
override val reactNativeHost: ReactNativeHost = object : DefaultReactNativeHost(this) {
Expand All @@ -41,6 +42,7 @@ class MainApplication : Application(), ReactApplication {
packages.add(KeychainPackage(KeychainModuleBuilder().withoutWarmUp()))
packages.add(RNStartTimePackage(START_MARK))
packages.add(RNHapticsPackage())
packages.add(NavbarHeightPackage())
return packages
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package me.rainbow.NativeModules.NavbarHeight;

import androidx.annotation.NonNull;

import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.module.annotations.ReactModule;
import android.graphics.Point;
import android.view.WindowManager;
import android.view.Display;
import java.lang.IllegalAccessException;
import java.lang.reflect.InvocationTargetException;
import java.lang.NoSuchMethodException;
import android.view.WindowInsets;
import android.os.Build;
import android.content.Context;

@ReactModule(name = NavbarHeightModule.NAME)
public class NavbarHeightModule extends ReactContextBaseJavaModule {
public static final String NAME = "NavbarHeight";

public NavbarHeightModule(ReactApplicationContext reactContext) {
super(reactContext);
}

@Override
@NonNull
public String getName() {
return NAME;
}

// Example method
// See https://reactnative.dev/docs/native-modules-android
@ReactMethod
public double getNavigationBarHeightSync() {
Context context = getReactApplicationContext();
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if (Build.VERSION.SDK_INT >= 30) {
return windowManager
.getCurrentWindowMetrics()
.getWindowInsets()
.getInsets(WindowInsets.Type.navigationBars())
.bottom;
} else {
Point appUsableSize = getAppUsableScreenSize(context);
Point realScreenSize = getRealScreenSize(context);

// navigation bar on the side
if (appUsableSize.x < realScreenSize.x) {
return appUsableSize.y;
}

// navigation bar at the bottom
if (appUsableSize.y < realScreenSize.y) {
return realScreenSize.y - appUsableSize.y;
}

// navigation bar is not present
return 0;
}
}
public Point getAppUsableScreenSize(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
return size;
}
public Point getRealScreenSize(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
Point size = new Point();

if (Build.VERSION.SDK_INT >= 17) {
display.getRealSize(size);
} else if (Build.VERSION.SDK_INT >= 14) {
try {
size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
} catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} catch (NoSuchMethodException e) {}
}

return size;
}
@ReactMethod(isBlockingSynchronousMethod = true)
public double getNavigationBarHeight() {
return getNavigationBarHeightSync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package me.rainbow.NativeModules.NavbarHeight;

import androidx.annotation.NonNull;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class NavbarHeightPackage implements ReactPackage {
@NonNull
@Override
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new NavbarHeightModule(reactContext));
return modules;
}

@NonNull
@Override
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
1 change: 1 addition & 0 deletions globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ declare module 'react-native-dotenv' {
export const REACT_NATIVE_RUDDERSTACK_WRITE_KEY: string;
export const RUDDERSTACK_DATA_PLANE_URL: string;
export const SILENCE_EMOJI_WARNINGS: boolean;
export const MWP_ENCRYPTION_KEY: string;
}
Loading

0 comments on commit 4da32dd

Please sign in to comment.