From 7ff2487eb951b66fdd5e52e632b0f870147bc5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=A4r?= Date: Tue, 13 Sep 2022 09:19:14 +0200 Subject: [PATCH] #3: CI build (#4) * #3: Added CI build Co-authored-by: Christoph Pirkl --- .github/workflows/broken_links_checker.yml | 27 ++++++++++ .github/workflows/ci_build.yml | 52 +++++++++++++++++++ README.md | 20 ++++--- build.gradle.kts | 19 ++++++- .../intellijplugin}/ShowUserGuideAction.java | 2 +- src/main/resources/META-INF/plugin.xml | 2 +- .../openfasttrace/intelijplugin/MockTest.java | 12 +++++ 7 files changed, 120 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/broken_links_checker.yml create mode 100644 .github/workflows/ci_build.yml rename src/main/java/org/itsallcode/{intellij/oftplugin => openfasttrace/intellijplugin}/ShowUserGuideAction.java (91%) create mode 100644 src/test/java/org/itallcode/openfasttrace/intelijplugin/MockTest.java diff --git a/.github/workflows/broken_links_checker.yml b/.github/workflows/broken_links_checker.yml new file mode 100644 index 0000000..29071df --- /dev/null +++ b/.github/workflows/broken_links_checker.yml @@ -0,0 +1,27 @@ +name: Broken Links Checker + +on: + schedule: + - cron: "0 5 * * 0" + push: + branches: + - main + pull_request: + +jobs: + linkChecker: + runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v3 + - name: Configure broken links checker + run: | + mkdir -p ./target + echo '{ "aliveStatusCodes": [429, 200], "ignorePatterns": [{"pattern": "^https?://(www.)?opensource.org"}] }' > ./target/broken_links_checker.json + - uses: gaurav-nelson/github-action-markdown-link-check@v1 + with: + use-quiet-mode: 'yes' + use-verbose-mode: 'yes' + config-file: ./target/broken_links_checker.json \ No newline at end of file diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml new file mode 100644 index 0000000..7251d03 --- /dev/null +++ b/.github/workflows/ci_build.yml @@ -0,0 +1,52 @@ +name: Java CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Cache SonarQube packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - uses: gradle/wrapper-validation-action@v1 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + cache: 'gradle' + + - name: Build with Gradle + run: ./gradlew clean build --info --warning-mode all + + - name: Publish Test Report + uses: scacap/action-surefire-report@v1 + if: ${{ always() && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }} + with: + report_paths: '**/build/test-results/*/TEST-*.xml' + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Sonar analysis + if: ${{ env.SONAR_TOKEN != null }} + run: | + ./gradlew sonarqube -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.organization=kaklakariada-github \ + -Dsonar.login=$SONAR_TOKEN \ + --info --warning-mode=summary + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index ba1c0b7..13314b6 100644 --- a/README.md +++ b/README.md @@ -6,17 +6,17 @@ [![Build Status](https://github.com/itsallcode/openfasttrrace-intellij-pluginactions/workflows/ci-build.yml/badge.svg)](https://github.com/itsallcode/openfasttrrace-intellij-pluginactions/workflows/ci-build.yml) -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-virtual-schema-lua&metric=alert_status)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-virtual-schema-lua) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aopenfasttrace-intellij-plugin&metric=alert_status)](https://sonarcloud.io/dashboard?id=org.itsallcode%3Aopenfasttrace-intellij-plugin) -[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-virtual-schema-lua&metric=security_rating)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-virtual-schema-lua) -[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-virtual-schema-lua&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-virtual-schema-lua) -[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-virtual-schema-lua&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-virtual-schema-lua) -[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-virtual-schema-lua&metric=sqale_index)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-virtual-schema-lua) +[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aopenfasttrace-intellij-plugin&metric=security_rating)](https://sonarcloud.io/dashboard?id=org.itsallcode%3Aopenfasttrace-intellij-plugin) +[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aopenfasttrace-intellij-plugin&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=org.itsallcode%3Aopenfasttrace-intellij-plugin) +[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aopenfasttrace-intellij-plugin&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=org.itsallcode%3Aopenfasttrace-intellij-plugin) +[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aopenfasttrace-intellij-plugin&metric=sqale_index)](https://sonarcloud.io/dashboard?id=org.itsallcode%3Aopenfasttrace-intellij-plugin) -[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-virtual-schema-lua&metric=code_smells)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-virtual-schema-lua) -[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-virtual-schema-lua&metric=coverage)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-virtual-schema-lua) -[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-virtual-schema-lua&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-virtual-schema-lua) -[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=com.exasol%3Aexasol-virtual-schema-lua&metric=ncloc)](https://sonarcloud.io/dashboard?id=com.exasol%3Aexasol-virtual-schema-lua) +[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aopenfasttrace-intellij-plugin&metric=code_smells)](https://sonarcloud.io/dashboard?id=org.itsallcode%3Aopenfasttrace-intellij-plugin) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aopenfasttrace-intellij-plugin&metric=coverage)](https://sonarcloud.io/dashboard?id=org.itsallcode%3Aopenfasttrace-intellij-plugin) +[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aopenfasttrace-intellij-plugin&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=org.itsallcode%3Aopenfasttrace-intellij-plugin) +[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aopenfasttrace-intellij-plugin&metric=ncloc)](https://sonarcloud.io/dashboard?id=org.itsallcode%3Aopenfasttrace-intellij-plugin) --> ![OFT Logo](doc/images/openfasttrace_logo.svg) @@ -31,14 +31,12 @@ Editor support for writing and maintaining OpenFastTrace documents ### Information for Users -* [User Guide](doc/user_guide/user_guide.md) * [Changelog](doc/changes/changelog.md) ### Information for Contributors Requirement, design documents and coverage tags are written in [OpenFastTrace](https://github.com/itsallcode/openfasttrace) format. -* [Developer Guide](doc/developer_guide/developer_guide.md) * [Getting Started With IntelliJ Plugin Development](doc/developer_guide/getting_started_intellij_plugin_development.md) ### Runtime Dependencies diff --git a/build.gradle.kts b/build.gradle.kts index ff3291e..182c340 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,8 @@ plugins { id("java") - id("org.jetbrains.intellij") version "1.8.0" + id("jacoco") + id("org.jetbrains.intellij") version "1.9.0" + id("org.sonarqube") version "3.4.0.2513" } group = "org.itsallcode" @@ -41,3 +43,18 @@ tasks { token.set(System.getenv("PUBLISH_TOKEN")) } } + +tasks.test { + finalizedBy(tasks.jacocoTestReport) +} +tasks.jacocoTestReport { + dependsOn(tasks.test) + reports { + xml.required.set(true) + } +} + +tasks.sonarqube { + dependsOn(tasks.jacocoTestReport) +} + diff --git a/src/main/java/org/itsallcode/intellij/oftplugin/ShowUserGuideAction.java b/src/main/java/org/itsallcode/openfasttrace/intellijplugin/ShowUserGuideAction.java similarity index 91% rename from src/main/java/org/itsallcode/intellij/oftplugin/ShowUserGuideAction.java rename to src/main/java/org/itsallcode/openfasttrace/intellijplugin/ShowUserGuideAction.java index 41dae2b..f70288d 100644 --- a/src/main/java/org/itsallcode/intellij/oftplugin/ShowUserGuideAction.java +++ b/src/main/java/org/itsallcode/openfasttrace/intellijplugin/ShowUserGuideAction.java @@ -1,4 +1,4 @@ -package org.itsallcode.intellij.oftplugin; +package org.itsallcode.openfasttrace.intellijplugin; import com.intellij.ide.BrowserUtil; import com.intellij.openapi.actionSystem.AnAction; diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 7e00731..8df838a 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -26,7 +26,7 @@ diff --git a/src/test/java/org/itallcode/openfasttrace/intelijplugin/MockTest.java b/src/test/java/org/itallcode/openfasttrace/intelijplugin/MockTest.java new file mode 100644 index 0000000..3efbdfd --- /dev/null +++ b/src/test/java/org/itallcode/openfasttrace/intelijplugin/MockTest.java @@ -0,0 +1,12 @@ +package org.itallcode.openfasttrace.intelijplugin; + +import org.junit.Test; + +public class MockTest { + // This is a test that only exists to have a single test result in the test report. It is required to find out if + // the CI build works. It will be removed with a later PR once real tests exist. + @Test + public void testNothing(){ + // empty on purpose. + } +}