How to set up GitHub Actions CI
CI via GitHub actions
This page documents how to configure Github actions CI to execute unit tests and submit coverage to coveralls for the migration from Travis-CI
Android Apps or Libraries Repositories
For android apps use this as the CI config file on the path
.github/workflows/ci.yml
Installing the NDK is might be necessitated by the build version you are using, the given NGD below is for build
29.0.3
# This workflow will build a Java project with Gradle # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle name: Android CI with Gradle on: push: branches: [ master ] pull_request: branches: [ master ] jobs: unit_tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up JDK 1.8 uses: actions/setup-java@v1 with: java-version: 1.8 - name: Install NDK run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.0.6113669" --sdk_root=${ANDROID_SDK_ROOT} - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Run unit tests with Gradle run: ./gradlew :opensrp-chw-core:jacocoTestReport --stacktrace - name: Generate Javadoc with Gradle run: ./gradlew javadoc - name: Upload coverage to Coveralls with Gradle run: ./gradlew coveralls --stacktrace env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
Delete
.travis
fileUpgrade coveralls to the latest version which supports github actions
2.10.2
To upgrade coveralls make the below changes in root build.gradle
buildscript { repositories { maven{ url "https://plugins.gradle.org/m2/" } } } dependencies { classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.10.2' } allprojects { repositories { maven{ url "https://plugins.gradle.org/m2/" } } }
To upgrade coveralls remove older dependencies in application or library build.gradle
buildscript { dependencies { //remove any older coveralls-gradle-plugin depencies } }
Get the repository token from coveralls from
http://coveralls.io/github/OpenSRP/<<your_repo>>
Create a Github secret called COVERALLS_TOKEN with the value retrieved from step 3. Use the this link to create secrets
https://github.com/OpenSRP/<<your_repo>>/settings/secrets/new
Update settings and change branch protection rules to have as mandatory checks while removing travis actions as mandatory
Test and confirm unit tests were run and coveralls check succeeded
Server Repositories
Use below as the CI file. The same procedures for the android apps apply except steps 3-5
ReadME file
Once you have migrated to Github actions replace the Travis badge on ReadME.md
with![Build status](https://github.com/OpenSRP/<project-handle-here>/workflows/Android%20CI%20with%20Gradle/badge.svg)
NB:
The workflow name after /workflow should be URL encoded value of the
ci.yml
name property
Replace
<project-handle-here>
in the example above with the correct project name/handle
This site is no longer maintained. Please visit docs.opensrp.io for current documentation.