# Kotlin
# Configuration sample
default:
workspace: shared
stages:
- test
- release
jobs:
- name: detekt
stage: test
image: 30121999/sunci-detekt:latest
script:
- java -jar /usr/local/bin/detekt-cli-all.jar --all-rules
- name: coverage
stage: test
image: gradle:6.6.1-jdk11
script:
- gradle jacocoTestReport
coverage:
type: jacoco
path: coverage.xml
artifacts:
paths:
- coverage
expires_in: 3 days
- name: realease apk
stage: release
image: 30121999/sunci-fastlane-firebase:latest
script:
- fastlane add_plugin firebase_app_distribution
- export GOOGLE_APPLICATION_CREDENTIALS=./firebase-admin-sdk-key.json
- fastlane releaseApkByFirebase
Please add the .sun-ci.yml
file to your application to proceed.
# Check convention using detekt
Using the sunci-detekt docker image written by Sun* CI on docker hub. Allows to run detekt test convention using Command Line Interface.
Run the following command to see the options of detekt:
$ java -jar /usr/local/bin/detekt-cli-all.jar
# 2. Run unit test with code coverage use Jacoco
Using the gradle:6.6.1-jdk11
docker image on docker hub.
The .sun-ci.yml
example above uses Gradle to test and generate the Jacoco XML result file.
To get started, apply the JaCoCo Plugin to the Kotlin project you want to calculate code coverage for.
For projects that also apply the Java Plugin, the JaCoCo plugin automatically adds the following tasks:
jacocoTestReport — JacocoReport
Generates code coverage report for the test task.
jacocoTestCoverageVerification — JacocoCoverageVerification
Verifies code coverage metrics based on specified rules for the test task.
By default, a HTML report is generated at $buildDir/reports/jacoco/test
.
Depending on your usecases, you may want to always generate the jacocoTestReport or run the test task before generating the report explicitly.
After apply the JaCoCo Plugin to the project and customizing the jacocoTestReport task to suit your project, run the following command to generate the report coverage:
$ gradle jacocoTestReport
Remember to define the type as jacoco
and path of coverage result file to coverage.xml
in your project in coverage
parameter.
Then add the path to the files and folders for upload to the artifacts
.
# Auto release apk use fastlane & firebase
Using the sunci-fastlane-firebase docker image written by Sun* CI on docker hub. fastlane-firebase docker image based on ruby image. Used to run the fastlane and distribute your app using firebase.
fastlane is the easiest way to automate beta deployments and releases for your IOS or Android apps.
It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application.
Please visit fastlane page fore more detail.
You can see the newly created ./fastlane
directory, with the following files:
Appfile
which defines configuration information that is global to your app
Fastfile
which defines the "lanes" that drive the behavior of fastlane, contains all the information that is needed to distribute your app.
Firebase App Distribution makes distributing your apps to trusted testers painless. This guide describes how to distribute APK builds to testers using fastlane, an open source platform that automates building and releasing iOS and Android apps. It follows simple instructions defined in a Fastfile. After you set up fastlane and your Fastfile, you can integrate App Distribution with your fastlane configuration. Find all tutorials on Distribute Android apps to testers using fastlane.
See the release apk
job in the .sun-ci.yml
example above follow these steps:
Set up fastlane and add firebase_app_distribution: Fastlane installation and setup was done by the sunci-fastlane-firebase docker image. To add App Distribution to your fastlane configuration, run the following command:
fastlane add_plugin firebase_app_distribution
Authenticate with Firebase: Before you can use the Fastlane plugin, you must first authenticate with your Firebase project. To authenticate a service account and authorize it to access Firebase services, you must generate a private key file in JSON format. You can do this guide to create this file. Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the file path of the JSON file that contains your service account key as follows:
export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/service-account-file.json"
After you have completed the above steps then your firebase account is signed in.Set up your Fastfile and distribute your app: In a
./fastlane/Fastfile
lane, add areleaseApkByFirebase
lane. Use the following firebase_app_distribution parameters to configure the distribution. Finally, to make the build available to testers, run your lane:
fastlane releaseApkByFirebase