Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ Upgrade the phone native code to the latest #1172

Merged
merged 12 commits into from
Aug 30, 2024
Merged

Conversation

shankari
Copy link
Contributor

shankari and others added 12 commits August 26, 2024 23:00
This is consistent with
e-mission/e-mission-docs#1079 (comment)
and may fix the errors in the CI/CD for the android SDK installation script

Testing done:
with the other changes in this PR, `npx cordova build` succeeded
This includes:
- cordova-android
- cordova-ios
- core plugins (inapp-browser)
- cordova CLI
- nvm, node, npm
- cocoapods
- gradle

This is consistent with
e-mission/e-mission-docs#1079 (comment)
to look through the changes in the cordova codebase
While investigating the issues with SSL errors, I discovered that cordova
doesn't use the system gradle, but configures `build.gradle` so that the
correct version of gradle is downloaded and installed on the first run.

This means that we don't need to install gradle manually, which in turn, means
that we don't need to install sdkman so that we install the pinned version of
gradle.

Yay for simplifying code and removing dependencies!
e-mission/e-mission-docs#1079 (comment)
We had a pinned npm version, but we didn't actually use it,
using the default version in node instead. As long as we have
a reasonbly recent version of node, that seems like it will work.
It is still pinned (just pinned implicitly by the node pin), and we don't
actually use the pinned version now anyway.

Yay for simplicity and not keeping bitrotted code around...
This ensures that we don't "discover" the plugin and try to install it
#1168 (comment)

Without this change:
```
Discovered plugin "cordova-plugin-ibeacon". Adding it to the project
Plugin "com.unarin.cordova.beacon" already installed on android.
Plugin "com.unarin.cordova.beacon" already installed on ios.
```

With this change: those logs don't show up
It was in `before_build` earlier, but that led to the changes from the script
being overridden before the actual compile started
e-mission/e-mission-docs#1079 (comment)
#1168 (comment)
#1168 (comment)
#1168 (comment)
#1168 (comment)

Testing done:

Before this change:

```
Done setting IPHONEOS_DEPLOYMENT_TARGET
Overwriting existing resource file at platforms/ios/emission/Resources/GoogleService-Info.plist
^[[37mcordova-custom-config: Applied custom config from config.xml to /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/emission/emission-Info.plist^[[39m
```

After this change:

```
Overwriting existing resource file at platforms/ios/emission/Resources/GoogleService-Info.plist
^[[37mcordova-custom-config: Applied custom config from config.xml to /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/emission/emission-Info.plist^[[39m
...
Done setting IPHONEOS_DEPLOYMENT_TARGET
...
Touch /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/build/Debug-iphonesimulator/emission.app (in target 'emission' from project 'emission')
    cd /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios
    /usr/bin/touch -c /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/build/Debug-iphonesimulator/emission.app

** BUILD SUCCEEDED **
```
…T_TARGET`

Add additional logging to debug this more efficiently in the future
The additional logging is accessed with `--verbose`. While testing this, I
realized that `--verbose` would have been helpful in debugging this issue in
the first place - it makes is really clear that the `pod install` happens as
part of prepare before the compile. Still not sure how it worked locally before!

- No verbose:

```
cordova-custom-config: Applied custom config from config.xml to /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/emission/emission-Info.plist
Apply patch to [
  'node_modules/@shopify/flash-list/ios/RNFlashList.xcodeproj/project.pbxproj',
  'node_modules/cordova-ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj',
  'node_modules/cordova-ios/templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj',
  'node_modules/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj',
  'node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj/project.pbxproj',
  'node_modules/react-native-safe-area-context/ios/RNSafeAreaContext.xcodeproj/project.pbxproj',
  'node_modules/react-native-screens/ios/RNScreens.xcodeproj/project.pbxproj',
  'node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj/project.pbxproj',
  'platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj',
  'platforms/ios/Pods/Pods.xcodeproj/project.pbxproj',
  'platforms/ios/emission.xcodeproj/project.pbxproj'
]
Done setting IPHONEOS_DEPLOYMENT_TARGET
List simulator targets
Select last emulator from list as default.
List simulator targets
No simulator found for ". Falling back to the default target.
Building for "iPhone 15 Pro Max" Simulator (com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro-Max, iPhone-15-Pro-Max).
Building project: /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/emission.xcworkspace
	Configuration: Debug
	Platform: emulator
	Target: iPhone 15 Pro Max
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace emission.xcworkspace -scheme emission -configuration Debug -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 15 Pro Max" build SYMROOT=/Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/build
```

- verbose

```
pods.json found in platforms/ios
Podfile found in platforms/ios
Wrote to Podfile.
Running `pod install` (to install plugins)
==== pod install start ====
==== pod install end ====
Updating resource files at platforms/ios
Prepared iOS project successfully

