Skip to content

Commit

Permalink
enabled SonarCloud analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Dec 12, 2022
1 parent d7db527 commit ef525cc
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ jobs:
env:
DISPLAY: :1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

# for external PRs the secret token is not available
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2.5.0
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v3.6.0
with:
Expand All @@ -28,6 +33,7 @@ jobs:
with:
path: |
~/.m2
~/.sonar/cache
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml', '**/*.target') }}
restore-keys: ${{ runner.os }}-m2-
- name: Install and start Metacity window manager
Expand All @@ -39,7 +45,7 @@ jobs:
metacity --sm-disable --replace 2> metacity.err &
- name: Set Maven Additional Goals
run: |
echo "COVERALLSGOAL=coveralls:report" >> $GITHUB_ENV
echo "COVERALLSGOAL=coveralls:report sonar:sonar -Dsonar.projectKey=eclipse-emf-parsley_emf-parsley" >> $GITHUB_ENV
if: ${{ env.COVERALLS_REPO_TOKEN }}
# for external PRs the repo token is not defined
# and we don't upload coverage to coveralls
Expand Down
56 changes: 46 additions & 10 deletions releng/org.eclipse.emf.parsley.parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,51 @@
<tycho.scmUrl>scm:git:git://git.eclipse.org/gitroot/emf-parsley/org.eclipse.emf-parsley.git</tycho.scmUrl>

<!-- Sonar -->
<sonar.language>java</sonar.language>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.jacoco.reportPath>../../tests/org.eclipse.emf.parsley.tests.coverage/target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.junit.reportsPath>../${project.artifactId}.tests/target/surefire-reports/</sonar.junit.reportsPath>
<sonar.organization>eclipse-emf-parsley</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<sonar.coverage.jacoco.xmlReportPaths>
${jacoco-aggregate-report}
</sonar.coverage.jacoco.xmlReportPaths>

<!-- **/EmfParsleyViewFilesGenerator.java,**/EmfParsleyProjectFilesGenerator.java report massive code
duplication, but they're generated by Xtend and they are basically template generators;
runtime classes are currently not analyzed. -->
<sonar.exclusions>file:**/src-gen/**,file:**/runtime/**,file:**/test/**,file:**/tests/**,file:**/example/**,file:**/examples/**,**/*GuiceModule.java,**/*Dsl*Module.java,**/*ParsleyModule.java,**/*Activator.java,**/EmfParsleyViewFilesGenerator.java,**/EmfParsleyProjectFilesGenerator.java,**/EmfParsleyDslNewProjectFiles.java,**/*StandaloneSetup*.java,**/*ExtensionFactory*.java,**/*Nature*.java,file:**/web/**,file:**/swt/**,file:**/junit4/**</sonar.exclusions>
<sonar.exclusions>
**/src-gen/**,
**/runtime/**,
**/test/**,
**/tests/**,
**/example/**,
**/examples/**,
**/*GuiceModule.java,
**/*Dsl*Module.java,
**/*ParsleyModule.java,
**/*Activator.java,
**/EmfParsleyViewFilesGenerator.java,
**/EmfParsleyProjectFilesGenerator.java,
**/EmfParsleyDslNewProjectFiles.java,
**/*StandaloneSetup*.java,
**/*ExtensionFactory*.java,
**/*Nature*.java,
**/junit4/**
</sonar.exclusions>

<!-- Exclude Xtend generated files from code coverage:
we cover the original Xtend files, using xtendAsPrimaryDebugSource
inherited from the xtext-build-utils parent -->
<sonar.coverage.exclusions>
**/xtend-gen/**/*.java,
</sonar.coverage.exclusions>

<!-- To make SonarQube detect JUnit tests in generated Java code from Xtend -->
<sonar.scm.exclusions.disabled>true</sonar.scm.exclusions.disabled>

<!-- in the model inferrer we have a few lines of duplicated code that
makes it more readable -->
<sonar.cpd.exclusions>
**/xtend-gen/**/*JvmModelInferrer.java,
</sonar.cpd.exclusions>

<!-- see http://sonarqube.15.x6.nabble.com/sonar-issue-ignore-multicriteria-td5021722.html
and http://stackoverflow.com/questions/21825469/configure-sonar-sonar-issue-ignore-multicriteria-through-maven
Expand Down Expand Up @@ -853,12 +890,11 @@
</dependencies>
</plugin>

<!-- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=419172#c17 -->
<!-- <plugin>
<groupId>org.codehaus.mojo</groupId>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.4</version>
</plugin> -->
<version>3.9.1.2184</version>
</plugin>

<plugin>
<groupId>org.eclipse.tycho</groupId>
Expand Down

0 comments on commit ef525cc

Please sign in to comment.