From 0ba60afc1487661bcca4596a627010b7f41d5d6e Mon Sep 17 00:00:00 2001 From: Tobias Lehmann Date: Tue, 10 Sep 2024 17:21:27 +0200 Subject: [PATCH] added quality checks for java projects --- .gitea/workflows/build-java.yaml | 2 +- .gitea/workflows/quality-java.yaml | 44 +++++++++++++++++++ .../{create.quality.yaml => quality.yaml} | 8 ---- 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 .gitea/workflows/quality-java.yaml rename .gitea/workflows/{create.quality.yaml => quality.yaml} (87%) diff --git a/.gitea/workflows/build-java.yaml b/.gitea/workflows/build-java.yaml index 92d9a3b..a079860 100644 --- a/.gitea/workflows/build-java.yaml +++ b/.gitea/workflows/build-java.yaml @@ -18,7 +18,7 @@ jobs: java-version: '21' - name: Run gradle build process run: | - ./gradlew build + ./gradlew build - name: Upload build artifacts uses: actions/upload-artifact@v3 with: diff --git a/.gitea/workflows/quality-java.yaml b/.gitea/workflows/quality-java.yaml new file mode 100644 index 0000000..95eca88 --- /dev/null +++ b/.gitea/workflows/quality-java.yaml @@ -0,0 +1,44 @@ +name: SonarQube Scan +on: + workflow_call: +jobs: + sonarqube: + name: SonarQube Trigger + runs-on: ubuntu-latest + steps: + - name: Checking out + uses: actions/checkout@v4 + with: + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 + + - name: Setup java runtime + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '21' + + - name: Run gradle build process + run: | + ./gradlew build + + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@master # Ex: v2.1.0, See the latest version at https://github.com/marketplace/actions/official-sonarqube-scan + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }} + + # Check the Quality Gate status. + - name: SonarQube Quality Gate check + id: sonarqube-quality-gate-check + uses: sonarsource/sonarqube-quality-gate-action@master + # Force to fail step after specific time. + timeout-minutes: 5 + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }} + + # Optionally you can use the output from the Quality Gate in another step. + # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`. + - name: "Example show SonarQube Quality Gate Status value" + run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" \ No newline at end of file diff --git a/.gitea/workflows/create.quality.yaml b/.gitea/workflows/quality.yaml similarity index 87% rename from .gitea/workflows/create.quality.yaml rename to .gitea/workflows/quality.yaml index 45c6119..f727528 100644 --- a/.gitea/workflows/create.quality.yaml +++ b/.gitea/workflows/quality.yaml @@ -11,14 +11,6 @@ jobs: with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 - - - name: Download build artifacts (dist files) - uses: actions/download-artifact@v3 - with: - name: artifacts-build - path: | - build/ - dist/ - name: SonarQube Scan uses: sonarsource/sonarqube-scan-action@master # Ex: v2.1.0, See the latest version at https://github.com/marketplace/actions/official-sonarqube-scan