Executing script found in config.xml for hook "before_compile": hooks/before_compile/ios/ios_change_deployment.js
Context {
  hook: 'before_compile',
  opts: {
    platforms: [ 'ios' ],
    options: { verbose: true, argv: [] },
    verbose: true,
    silent: false,
    nohooks: [],
    searchpath: undefined,
    projectRoot: '/Users/kshankar/Desktop/data/e-mission/native_code_upgrade',
    cordova: { platforms: [Array], plugins: [Array], version: '12.0.1' },
    save: false,
    paths: [
      '/Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/www'
    ]
  },
  cmdLine: '/Users/kshankar/.nvm/versions/node/v20.9.0/bin/node /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/node_modules/.bin/cordova build ios --verbose',
  scriptLocation: '/Users/kshankar/Desktop/data/e-mission/native_code_upgrade/hooks/before_compile/ios/ios_change_deployment.js'
}

Apply patch to [
  'node_modules/@shopify/flash-list/ios/RNFlashList.xcodeproj/project.pbxproj',
  'node_modules/cordova-ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj',
  'node_modules/cordova-ios/templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj',
  'node_modules/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj',
  'node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj/project.pbxproj',
  'node_modules/react-native-safe-area-context/ios/RNSafeAreaContext.xcodeproj/project.pbxproj',
  'node_modules/react-native-screens/ios/RNScreens.xcodeproj/project.pbxproj',
  'node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj/project.pbxproj',
  'platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj',
  'platforms/ios/Pods/Pods.xcodeproj/project.pbxproj',
  'platforms/ios/emission.xcodeproj/project.pbxproj'
]
Done setting IPHONEOS_DEPLOYMENT_TARGET
Executing script found in plugin cordova-custom-config for hook "before_compile": plugins/cordova-custom-config/hooks/applyCustomConfig.js
^[[32mcordova-custom-config: Loaded module dependencies^[[39m
^[[32mcordova-custom-config: Running applyCustomConfig.js^[[39m
^[[32mcordova-custom-config: Finished applying platform config^[[39m
before patching, grep -r IPHONEOS_DEPLOYMENT_TARGET platforms/ios | sort | uniq:
 platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj:                         IPHONEOS_DEPLOYMENT_TARGET = 13.0;
platforms/ios/Pods/Pods.xcodeproj/project.pbxproj:                              IPHONEOS_DEPLOYMENT_TARGET = 10.0;
platforms/ios/Pods/Pods.xcodeproj/project.pbxproj:                              IPHONEOS_DEPLOYMENT_TARGET = 13.0;
platforms/ios/Pods/Pods.xcodeproj/project.pbxproj:                              IPHONEOS_DEPLOYMENT_TARGET = 8.0;
platforms/ios/Pods/Pods.xcodeproj/project.pbxproj:                              IPHONEOS_DEPLOYMENT_TARGET = 9.0;
platforms/ios/emission.xcodeproj/project.pbxproj:                               IPHONEOS_DEPLOYMENT_TARGET = 13.0;

after patching, grep -r IPHONEOS_DEPLOYMENT_TARGET platforms/ios | sort | uniq:
 platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj:                         IPHONEOS_DEPLOYMENT_TARGET = 13.0;
platforms/ios/Pods/Pods.xcodeproj/project.pbxproj:                              IPHONEOS_DEPLOYMENT_TARGET = 13.0;
platforms/ios/emission.xcodeproj/project.pbxproj:                               IPHONEOS_DEPLOYMENT_TARGET = 13.0;
```
⬆️ Upgrade to the latest everything
Data collection:
⬆️  foreground service permissions + restricted broadcast event
https://github.com/e-mission/e-mission-data-collection/releases/tag/v1.8.9

Server communication:
🔊 if parsing response as JSON fails, include the raw response
https://github.com/e-mission/cordova-server-communication/releases/tag/v1.2.7

Local notifications:
⬆️ API 34: inexact alarms + immutable notifications
https://github.com/e-mission/cordova-plugin-local-notification-12/releases/tag/0.1.5-remove-exact-alarms

Server sync:
🔥 Remove the NEW_DATA broadcast intent when we pull data from the server
https://github.com/e-mission/cordova-server-sync/releases/tag/v1.3.3

Related server PR:
⚡️ Always return an empty server_to_phone response
e-mission/e-mission-server#978

+ Bump up version numbers
The bluetooth plugins, with some minor hacks to support our use case, are all
currently owned by @louisg1337. Moving them into the @Emission org for
long-term stability.
In e81164c
we removed the email plugin, but we did not adjust the expected number of plugins downward
Finally doing so now

Testing done:

Before this:

```
Found       25 plugins, expected 26
Found       25 plugins, expected 26, retrying
```

After this:

```
Found       25 plugins, expected 25
All plugins installed successfully!
```
⬆️ Bump up the version of all changed plugins + move repos to the e-mission org
Copy link

codecov bot commented Aug 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 30.02%. Comparing base (f256364) to head (2561050).
Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1172      +/-   ##
==========================================
+ Coverage   30.01%   30.02%   +0.01%     
==========================================
  Files         118      118              
  Lines        5184     5182       -2     
  Branches     1162     1163       +1     
==========================================
  Hits         1556     1556              
  Misses       3624     3624              
+ Partials        4        2       -2     
Flag Coverage Δ
unit 30.02% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 4 files with indirect coverage changes

@shankari
Copy link
Contributor Author

The failure in the automated install is again due to running out of space.

Warning: An error occurred while preparing SDK package Google Play Intel x86_64 Atom System Image: No space left on device.

We see this in the existing codebase as well so it doesn't need to hold up the merge.
Screenshot 2024-08-30 at 9 04 39 AM

But let's do a quick check on how it worked earlier but is broken now
Screenshot 2024-08-30 at 9 05 28 AM

@shankari
Copy link
Contributor Author

It is just the storage.

Working...

[==================                     ] 45% Unzipping... x86_64/system.img    
[==================                     ] 46% Unzipping... x86_64/system.img    
[==================                     ] 47% Unzipping... x86_64/system.img    
[==================                     ] 47% Unzipping... x86_64/userdata.img  
[==================                     ] 47% Unzipping... x86_64/vendor.img    
[==================                     ] 47% Unzipping... x86_64/VerifiedBootPa
[===================                    ] 49% Unzipping... x86_64/VerifiedBootPa
[===================                    ] 49% Installing Google Play Intel x86_6
[===================                    ] 49% Downloading x86_64-28_r08.zip... x
[===================                    ] 50% Downloading x86_64-28_r08.zip... x
[====================                   ] 50% Downloading x86_64-28_r08.zip... x
[====================                   ] 51% Downloading x86_64-28_r08.zip... x
[====================                   ] 51% Unzipping... x86_64/VerifiedBootPa
[====================                   ] 51% Unzipping... x86_64/advancedFeatur

Not working...

[==================                     ] 45% Unzipping... x86_64/source.propert
[==================                     ] 45% Unzipping... x86_64/system.img    
[==================                     ] 46% Unzipping... x86_64/system.img    
[==================                     ] 47% Unzipping... x86_64/system.img    
Warning: An error occurred while preparing SDK package Google Play Intel x86_64 Atom System Image: No space left on device.
                                                                                
[==================                     ] 47% Unzipping... x86_64/system.img    
END: Done with android SDK download, exiting script

@shankari shankari merged commit f05d7de into master Aug 30, 2024
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

⬆️ Upgrade the native code the latest versions
1 participant