/sglandtransport

Public (and private - soon) transport made easy

Primary LanguageDartMIT LicenseMIT

SG Land Transport

GitHub Twitter handle

Test Deploy to Testflight Deploy to Google play store beta

codecov

Public transport made easy, providing screens and functionality based on APIs that are exposed by the LTA Datamall (https://www.mytransport.sg/content/mytransport/home/dataMall.html)

Download official apps

Download on Google Play Download on App Store

Contributing

Refer to the Contributing Guidelines.

Code of Conduct

Our code of conduct is based on the Contributor Covenant.

Prerequisites

Flutter

LTA Datamall API key

If you use VSCode, we recommend you create a launch.json file that launches the flutter run command with this argument, so that you can use the standard debug functionality of VSCode, rather than running your debug build via the command line.

Example launch.json file:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Flutter",
      "request": "launch",
      "type": "dart",
      "args": [
        "--dart-define=LTA_DATAMALL_API_KEY=<your LTA Datamall API key goes here>"
      ]
    }
  ]
}

To run it from command line:

flutter run --dart-define=LTA_DATAMALL_API_KEY=<add your key here>

A key can be generated following the guildeines of

You can generate a key following the guidelines of the Land Transport Datamall.

Google Firebase

Follow these instructions to add the necessary files related to Google Firebase services.

Code Generation

This project uses build runner to generate Models, Routes and other things.

Generate once

flutter pub run build_runner build --delete-conflicting-outputs

Watch and generate on change

flutter pub run build_runner watch --delete-conflicting-outputs

Running tests

Installing dependences

brew install lcov

Run tests, generate coverage files and convert to HTML

./prepare_test_coverage.sh lta_datamall_flutter
flutter test --coverage
lcov --list coverage/lcov.info
genhtml coverage/lcov.info --output=coverage

Run Integration (UI) Tests

flutter drive --target=test_driver/app.dart --dart-define=LTA_DATAMALL_API_KEY=<your LTA Datamall API key>

Deployments

TestFlight

GitHub Actions

TBD

Manually from Dev Machine

Ensure you have an SSH key properly set up. You can follow this guideline from GitHub. When creating the SSH key, ensure to leave the passphrase empty!

To test if you have the necessary rights and all is setup correctly, please try to run git clone git@github.com:bytecrumbs/certificates.git, which should complete successfully, without prompting any passphrase.

Once the above works successfully, you can create a new Testflight version manually from your local machine using following steps:

# generate required files using build_runner
flutter pub run build_runner build --delete-conflicting-outputs

# ensure the tests are passing
flutter test

# ensure you have the correct fastlane version installed
cd ios
bundle install

# store the version number in an environment variable
RELEASE_VERSION=<version_number>
export RELEASE_VERSION

# configure App Store Connect API
ASCAPI_KEY_ID=<key_id>
export ASCAPI_KEY_ID
ASCAPI_ISSUER_ID=<issuer_id>
export ASCAPI_ISSUER_ID
ASCAPI_KEY_CONTENT=<key_content>
export ASCAPI_KEY_CONTENT

# set new version and build number
bundle exec fastlane set_release_version

# build a release version of the app
flutter build ios --release --no-codesign --dart-define=LTA_DATAMALL_API_KEY=<your LTA Datamall API key>

# upload the built version to Testflight
bundle exec fastlane beta

There is no need to push the changes that bundle exec fastlane set_release_version has caused, you can savely discard those changes, as they will be overwritten again with above commands when the next build is produced.

iOS TestFlight from CI/CD:

cd ios
bundle exec fastlane testflight_from_ci

Note: Authentication with Apple services: Several Fastlane actions communicate with Apple services that need authentication. This can pose several challenges on CI. More info, use this link: https://docs.fastlane.tools/best-practices/continuous-integration/#application-specific-passwords

An Apple ID session is only valid for a certain region, meaning if your CI system is in a different region than your local machine, you might run into issues An Apple ID session is only valid for up to a month, meaning you'll have to generate a new session every month. Usually you'd only know about it when your build starts failing

iOS Firebase App Distribution from Local:

Upload build using Fastlane

  1. Set up fastlane and Add App Distribution to your fastlane configuration
bundle exec fastlane add_plugin firebase_app_distribution
  1. Authenticate With Firebase

To install the Firebase CLI using the automatic install script

curl -sL https://firebase.tools | bash
  1. Log into Firebase using your Google account
firebase login:ci
  1. Get the token and set FIREBASE_TOKEN
export FIREBASE_TOKEN=token_from_ci

Android internal test track:

cd android
bundle exec fastlane deploy_internal

Production deployments

Submit for Apple Review

cd ios
bundle exec fastlane submit_review

Screenshot Commandline utility

Installing dependencies

brew update && brew install imagemagick
pub global activate screenshots

Note: If pub is not found, add to PATH using:

On macOS:

export PATH="<path to flutter installation directory>/bin/cache/dart-sdk/bin:$PATH"

Usage

To create screenshots to upload via fastlane, run following command without any mode.

screenshots

If mode is recording, screenshots will be saved for later comparison

screenshots -m recording

If mode is archive, screenshots will be archived (and cannot be uploaded via fastlane).

screenshots -m archive

Generate new set of app icon

  1. Place your icon app-icon.png image in images/ folder
  2. Run the following command flutter pub run flutter_launcher_icons:main

Maintainers