Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/sonar_maven.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Sonar for Maven

on:
workflow_call:

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: Check for pom.xml
id: check_pom
run: |
if git ls-files "pom.xml" "**/pom.xml" | grep -q "."; then
echo "pom.xml found"
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "No pom.xml found"
echo "found=false" >> "$GITHUB_OUTPUT"
fi

- name: Set up JDK 17
if: steps.check_pom.outputs.found == 'true'
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.

- name: Cache SonarQube packages
if: steps.check_pom.outputs.found == 'true'
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Maven packages
if: steps.check_pom.outputs.found == 'true'
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build and analyze
if: steps.check_pom.outputs.found == 'true'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.organization=woped -Dsonar.projectKey=woped_${{ github.event.repository.name }} -Dsonar.host.url=https://sonarcloud.io
7 changes: 6 additions & 1 deletion .github/workflows/template_CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ jobs:
linting:
uses: woped/devops/.github/workflows/linting.yaml@main
testing_maven:
uses: woped/devops/.github/workflows/testing_maven.yaml@main
uses: woped/devops/.github/workflows/testing_maven.yaml@feature/main
sonar_maven:
needs: testing_maven
uses: woped/devops/.github/workflows/sonar_maven.yaml@feature/main
secrets: inherit

testing_pytest:
uses: woped/devops/.github/workflows/testing_pytest.yaml@main
sonar_python:
Expand Down