diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f02281a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: SonarQube +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build and analyze + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'zulu' # Alternative distribution options are available + - name: Cache SonarQube packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Build and analyze + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./gradlew build sonar --info \ No newline at end of file diff --git a/app/src/desktopTest/kotlin/net/cacheux/nvp/app/CsvTest.kt b/app/src/desktopTest/kotlin/net/cacheux/nvp/app/CsvTest.kt index 2ebc890..e979b47 100644 --- a/app/src/desktopTest/kotlin/net/cacheux/nvp/app/CsvTest.kt +++ b/app/src/desktopTest/kotlin/net/cacheux/nvp/app/CsvTest.kt @@ -5,11 +5,18 @@ import net.cacheux.nvp.app.utils.csvToDoseList import net.cacheux.nvp.app.utils.toCsv import net.cacheux.nvp.model.Dose import org.junit.Assert.assertEquals +import org.junit.Before import org.junit.Test import java.time.LocalDateTime import java.time.ZoneOffset +import java.util.TimeZone class CsvTest { + @Before + fun init() { + TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris")) + } + @Test fun testToCsv() { diff --git a/build.gradle.kts b/build.gradle.kts index c74bc37..5ed1402 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,11 +10,13 @@ plugins { alias(libs.plugins.compose.compiler) apply false alias(libs.plugins.hilt.android) apply false alias(libs.plugins.ksp) apply false + alias(libs.plugins.sonarqube) signing } val localProperties by extra { Properties().apply { - load(File("$rootDir/local.properties").inputStream()) + if (File("$rootDir/local.properties").exists()) + load(File("$rootDir/local.properties").inputStream()) } } val gpgSigningAvailable = listOf("gpgSigningKey", "gpgSigningPass").map { @@ -34,3 +36,10 @@ val signingIfAvailable by extra { } } } + +sonar { + properties { + property("sonar.projectKey", "lcacheux_nov-open-reader") + property("sonar.organization", "lcacheux") + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 36e01d6..dd1c717 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,6 +23,7 @@ room = { id = "androidx.room", version.ref = "room" } jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } dokka = { id = "org.jetbrains.dokka", version = "2.0.0" } +sonarqube = { id = "org.sonarqube", version = "6.3.1.5724" } [libraries] colorpicker-compose = { module = "com.github.skydoves:colorpicker-compose", version = "1.1.2" }