Skip to content

Commit

Permalink
Fix sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieaer committed Apr 14, 2024
1 parent b6092c7 commit c71b1bc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: test
uses: actions/checkout@v3
run: ./gradlew jacocoTestReport
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
Expand Down
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.github.node-gradle.node") version "5.0.0"
id("maven-publish")
id("jacoco")
}

java {
Expand Down Expand Up @@ -185,4 +186,12 @@ publishing {
from(components["java"])
}
}
}

tasks.jacocoTestReport {
dependsOn("test")
reports {
xml.required.set(true)
xml.outputLocation.set(file("build/reports/jacoco/test/jacoco.xml"))
}
}
6 changes: 4 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ sonar.organization=kieaer
#sonar.projectName=Essentials
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
sonar.sourceEncoding=UTF-8

sonar.coverage.jacoco.xmlReportPaths = build/reports/jacoco/test/jacoco.xml
sonar.java.coveragePlugin = jacoco
28 changes: 17 additions & 11 deletions src/test/kotlin/FeatureTest.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ClientCommandTest.Companion.playerData
import PluginTest.Companion.clientCommand
import PluginTest.Companion.loadGame
import PluginTest.Companion.loadPlugin
Expand All @@ -14,24 +15,29 @@ import org.junit.Test


class FeatureTest {
private var done = false
lateinit var playerData: DB.PlayerData

@BeforeClass
fun setup() {
if (!done) {
loadGame()
loadPlugin()
companion object {
var done = false

val p = newPlayer()
Vars.player = p.first.self()
player = p.first.self()
playerData = p.second
@BeforeClass
@JvmStatic fun setup() {
if (!done) {
loadGame()
loadPlugin()

done = true
val p = newPlayer()
Vars.player = p.first.self()
player = p.first.self()
playerData = p.second

done = true
}
}
}



@Test
fun pvpBalanceTest() {
// Require user or above permission
Expand Down
6 changes: 1 addition & 5 deletions src/test/kotlin/PluginTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ import java.lang.Thread.sleep
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.sql.Connection
import java.sql.DriverManager
import java.sql.ResultSet
import java.sql.Statement
import java.text.MessageFormat
import java.util.*
import java.util.zip.ZipFile
Expand Down Expand Up @@ -311,7 +307,7 @@ class PluginTest {

// Copy Essentials 14.1 database
val file = Paths.get("src", "test", "resources", "database-v0.db").toFile()
val desc = File(Config.database + ".mv.db")
val desc = File("database.mv.db")
file.copyRecursively(desc, true)
println(Config.database)

Expand Down

0 comments on commit c71b1bc

Please # to comment.