Skip to content

Commit

Permalink
Merge branch 'develop' into qr-scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
alwx authored Feb 15, 2024
2 parents 76f89d3 + e6ea8ae commit 8a9c004
Show file tree
Hide file tree
Showing 42 changed files with 284 additions and 182 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,6 @@ test/appium/tests/users.py

## git hooks
lefthook.yml

## metro server logs
metro-server-logs.log
17 changes: 5 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ build-fdroid: ##@build Build release for F-Droid

build-android: export BUILD_ENV ?= prod
build-android: export BUILD_TYPE ?= nightly
build-android: export BUILD_NUMBER ?= $(TMP_BUILD_NUMBER)
build-android: export ORG_GRADLE_PROJECT_versionCode ?= $(TMP_BUILD_NUMBER)
build-android: export ANDROID_ABI_SPLIT ?= false
build-android: export ANDROID_ABI_INCLUDE ?= armeabi-v7a;arm64-v8a;x86
build-android: ##@build Build unsigned Android APK
Expand Down Expand Up @@ -267,7 +267,7 @@ run-clojure: ##@run Watch for and build Clojure changes for mobile

run-metro: export TARGET := clojure
run-metro: ##@run Start Metro to build React Native changes
@scripts/start-react-native.sh
@scripts/run-metro.sh

run-re-frisk: export TARGET := clojure
run-re-frisk: ##@run Start re-frisk server
Expand All @@ -278,22 +278,15 @@ run-android: export TARGET := android
# Disabled for debug builds to avoid 'maximum call stack exceeded' errors.
# https://github.com/status-im/status-mobile/issues/18493
run-android: export ORG_GRADLE_PROJECT_hermesEnabled := false
# INFO: If it's empty (no devices attached, parsing issues, script error) - for Nix it's the same as not set.
run-android: export ANDROID_ABI_INCLUDE ?= $(shell ./scripts/adb_devices_abis.sh)
run-android: ##@run Build Android APK and start it on the device
npx react-native run-android --appIdSuffix debug
@scripts/run-android.sh

SIMULATOR=iPhone 13
# TODO: fix IOS_STATUS_GO_TARGETS to be either amd64 or arm64 when RN is upgraded
run-ios: export TARGET := ios
run-ios: export IOS_STATUS_GO_TARGETS := ios/arm64;iossimulator/amd64
run-ios: export XCBeautify=$(shell which xcbeautify) # for react-native-cli to pick this up and to auto format output
run-ios: ##@run Build iOS app and start it in a simulator/device
ifneq ("$(SIMULATOR)", "")
npx react-native run-ios --simulator="$(SIMULATOR)"
else
npx react-native run-ios
endif
run-ios: ##@run Build iOS app and start it in on the simulator
@scripts/run-ios.sh "${SIMULATOR}"

show-ios-devices: ##@other shows connected ios device and its name
xcrun xctrace list devices
Expand Down
2 changes: 1 addition & 1 deletion ci/Jenkinsfile.android
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

/* Options section can't access functions in objects. */
def isPRBuild = utils.isPRBuild()
Expand Down
2 changes: 1 addition & 1 deletion ci/Jenkinsfile.combined
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

