Merge pull request #1 from ouchadam/ci
Adding CI pipelines for assembly and testing
This commit is contained in:
commit
e792264b3c
|
@ -0,0 +1,35 @@
|
|||
name: Assemble
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
assemble-debug:
|
||||
name: Assemble debug variant
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
|
||||
- name: Assemble debug variant
|
||||
run: ./gradlew assembleDebug --no-daemon
|
|
@ -0,0 +1,53 @@
|
|||
name: Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
name: Run all unit tests (with coverage)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.8
|
||||
|
||||
- name: Start synapse server
|
||||
run: |
|
||||
pip install matrix-synapse
|
||||
curl -sL https://raw.githubusercontent.com/matrix-org/synapse/develop/demo/start.sh \
|
||||
| bash -s -- --no-rate-limit
|
||||
|
||||
- name: Run all unit tests
|
||||
run: ./gradlew clean allCodeCoverageReport --no-daemon
|
||||
|
||||
- name: Print coverage size
|
||||
run: ls -l ./build/reports/jacoco/allCodeCoverageReport/allCodeCoverageReport.xml
|
||||
|
||||
- uses: codecov/codecov-action@v2
|
||||
with:
|
||||
files: ./build/reports/jacoco/allCodeCoverageReport/allCodeCoverageReport.xml
|
|
@ -1,4 +1,4 @@
|
|||
# SmallTalk [![codecov](https://codecov.io/gh/ouchadam/small-talk/branch/main/graph/badge.svg?token=ETFSLZ9FCI)](https://codecov.io/gh/ouchadam/small-talk)
|
||||
# SmallTalk [![Assemble](https://github.com/ouchadam/small-talk/actions/workflows/assemble.yml/badge.svg)](https://github.com/ouchadam/small-talk/actions/workflows/assemble.yml) [![codecov](https://codecov.io/gh/ouchadam/small-talk/branch/main/graph/badge.svg?token=ETFSLZ9FCI)](https://codecov.io/gh/ouchadam/small-talk)
|
||||
|
||||
`SmallTalk` is a minimal, modern, friends and family focused Android messenger. Heavily inspired by Whatsapp and Signal, powered by Matrix.
|
||||
|
||||
|
|
|
@ -26,68 +26,70 @@ def excludes = [
|
|||
]
|
||||
|
||||
def initializeReport(report, projects, classExcludes) {
|
||||
report.executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
|
||||
|
||||
def includeAndroid = { project, type ->
|
||||
report.sourceDirectories.setFrom(report.sourceDirectories + files(["${project.projectDir}/src/main/kotlin"]))
|
||||
def androidClasses = project.files([project.fileTree(dir: "${project.buildDir}/tmp/kotlin-classes/${type}", excludes: classExcludes)])
|
||||
report.classDirectories.setFrom(androidClasses + report.classDirectories)
|
||||
}
|
||||
|
||||
projects.each { project ->
|
||||
project.apply plugin: 'jacoco'
|
||||
project.afterEvaluate {
|
||||
switch (project) {
|
||||
case { it.plugins.hasPlugin("com.android.application") }:
|
||||
includeAndroid(it, "debug")
|
||||
break
|
||||
case { it.plugins.hasPlugin("com.android.library") }:
|
||||
includeAndroid(it, "release")
|
||||
break
|
||||
default:
|
||||
report.sourceSets it.sourceSets.main
|
||||
report.classDirectories.setFrom(files(report.classDirectories.files.collect {
|
||||
fileTree(dir: it, excludes: classExcludes)
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
projects.each { project -> project.apply plugin: 'jacoco' }
|
||||
report.executionData { fileTree(rootProject.rootDir.absolutePath).include("**/build/jacoco/*.exec") }
|
||||
|
||||
report.reports {
|
||||
xml.enabled true
|
||||
html.enabled true
|
||||
csv.enabled false
|
||||
}
|
||||
|
||||
gradle.projectsEvaluated {
|
||||
def androidSourceDirs = []
|
||||
def androidClassDirs = []
|
||||
|
||||
projects.each { project ->
|
||||
switch (project) {
|
||||
case { project.plugins.hasPlugin("com.android.application") }:
|
||||
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/debug")
|
||||
androidSourceDirs.add("${project.projectDir}/src/main/kotlin")
|
||||
break
|
||||
case { project.plugins.hasPlugin("com.android.library") }:
|
||||
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/release")
|
||||
androidSourceDirs.add("${project.projectDir}/src/main/kotlin")
|
||||
break
|
||||
default:
|
||||
report.sourceSets project.sourceSets.main
|
||||
}
|
||||
}
|
||||
|
||||
report.sourceDirectories.setFrom(report.sourceDirectories + files(androidSourceDirs))
|
||||
def classFiles = androidClassDirs.collect { files(it).files }.flatten()
|
||||
report.classDirectories.setFrom(files((report.classDirectories.files + classFiles).collect {
|
||||
fileTree(dir: it, excludes: classExcludes)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
def collectProjects(predicate) {
|
||||
return subprojects.findAll { it.buildFile.isFile() && predicate(it) }
|
||||
}
|
||||
|
||||
task unitCodeCoverageReport(type: JacocoReport) {
|
||||
rootProject.apply plugin: 'jacoco'
|
||||
def excludedProjects = [
|
||||
'olm-stub',
|
||||
'test-harness'
|
||||
]
|
||||
def projects = collectProjects { !excludedProjects.contains(it.name) }
|
||||
dependsOn ":app:assembleDebug"
|
||||
dependsOn { projects*.test }
|
||||
initializeReport(it, projects, excludes)
|
||||
}
|
||||
|
||||
task harnessCodeCoverageReport(type: JacocoReport) {
|
||||
rootProject.apply plugin: 'jacoco'
|
||||
def projects = collectProjects { true }
|
||||
dependsOn ":app:assembleDebug"
|
||||
dependsOn { project(":test-harness").test }
|
||||
initializeReport(it, projects, excludes)
|
||||
}
|
||||
//task unitCodeCoverageReport(type: JacocoReport) {
|
||||
// outputs.upToDateWhen { false }
|
||||
// rootProject.apply plugin: 'jacoco'
|
||||
// def excludedProjects = [
|
||||
// 'olm-stub',
|
||||
// 'test-harness'
|
||||
// ]
|
||||
// def projects = collectProjects { !excludedProjects.contains(it.name) }
|
||||
// dependsOn { ["app:assembleDebug"] + projects*.test }
|
||||
// initializeReport(it, projects, excludes)
|
||||
//}
|
||||
//
|
||||
//task harnessCodeCoverageReport(type: JacocoReport) {
|
||||
// outputs.upToDateWhen { false }
|
||||
// rootProject.apply plugin: 'jacoco'
|
||||
// def projects = collectProjects { true }
|
||||
// dependsOn { ["app:assembleDebug", project(":test-harness").test] }
|
||||
// initializeReport(it, projects, excludes)
|
||||
//}
|
||||
|
||||
task allCodeCoverageReport(type: JacocoReport) {
|
||||
outputs.upToDateWhen { false }
|
||||
rootProject.apply plugin: 'jacoco'
|
||||
def projects = collectProjects { true }
|
||||
dependsOn ":app:assembleDebug"
|
||||
dependsOn { projects*.test }
|
||||
dependsOn { ["app:assembleDebug"] + projects*.test }
|
||||
initializeReport(it, projects, excludes)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue