diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 77c251a..47a84e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -137,6 +137,7 @@ jobs: - name: Upload Code Coverage Report uses: codecov/codecov-action@v4 with: + token: ${{secrets.CODECOV_TOKEN}} files: ${{ github.workspace }}/build/reports/kover/report.xml # Run Qodana inspections and provide report @@ -174,6 +175,12 @@ jobs: with: cache-default-branch-only: true + # Upload results to CodeQL + - name: CodeQL - Upload SARIF + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json + # Run plugin structure verification along with IntelliJ Plugin Verifier verify: name: Verify plugin diff --git a/CHANGELOG.md b/CHANGELOG.md index d3d81de..22223e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ # Pedro Progress Bar Changelog ## [Unreleased] +- Various dependency updates + +## [0.0.2] ### Added - Prepare next plugin version diff --git a/build.gradle.kts b/build.gradle.kts index 065b81b..565bf74 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,11 +6,11 @@ fun environment(key: String) = providers.environmentVariable(key) plugins { id("java") // Java support - id("org.jetbrains.kotlin.jvm") version "2.0.0" // Kotlin support - id("org.jetbrains.intellij") version "1.17.4" // Gradle IntelliJ Plugin - id("org.jetbrains.changelog") version "2.2.0" // Gradle Changelog Plugin - id("org.jetbrains.qodana") version "2024.1.5" // Gradle Qodana Plugin - id("org.jetbrains.kotlinx.kover") version "0.8.1" // Gradle Kover Plugin + alias(libs.plugins.kotlin) // Kotlin support + alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin + alias(libs.plugins.changelog) // Gradle Changelog Plugin + alias(libs.plugins.qodana) // Gradle Qodana Plugin + alias(libs.plugins.kover) // Gradle Kover Plugin } group = properties("pluginGroup").get() @@ -23,7 +23,7 @@ repositories { // Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog dependencies { -// none + testImplementation(libs.junit5) } // Set the JVM language level used to build the project. @@ -108,6 +108,10 @@ tasks { systemProperty("jb.consents.confirmation.enabled", "false") } + test { + useJUnitPlatform() + } + signPlugin { certificateChain = environment("CERTIFICATE_CHAIN") privateKey = environment("PRIVATE_KEY") diff --git a/gradle.properties b/gradle.properties index a9300c6..8aae7df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.github.strangelookingnerd pluginName = pedro-progress-bar pluginRepositoryUrl = https://github.com/strangelookingnerd/pedro-progress-bar-plugin # SemVer format -> https://semver.org -pluginVersion = 0.0.2 +pluginVersion = 0.0.3 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 232 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..9685ec0 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,20 @@ +[versions] +# libraries +junit5 = "5.10.2" + +# plugins +kotlin = "2.0.0" +changelog = "2.2.0" +gradleIntelliJPlugin = "1.17.4" +qodana = "2024.1.5" +kover = "0.8.1" + +[libraries] +junit5 = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit5" } + +[plugins] +changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } +gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" } +kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } +qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" } diff --git a/src/test/java/com/github/strangelookingnerd/PedroIconsTest.java b/src/test/java/com/github/strangelookingnerd/PedroIconsTest.java new file mode 100644 index 0000000..e022445 --- /dev/null +++ b/src/test/java/com/github/strangelookingnerd/PedroIconsTest.java @@ -0,0 +1,64 @@ +/* + * The MIT License + * + * Copyright (c) 2024 strangelookingnerd + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.github.strangelookingnerd; + +import com.intellij.ui.scale.JBUIScale; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import javax.swing.ImageIcon; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class PedroIconsTest { + + private static final Pattern DESCRIPTION_PATTERN = Pattern.compile("^Pedro (\\d\\d)x(\\d\\d)$"); + + @ParameterizedTest + @ValueSource(floats = {0.75F, 1F, 1.1F, 1.25F, 1.5F, 1.75F, 2F, 3F}) + void testScaling(float scaleFactor) { + JBUIScale.setUserScaleFactorForTest(scaleFactor); + + ImageIcon icon = PedroIcons.getScaledIcon(); + assertNotNull(icon); + + if (scaleFactor < 1F || scaleFactor > 2F) { + assertNull(icon.getImage()); + assertNull(icon.getDescription()); + } else { + assertNotNull(icon.getImage()); + + Matcher matcher = DESCRIPTION_PATTERN.matcher(icon.getDescription()); + assertTrue(matcher.matches()); + assertEquals(Integer.valueOf(matcher.group(1)), icon.getIconWidth()); + assertEquals(Integer.valueOf(matcher.group(2)), icon.getIconHeight()); + } + } +} \ No newline at end of file