pipeline {
agent { label 'linux' }
Expand Down
2 changes: 1 addition & 1 deletion ci/Jenkinsfile.e2e-nightly
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

pipeline {
agent { label 'linux' }
Expand Down
2 changes: 1 addition & 1 deletion ci/Jenkinsfile.ios
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

/* Options section can't access functions in objects. */
def isPRBuild = utils.isPRBuild()
Expand Down
2 changes: 1 addition & 1 deletion ci/Jenkinsfile.tests
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

/* Options section can't access functions in objects. */
def isPRBuild = utils.isPRBuild()
Expand Down
2 changes: 1 addition & 1 deletion ci/tests/Jenkinsfile.e2e-nightly
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

pipeline {

Expand Down
2 changes: 1 addition & 1 deletion ci/tests/Jenkinsfile.e2e-prs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

pipeline {

Expand Down
2 changes: 1 addition & 1 deletion ci/tests/Jenkinsfile.e2e-upgrade
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

pipeline {

Expand Down
2 changes: 1 addition & 1 deletion ci/tools/Jenkinsfile.fastlane-clean
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

pipeline {
agent { label 'macos' }
Expand Down
4 changes: 2 additions & 2 deletions ci/tools/Jenkinsfile.nix-cache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

pipeline {
agent { label params.AGENT_LABEL }
Expand Down Expand Up @@ -82,7 +82,7 @@ pipeline {
env.NIXPKGS_SYSTEM_OVERRIDE = nixSysOverride(os, arch, 'android')
/* Build/fetch deps required to build android release. */
nix.build(
attr: 'targets.mobile.android.release.buildInputs',
attr: 'targets.mobile.android.build.buildInputs',
sandbox: false,
pure: false,
link: false
Expand Down
2 changes: 1 addition & 1 deletion ci/tools/Jenkinsfile.playstore-meta
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

pipeline {
agent { label 'linux' }
Expand Down
2 changes: 1 addition & 1 deletion ci/tools/Jenkinsfile.xcode-clean
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5'
library 'status-jenkins-lib@v1.8.7'

pipeline {
agent {
Expand Down
3 changes: 1 addition & 2 deletions doc/ide-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ See below:

Do the following:

Ensure you have 3 terminals running the following
Ensure you have 2 terminals running the following

- `make run-clojure`
- `make run-metro`
- `make run-ios` / `make run-android`

[See the STARTING GUIDE for details](STARTING_GUIDE.md#development)
Expand Down
3 changes: 1 addition & 2 deletions doc/starting-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ This step will take a while the first time as it will download all dependencies.
There are three steps necessary to start development, in this case for Android:

1. `make run-clojure` - Compiles Clojure into JavaScript, watches for changes on cljs files, and hot-reloads code in the app.
2. `make run-metro` - Starts metro bundler and watches JavaScript code.
3. `make run-android` or `make run-ios` - Builds the Android/iOS app and starts it on the device.
2. `make run-android` or `make run-ios` - Builds the Android/iOS app, starts it on the device and starts metro bundler.

The first two will continue watching for changes and keep re-building the app. They need to be ready first.
The last one will exit once the app is up and ready.
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ CHECKOUT OPTIONS:
:submodules: true

SPEC CHECKSUMS:
boost: 57d2868c099736d80fcd648bf211b4431e51a558
boost: 64032b9e9b938fda23325e68a3771f0fabf414dc
BVLinearGradient: 612a04ff38e8480291f3379ee5b5a2c571f03fe0
CryptoSwift: c4f2debceb38bf44c80659afe009f71e23e4a082
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
Expand Down
6 changes: 3 additions & 3 deletions nix/DETAILS.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ We will use the `make jsbundle` target as an example of a derivation you can bui
3. [`build.sh`](/nix/scripts/build.sh) calls `nix-build --attr targets.mobile.jsbundle` with extra arguments
4. `nix-build` builds the derivation from [`nix/mobile/jsbundle/default.nix`](/nix/mobile/jsbundle/default.nix)

The same can be done for other targets like `targets.mobile.android.release`.
The same can be done for other targets like `targets.mobile.android.build`.
Except in that case extra arguments are required which is why the [`scripts/release-android.sh`](/scripts/release-android.sh) is used in the `make release-android` target.

If you run `make release-android` you'll see the `nix-build` command used:
Expand All @@ -71,14 +71,14 @@ nix-build \
--fallback \
--no-out-link \
--show-trace \
--attr targets.mobile.android.release \
--attr targets.mobile.android.build \
--argstr secrets-file '/tmp/tmp-status-mobile-559a3a441/tmp.xAnrPuNtAP' \
--option extra-sandbox-paths '/home/joe/.gradle/status-im.keystore /tmp/tmp-status-mobile-559a3a441/tmp.xAnrPuNtAP' \
default.nix
```
Some of those are required which is why just calling:
```
nix-build --attr targets.mobile.android.release
nix-build --attr targets.mobile.android.build
```
Would fail.

Expand Down
2 changes: 1 addition & 1 deletion nix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export STATUS_GO_IPFS_GATEWAY_URL="https://ipfs.status.im/"
```
You can see the defaults in code:
- [`nix/status-go/default.nix`](./status-go/default.nix)
- [`nix/mobile/android/release.nix`](./mobile/android/release.nix)
- [`nix/mobile/android/release.nix`](./mobile/android/build.nix)

## Shell

Expand Down
2 changes: 1 addition & 1 deletion nix/deps/gradle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This directory contains the tools and the data that allows Nix to manage Gradle

Simply calling `generate.sh` should result in a `deps.json` file which is used in the derivation that provides Gradle dependencies when building the Android app.

You can see in [`nix/mobile/android/release.nix`](../../mobile/android/release.nix) that it's used via the `-Dmaven.repo.local='${deps.gradle}'` Gradle flag.
You can see in [`nix/mobile/android/release.nix`](../../mobile/android/build.nix) that it's used via the `-Dmaven.repo.local='${deps.gradle}'` Gradle flag.

# Files

Expand Down
34 changes: 18 additions & 16 deletions nix/mobile/android/release.nix → nix/mobile/android/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
# Path to the file containing secret environment variables
secretsFile ? "",
# Build type (influences which .env file gets used for feature flags)
# TODO: pr or relase for default?
buildType ? lib.getEnvWithDefault "BUILD_TYPE" "release",
# Used for versionCode
buildNumber ? lib.getEnvWithDefault "BUILD_NUMBER" 9999,
versionCode ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_versionCode" 9999,
# Included in APK Manifest for easier identification.
# TODO: or GIT_COMMIT from Jenkins?
commitHash ? lib.getEnvWithDefault "COMMIT_HASH" "unknown",
# Gradle options passed for Android builds
androidGradleOpts ? lib.getEnvWithDefault "ANDROID_GRADLE_OPTS" null,
commitHash ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_commitHash" "unknown",
# Disabled for debug builds to avoid 'maximum call stack exceeded' errors.
# https://github.com/status-im/status-mobile/issues/18493
hermesEnabled ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_hermesEnabled" "true",
buildUrl ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_buildUrl" null,
statusGoSrcOverride ? lib.getEnvWithDefault "STATUS_GO_SRC_OVERRIDE" null,
# If APKs should be split based on architectures
androidAbiSplit ? lib.getEnvWithDefault "ANDROID_ABI_SPLIT" "false",
Expand All @@ -40,8 +40,10 @@ let
else if (elem buildType ["pr" "manual"]) then ".env.jenkins"
else ".env";

# There are only two types of Gradle build targets: pr and release
gradleBuildType = if buildType == "pr" then "Pr" else "Release";
gradleBuildType =
if buildType == "pr" then "Pr"
else if buildType == "debug" then "Debug"
else "Release";

apksPath = "./android/app/build/outputs/apk/${toLower gradleBuildType}";

Expand Down Expand Up @@ -81,7 +83,10 @@ in stdenv.mkDerivation rec {
ANDROID_ABI_INCLUDE = androidAbiInclude;
# Disabled for debug builds to avoid 'maximum call stack exceeded' errors.
# https://github.com/status-im/status-mobile/issues/18493
ORG_GRADLE_PROJECT_hermesEnabled = true;
ORG_GRADLE_PROJECT_versionCode = versionCode;
ORG_GRADLE_PROJECT_commitHash = commitHash;
ORG_GRADLE_PROJECT_buildUrl = buildUrl;
ORG_GRADLE_PROJECT_hermesEnabled = hermesEnabled;

# Fix for ERR_OSSL_EVP_UNSUPPORTED error.
NODE_OPTIONS = "--openssl-legacy-provider";
Expand Down Expand Up @@ -116,8 +121,6 @@ in stdenv.mkDerivation rec {
# Symlink React Native entrypoint.
cp -Lr ${builtJsBundle} ./result
pwd
find -L result
# Copy android/ directory
mkdir -p ./android/build
Expand All @@ -144,16 +147,13 @@ in stdenv.mkDerivation rec {
"LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${makeLibraryPath [ pkgs.zlib ]}";
gradleCommand = ''
${pkgs.gradle}/bin/gradle \
${toString androidGradleOpts} \
--console=plain \
--offline \
--no-daemon \
--no-scan \
--no-watch-fs \
--no-build-cache \
-Dmaven.repo.local='${deps.gradle}' \
-PversionCode=${toString buildNumber} \
-PcommitHash=${commitHash} \
assemble${gradleBuildType}
'';
in
Expand All @@ -171,12 +171,14 @@ in stdenv.mkDerivation rec {
${adhocEnvVars} ${gradleCommand}
popd > /dev/null
'';
doCheck = true;
checkPhase = ''

doCheck = buildType != "debug";
checkPhase = ''
ls ${apksPath}/*.apk \
| xargs -n1 ${pkgs.unzip}/bin/unzip -qql \
| grep 'index.android.bundle'
'';

installPhase = ''
mkdir -p $out
cp ${apksPath}/*.apk $out/
Expand Down
4 changes: 2 additions & 2 deletions nix/mobile/android/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, jsbundle, status-go, androidPkgs, androidShell }:

rec {
release = callPackage ./release.nix {
build = callPackage ./build.nix {
inherit jsbundle status-go;
};

Expand All @@ -15,7 +15,7 @@ rec {
];

inputsFrom = [
(release {})
(build {})
androidShell
];

Expand Down
2 changes: 1 addition & 1 deletion nix/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if [[ -z "${TARGET}" ]]; then
fi

# Hack fix for missing Android SDK for aarch64 on Darwin. See systemOverride in `nix/pkgs.nix`.
if [[ "${TARGET}" =~ ^(targets.status-go.mobile.android|targets.mobile.android.release)$ ]]; then
if [[ "${TARGET}" =~ ^(targets.status-go.mobile.android|targets.mobile.android.build)$ ]]; then
os=$(uname -s | tr '[:upper:]' '[:lower:]')
export NIXPKGS_SYSTEM_OVERRIDE="x86_64-${os}"
fi
Expand Down
4 changes: 1 addition & 3 deletions scripts/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ function append_env_export() {
VAR_VALUE=$(must_get_env "${VAR_NAME}")
echo "export ${VAR_NAME}=\"${VAR_VALUE}\";" >> "${SECRETS_FILE_PATH}"
}

export COMMIT_HASH="$(git rev-parse --verify HEAD)"
nixOpts=()

# We create if now so the trap knows its location
Expand Down Expand Up @@ -73,4 +71,4 @@ else
fi


"${GIT_ROOT}/nix/scripts/build.sh" targets.mobile.android.release "${nixOpts[@]}"
"${GIT_ROOT}/nix/scripts/build.sh" targets.mobile.android.build "${nixOpts[@]}"
Loading

0 comments on commit 8a9c004

Please sign in to comment.