Skip to content

Commit

Permalink
Merge pull request #638 from e-mission/import_ci
Browse files Browse the repository at this point in the history
Import the setup scripts and the CI workflows for Github Actions
  • Loading branch information
shankari authored Apr 18, 2020
2 parents de7f58e + 7d80a11 commit 6349af6
Show file tree
Hide file tree
Showing 11 changed files with 337 additions and 134 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This is a basic workflow to help you get started with Actions

name: osx-ubuntu-build-android

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '5 4 * * 0'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Print the java version
run: java -version

- name: Tries to figure out where android is installed
run: |
echo "Android listed at $ANDROID_HOME"
ls -al /opt/
- name: Setup the cordova environment
shell: bash -l {0}
run: |
source setup/setup_android_native.sh
npx cordova -version
npx ionic -version
- name: Access cordova with a specified shell
shell: bash -l {0}
run: |
npx cordova -version
which gradle
gradle -version
- name: Build android
shell: bash -l {0}
run: |
echo $PATH
which gradle
gradle -version
echo "Let's rerun the sdkman again"
source ~/.sdkman/bin/sdkman-init.sh
echo $PATH
which gradle
gradle --version
npx cordova build android
33 changes: 33 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!

# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
62 changes: 62 additions & 0 deletions .github/workflows/ios-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This is a basic workflow to help you get started with Actions

name: osx-build-ios

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '5 4 * * 0'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Print the xcode path
run: xcode-select --print-path

- name: Print the xcode setup
run: xcodebuild -version -sdk

- name: Print applications through dmg
run: ls /Applications

- name: Print applications through brew
run: brew list

- name: Setup the cordova environment
shell: bash -l {0}
run: |
source setup/setup_ios_native.sh
npx cordova -version
npx ionic -version
- name: Access cordova directly
run: npx cordova -version

- name: Access cordova with a specified shell
shell: bash -l {0}
run: npx cordova -version

- name: Build ios
shell: bash -l {0}
run: npx cordova build ios

- name: Cleanup the cordova environment
shell: bash -l {0}
run: source setup/teardown_ios_native.sh

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ app-settings.json
.idea/
.io-config.json
*.apk
*.app.zip
*.ipa
www/js/control/collect-settings.js
www/js/control/sync-settings.js
Expand Down
174 changes: 40 additions & 134 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,157 +145,63 @@ One advantage of using `skip` authentication in development mode is that any use
Updating the e-mission-\* plugins or adding new plugins
---
=======
![osx-build-ios](https://github.com/covid19database/phone-app/workflows/osx-build-ios/badge.svg)
![osx-ubuntu-build-android](https://github.com/covid19database/phone-app/workflows/osx-ubuntu-build-android/badge.svg)
Installing
Pre-requisites
---
We are using the ionic v3.19.1 platform, which is a toolchain on top of the apache
cordova project. So the first step is to install ionic using their instructions.
http://ionicframework.com/docs/v1/getting-started/
NOTE: Since we are still on ionic v1, please do not install v2 or v3, as the current codebase will not work with it.
Issue the following commands to install Cordova and Ionic instead of the ones provided in the instruction above.
```
$ npm install -g [email protected]
$ npm install -g [email protected]
```
Install gradle (https://gradle.org/install/) for android builds.
Then, get the current version of our code
Fork this repo using the github UI
Clone your fork
```
$ git clone <your repo URL>
```
```
$ cd e-mission-phone
```
Enable platform hooks, including http on iOS9
- the version of xcode used by the CI
- to install a particular version, use [xcode-select](https://www.unix.com/man-page/OSX/1/xcode-select/)
- or this [supposedly easier to use repo](https://github.com/xcpretty/xcode-install)
- git
- the most recent version of android studio
```
$ git clone https://github.com/driftyco/ionic-package-hooks.git ./package-hooks
```
Setup the config
```
$ ./bin/configure_xml_and_json.js cordovabuild
```
Install all javascript components using bower
```
$ bower update
```
Make sure to install the other node modules required for the setup scripts.
```
npm install
```
Create a remote to pull updates from upstream
```
$ git remote add upstream https://github.com/e-mission/e-mission-phone.git
```
Setup cocoapods. For all versions > 1.9, we need https://cocoapods.org/ support. This is used by the push plugin for the GCM pod, and by the auth plugin to install the GTMOAuth framework. This is a good time to get a cup of your favourite beverage.
```
$ sudo gem install cocoapods
$ pod setup
```
To debug the cocoapods install, or make it less resource intensive, check out troubleshooting guide for the push plugin.
https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md#cocoapods
Important
---
Most of the recent issues encountered have been due to incompatible setup. We
have now:
- locked down the dependencies,
- created setup and teardown scripts to setup self-contained environments with
those dependencies, and
- CI enabled to validate that they continue work.
**Note about cocoapods 1.9, there seems to be an issue which breaks ```pod setup```:**
https://github.com/flutter/flutter/issues/41253
1.75 seems to work: ```sudo gem install cocoapods -v 1.7.5```
If you have setup failures, please compare the configuration in the passing CI
builds with your configuration. That is almost certainly the source of the error.
Configure values if necessary - e.g.
Installing
---
Run the setup script for the platform you want to build
```
ls www/json/*.sample
cp www/json/setupConfig.json.sample www/json/setupConfig.json
cp ..... www/json/connectionConfig.json
$ source setup/setup_android_native.sh
AND/OR
$ source setup/setup_ios_native.sh
```
Restore cordova platforms and plugins
Run in the emulator
```
$ cordova prepare
$ npx cordova emulate ios
AND/OR
$ npx cordova emulate android
```
**Note:** Sometimes, the `$ cordova prepare` command fails because of errors while cloning plugins (`Failed to restore plugin "..." from config.xml.`). A workaround is at https://github.com/e-mission/e-mission-docs/blob/master/docs/overview/high_level_faq.md#i-get-an-error-while-adding-plugins
**Note #2:** After the update to the plugins to support api 26, for this repository **only** the first call `$ cordova prepare` fails with the error
Using cordova-fetch for cordova-android@^6.4.0
Error: Platform ios already added.
The workaround is to re-run `$cordova prepare`. This not required in the https://github.com/e-mission/e-mission-base repo although the config.xml seems to be the same for both repositories.
$ cordova prepare
Discovered platform "android@^6.4.0" in config.xml or package.json. Adding it to the project
Using cordova-fetch for cordova-android@^6.4.0
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: edu.berkeley.eecs.emission
Name: emission
Activity: MainActivity
Android target: android-26
Installation is now complete. You can view the current state of the application in the emulator
$ cordova emulate ios
OR
$ cordova emulate android
The android build and emulator have improved significantly in the last release
of Android Studio (3.0.1). The build is significantly faster than iOS, the
emulator is just as snappy, and the debugger is better since chrome saves logs
from startup, so you don't have to use tricks like adding alerts to see errors
in startup.
**Note about Xcode >=10** The cordova build doesn't work super smoothly for iOS anymore. Concretely, you need two additional steps:
- install pods manually. Otherwise you will get a linker error for `-lAppAuth`
```
$ cd platform/ios
$ pod install
$ cd ../..
```
- when you recompile, you will get the following compile error. The workaround is to compile from xcode. I have filed an issue for this (https://github.com/apache/cordova-ios/issues/550) but there have been no recent updates.
```
/Users/shankari/e-mission/e-mission-phone/platforms/ios/Pods/JWT/Classes/Supplement/JWTBase64Coder.m:22:9: fatal error:
'Base64/MF_Base64Additions.h' file not found
#import <Base64/MF_Base64Additions.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```
- Also, on Mojave, we have reports that [you may need to manually enable the Legacy Build system in Xcode if you want to run the app on a real device](https://stackoverflow.com/a/52528662/4040267).
Troubleshooting
---
- Make sure to use `npx ionic` and `npx cordova`. This is
because the setup script installs all the modules locally in a self-contained
environment using `npm install` and not `npm install -g`
- Check the CI to see whether there is a known issue
- Run the commands from the script one by one and see which fails
- compare the failed command with the CI logs
- Another workaround is to delete the local environment and recreate it
- javascript errors: `rm -rf node_modules && npm install`
- native code compile errors: `rm -rf plugins && rm -rf platforms && npx cordova prepare`
Troubleshooting tips have been moved to the e-mission-phone section of the e-mission-docs repo:
https://github.com/e-mission/e-mission-docs/blob/master/docs/e-mission-phone/troubleshooting_tips_faq.md
Create a remote to pull updates from upstream
Debugging
Beta-testing debugging
---
If users run into problems, they have the ability to email logs to the
maintainer. These logs are in the form of an sqlite3 database, so they have to
Expand Down
Loading

0 comments on commit 6349af6

Please sign in to comment.