Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

uclapi/ucl-assistant-app

 
 

Repository files navigation

NOTE: The UCL Assistant app has been rewritten and now lives in @uclapi/ucl-assistant-app-flutter.


Powered by UCL API Build Status codecov

UCL Assistant is a new and beautiful app to manage your student life at UCL!

Get it on the App Store Get it on Google Play

Contributing

Building from source

You'll need the Expo XDE client or the Expo command line client. Get them from here. You'll also need Yarn or NPM installed.

Copy app.example.json to app.json and add your own Google Maps API key and either modify or delete the Sentry sourcemap hook. Remember to update the APP_JSON env variable in Travis if you modify app.json.

The Google Maps API key is optional but without it you won't be able to use Maps on Android. You'll want to create an API key on the Google APIs console and then give the key access to the Google Maps Android API.

Install the necessary dependencies with npm i

Then you can start the app with npm run start. If you're using WSL, then you may need to set the RN packager host to your actual IP address instead of the WSL IP address using export REACT_NATIVE_PACKAGER_HOSTNAME=192.168.x.x, or do port-forwarding over adb debugging.

Which API server?

Source code for the UCL Assistant API Server is available here. It is hosted at ucl-assistant.uclapi.com

Saving user data

The app uses redux-persist to save the app state to the device storage. In the future, for extra security, the user reducer will be saved using the Expo.SecureStore API.

Committing

Our git commit message template can be found here. We lint commit messages with commitlint. You can optionally use the interactive commit prompt (git add . -A && npm run commit) to ensure your commit message complies with our commit message template.

Deployment

Expo allows us to update the app seamlessly OTA. To publish the latest version of UCL Assistant over-the-air via Expo:

$ npm run publish

To build a APK/IPA, which will also publish the current version of UCL Assistant

$ npm run build

To upload the APK/IPA to the Play/App Store.

$ npm run upload

When uploading to the Play Store, there should be an android.json containing the credentials for the service account in the project root folder. This is the credentials JSON file that can be obtained from the Google Developers Console (see android.example.json).

When uploading to the App Store, there should be an ios.json containing the credentials for the App Store Connect account (see ios.example.json).

Manual Deployment

To manually publish:

expo publish --release-channel production-[VERSION CODE]

[VERSION CODE] should follow semantic versioning, e.g. 2.0.0.

Similarly, to create a new app binary (when native code is modified, e.g. for an Expo SDK update)

expo build:android --release-channel production-[VERSION CODE]
expo build:ios --release-channel production-[VERSION CODE]

Travis

When updating APP_JSON in Travis, use this format: "$(echo -e ' {JSON_CONTENT} ')" or simply wrap it with single quotes

Testing

We use Jest for testing.

jest/test-utils.tsx contains custom utility functions:

  • a custom render function that mocks our Redux store and navigation container
  • a waitForEventLoop function that returns a Promise which returns only after the current async queue is completed
    • redux-persist is tricky to mock. Amongst other things, it requires jest.useFakeTimers(), which doesn't play well with setTimeout or setInterval. waitForEventLoop therefore temporarily sets jest.useRealTimers() before switching back to fake timers