Skip to content

Commit

Permalink
feat(github-actions): added testing and code coverage in ci
Browse files Browse the repository at this point in the history
also fixed build.gradle issues from pr commits
  • Loading branch information
shinybrar committed Nov 7, 2024
1 parent 4eafb62 commit 4e207a5
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/ci.testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "CI: Testing"

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'

- name: Run Tests
run: |
cd skaha
./gradlew clean check
-
name: Upload coverage artifacts
uses: actions/[email protected]
with:
name: skaha-unittests-coverage
path: build/reports/jacoco/test/jacocoTestReport.xml
if-no-files-found: error
retention-days: 1
overwrite: true

codecov:
runs-on: ubuntu-latest
needs: tests
steps:
-
name: Download coverage artifacts
uses: actions/[email protected]
with:
name: skaha-unittests-coverage
path: jacocoTestReport.xml
-
name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: jacocoTestReport.xml
flags: skaha-unittests-coverage
name: skaha-unittests-coverage
fail_ci_if_error: true
15 changes: 13 additions & 2 deletions skaha/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
plugins {
id 'war'
id 'maven-publish'
id("com.diffplug.spotless") version "6.25.0"
id 'com.diffplug.spotless' version '6.25.0'
id 'java'
id 'jacoco'
}

repositories {
Expand Down Expand Up @@ -49,7 +51,7 @@ dependencies {

runtimeOnly 'org.opencadc:cadc-registry:[1.3.5,)'

testImplementation 'junit:junit:[4.0,)'
testImplementation 'junit:junit:[4.13,)'
testImplementation 'org.json:json:20231013'
testImplementation 'org.mockito:mockito-core:5.12.0'
}
Expand All @@ -75,3 +77,12 @@ spotless {
endWithNewline()
}
}

jacocoTestReport {
reports {
xml.enabled true
html.enabled true
}
}

check.dependsOn jacocoTestReport
1 change: 0 additions & 1 deletion skaha/opencadc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ task intTest(type: Test) {
// set the configuration context
testClassesDirs = sourceSets.intTest.output.classesDirs
classpath = sourceSets.intTest.runtimeClasspath

// run the tests always
outputs.upToDateWhen { false }
}
Expand Down

0 comments on commit 4e207a5

Please sign in to comment.