Tag: Bitrise

Setup ngTest step on Bitrise.io

Bitrise’s buit-in karma jasmine testRunner seems out-of-date, every time gives error:

‘@angular-devkit/build-angular/plugins/karma’ karma plugin is meant to be used from within Angular CLI and will not work correctly outside of it.

It’s not hard to create a script step, things to do:

1. Download chrome.

brew update && brew cask install chromedriver google-chrome

Quite often, we got checksum error, possible cause, network cache, solution: directly run script from github repo, ideally from your forked repo to avoid cache.

brew cask install https://raw.githubusercontent.com/maodd/homebrew-cask/master/Casks/google-chrome.rb

2. Run ngTest, non-watch mode, so it can close itself after done.

./node_modules/@angular/cli/bin/ng test –watch=false –code-coverage

3. (Optional) Collect code coverage report.

The challenge here is Bitrise can deploy a folder as artifact, we need to find a way display report in single html file, also to keep the original multiple test files as many as possible.

We use a html-inline npm package to compact test report files, also zip the whole test result into a single file, and artifact both files.

if [ -d "$BITRISE_SOURCE_DIR/coverage" ]; then
   zip -r $BITRISE_DEPLOY_DIR/coverage.zip $BITRISE_SOURCE_DIR/coverage
   npm i -g html-inline
   html-inline -i $BITRISE_SOURCE_DIR/coverage/index.html -o coverage.html
   cp coverage.html $BITRISE_DEPLOY_DIR

The artifacts for each build looks like this:

Screen Shot 2020-04-03 at 9.20.20 AM.png

Subfolder links inside the coverage report won’t work, but it’s good enough for us, until we can find a better html-package tool.

Distribute Internal/Beta Mobile Apps

If you have apps do not want to publish to general public, e.g. internal or beta apps, keep reading.

For iOS apps, for far the best solution is still TestFlight, the best advantage is no need to collect end users UUID, like the adHoc way distribution. The Beta TestFlight also has public link feature.

For Android apps, google Playstore alpha/beta release is OK, but you need to collect tester’s google id, refresh time always has delay.

For small distribution, DeployGate Free plan provides 20 devices, with auto-update and public url features, can be a good choice.

If distribution larger than 20, if you already use bitrise.io as CI, currently their Ship(beta) is fairly easy to use, just ensure you have the Deploy to bitrise step at version 1.9.x+.

Also, since by default, bitrise keep both unsigned and signed apk as deploy artifacts, the ship(beta) just simply use the first one as distribution target, it would be a good idea just set the signed apk to deploy.

Screen Shot 2020-04-01 at 10.44.12 AM.png

You will get a nice public page for this signed APK, most of time.

Screen Shot 2020-04-01 at 11.22.49 AM.png

Since ship is still in beta. Sometimes you might get a heroku error. 😦

Screen Shot 2020-04-01 at 10.53.52 AM.png