Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 77 additions & 22 deletions .github/workflows/jacoco_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,98 @@
# limitations under the License.
#

name: JaCoCo report
name: CI JaCoCo Report

on:
pull_request:
branches: [ master ]
types: [ opened, edited, synchronize, reopened ]

permissions:
contents: read

# Cancel superseded runs on the same ref to save runner minutes.
concurrency:
group: jacoco-report-${{ github.ref }}
cancel-in-progress: true

env:
# hint: "group thresholds" are in format: 'overall*changed-files-average*per-changed-file'
REPORT_GROUPS: |
- name: login-service-api
paths:
- '**/api/target/**/jacoco-report/jacoco.xml'
thresholds: '73*80*60'
- name: login-service-client-library
paths:
- '**/clientLibrary/target/**/jacoco-report/jacoco.xml'
thresholds: '62*80*60'

jobs:
test:
detect:
name: Detect Changed Files
runs-on: ubuntu-latest
strategy:
matrix:
include:
- scala: 2.12.17
scala_short: 2.12
overall: 0.0
changed: 80.0
timeout-minutes: 2
outputs:
scala_changed: ${{ steps.filter.outputs.scala }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
persist-credentials: false
fetch-depth: 0
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d
id: filter
with:
token: ""
filters: |
scala:
- '**/*.scala'
- '!project/**'
Comment thread
tmikula-dev marked this conversation as resolved.

jacoco-report:
name: JaCoCo Report
needs: detect
if: needs.detect.outputs.scala_changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
persist-credentials: false
fetch-depth: 0

- name: Setup Scala
uses: olafurpg/setup-scala@v10
uses: olafurpg/setup-scala@32ffa16635ff8f19cc21ea253a987f0fdf29844c
with:
java-version: "openjdk@1.17"
- name: Build and run tests
run: sbt ++${{matrix.scala}} jacoco

- name: Build and run tests with coverage
continue-on-error: true
run: sbt jacoco
Comment thread
tmikula-dev marked this conversation as resolved.

- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: '3.14'

- name: Add JaCoCo Report in PR comments
uses: MoranaApps/jacoco-report@v2
uses: MoranaApps/jacoco-report@48921080d110bb49247b55a5d23f79e688577ef0
with:
token: '${{ secrets.GITHUB_TOKEN }}'
paths: |
**/target/jacoco/report/jacoco.xml
min-coverage-overall: 43.0
min-coverage-changed-files: 70.0
sensitivity: "detail"
comment-mode: 'multi'
token: ${{ secrets.GITHUB_TOKEN }}
global-thresholds: '71*73'
report-thresholds-default: '62*80*60'
skip-unchanged: 'true'
evaluate-unchanged: 'false'
report-groups: ${{ env.REPORT_GROUPS }}

noop:
name: No Operation
needs: detect
if: needs.detect.outputs.scala_changed != 'true'
runs-on: ubuntu-latest
steps:
- run: echo "No changes in Scala related files — passing."
7 changes: 7 additions & 0 deletions .sbtrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Jacoco Aliases
alias jacoco=; jacocoOn; jacocoApi; jacocoClientLibrary; jacocoOff
alias jacocoOn=; set every jacocoPluginEnabled := true
alias jacocoOff=; set every jacocoPluginEnabled := false

alias jacocoApi=; project api; clean; test; jacocoReportAll
alias jacocoClientLibrary=; project clientLibrary; clean; test; jacocoReportAll
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import za.co.absa.loginsvc.rest.config.validation.ConfigValidationException
import za.co.absa.loginsvc.rest.provider.ConfigUsersAuthenticationProvider
import za.co.absa.loginsvc.rest.provider.ad.ldap.ActiveDirectoryLDAPAuthenticationProvider

import scala.collection.immutable.SortedMap

/**
* This class registers the authManager bean that is responsible for users to be able to "login" using their credentials
* based on the config
Expand Down
19 changes: 2 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,16 @@ lazy val scala213 = "2.13.13"
ThisBuild / scalaVersion := scala212
ThisBuild / versionScheme := Some("early-semver")

lazy val commonJacocoExcludes: Seq[String] = Seq(
"za.co.absa.loginsvc.rest.Application*"
// "za.co.absa.loginsvc.rest.config.BaseConfig" // class only
)

lazy val commonJavacOptions = Seq("-source", "1.8", "-target", "1.8", "-Xlint") // deliberately making backwards compatible with J8

addCommandAlias("runLocal", "api/run --spring.config.location=api/src/main/resources/local.application.yaml")

lazy val parent = (project in file("."))
.aggregate(api, clientLibrary, examples)
.enablePlugins(FilteredJacocoAgentPlugin)
.settings(
name := "login-service",
javacOptions ++= commonJavacOptions,
publish / skip := true,
// Global defaults (override per-module below if you wish)
FilteredJacocoAgentPlugin.autoImport.jacocoIncludes := Seq("za.co.absa.*"),
FilteredJacocoAgentPlugin.autoImport.jacocoExcludes ++= commonJacocoExcludes,
FilteredJacocoAgentPlugin.autoImport.jacocoFailOnMissingExec := false
)

lazy val api = project // no need to define file, because path is same as val name
Expand All @@ -58,7 +48,7 @@ lazy val api = project // no need to define file, because path is same as val na
run / javaOptions += "-Djavax.net.ssl.trustStoreType=KeychainStore" // use macOS Keychain CA certs (corporate proxy)
).enablePlugins(TomcatPlugin)
.enablePlugins(AutomateHeaderPlugin)
.enablePlugins(FilteredJacocoAgentPlugin)
.enablePlugins(JacocoFilterPlugin)

lazy val clientLibrary = project // no need to define file, because path is same as val name
.settings(
Expand All @@ -67,7 +57,7 @@ lazy val clientLibrary = project // no need to define file, because path is same
javacOptions ++= commonJavacOptions,
crossScalaVersions := Seq(scala212, scala213)
).enablePlugins(AutomateHeaderPlugin)
.enablePlugins(FilteredJacocoAgentPlugin)
.enablePlugins(JacocoFilterPlugin)

lazy val examples = project // no need to define file, because path is same as val name
.settings(
Expand All @@ -77,8 +67,3 @@ lazy val examples = project // no need to define file, because path is same as v
publish / skip := true
).enablePlugins(AutomateHeaderPlugin)
.dependsOn(clientLibrary)

// Run activate jacoco + clean + test + per-module reports across the whole build + deactivate jacoco
addCommandAlias("jacoco", "; jacocoOn; clean; test; jacocoReportAll; jacocoOff")
addCommandAlias("jacocoOff", "; set every jacocoPluginEnabled := false")
addCommandAlias("jacocoOn", "; set every jacocoPluginEnabled := true")
Loading
Loading