Skip to content

Commit

Permalink
added sonarcloud integration (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrimmingDev committed Feb 3, 2022
1 parent ca2534d commit 6de0d4f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
steps:
- name: Checkout twilio-java
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up Java
uses: actions/setup-java@v2
Expand All @@ -29,10 +31,24 @@ jobs:
java-version: ${{ matrix.java }}
cache: 'maven'

- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- run: mvn install -DskipTests=true -Dgpg.skip -Dmaven.javadoc.skip=true -B -V
- name: Run Unit Tests
run: mvn test -B

- name: SonarCloud Scan
if: ${{ (github.event_name == 'pull_request' || github.ref_type == 'branch') && matrix.java == 11 && !github.event.pull_request.head.repo.fork }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=twilio_twilio-java

deploy:
name: Deploy
if: success() && github.ref_type == 'tag'
Expand Down
57 changes: 56 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<timezone>-7</timezone>
</developer>
</developers>

<profiles>
<profile>
<id>gpg</id>
Expand Down Expand Up @@ -64,6 +65,37 @@
</plugins>
</build>
</profile>
<profile>
<id>coverage</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<activation>
Expand Down Expand Up @@ -136,13 +168,24 @@
</build>
</profile>
</profiles>

<properties>
<jackson.version>2.12.5</jackson.version>
<javadoc.plugin.version>3.3.1</javadoc.plugin.version>
<jjwt.version>0.11.2</jjwt.version>
<skip.tests>false</skip.tests>
<dependency.skip>false</dependency.skip>
<sonar.organization>twilio</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.projectName>twilio-java</sonar.projectName>
<sonar.coverage.exclusions>
**/test/**/*.*,**/rest/**/*.*
</sonar.coverage.exclusions>
<sonar.cpd.exclusions>
**/rest/**/*.*
</sonar.cpd.exclusions>
</properties>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down Expand Up @@ -286,6 +329,7 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -388,7 +432,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<argLine>-javaagent:${settings.localRepository}/org/jmockit/jmockit/1.24/jmockit-1.24.jar</argLine>
<argLine>@{argLine} -javaagent:${settings.localRepository}/org/jmockit/jmockit/1.24/jmockit-1.24.jar</argLine>
<forkCount>8</forkCount>
<reuseForks>true</reuseForks>
</configuration>
Expand Down Expand Up @@ -422,8 +466,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
</plugin>
</plugins>
</build>

<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
Expand Down

0 comments on commit 6de0d4f

Please sign in to comment.