Skip to content

Commit

Permalink
Merge pull request #509 from jamesmudd/sonar-java-17
Browse files Browse the repository at this point in the history
SonarQube GHA
  • Loading branch information
jamesmudd authored Nov 17, 2023
2 parents 2bed0e7 + 7656941 commit 06b3db1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 37 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: SonarQube
on:
# Trigger analysis when pushing to your main branches, and when creating a pull request.
push:
branches:
- main
- master
- develop
- 'releases/**'
pull_request:
types: [opened, synchronize, reopened]

jobs:
sonarqube:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'

- name: Set up JDK (x64)
uses: actions/setup-java@v3
with:
java-version: '17'
architecture: 'x64'
distribution: 'temurin'
cache: 'gradle'

- name: Build
working-directory: jhdf
run: ./gradlew build

- name: Checkstyle
working-directory: jhdf
run: ./gradlew checkstyleMain checkstyleTest

- name: SpotBugs
working-directory: jhdf
run: ./gradlew spotbugsMain spotbugsTest

- name: Jacoco Coverage Report
working-directory: jhdf
run: ./gradlew jacocoTestReport

- name: Sonar
working-directory: jhdf
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew sonar --info
44 changes: 7 additions & 37 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ trigger:
- master
pr:
- master

jobs:
- job: Linux
pool:
Expand All @@ -17,14 +17,14 @@ jobs:
Java 11:
java.version: '1.11'
steps:

# Build using a Gradle wrapper script
- task: Gradle@2
displayName: Build + Test
inputs:
gradleWrapperFile: 'jhdf/gradlew'
workingDirectory: jhdf
tasks: 'clean build jacocoTestReport'
tasks: 'clean build jacocoTestReport'
publishJUnitResults: true
testResultsFiles: 'jhdf/build/test-results/test/TEST-*.xml'
testRunTitle: $(osName) $(Agent.JobName)
Expand All @@ -47,36 +47,6 @@ jobs:
tasks: 'sourcesJar javadocJar'
jdkVersionOption: $(java.version)
publishJUnitResults: false

# SonarQube
- task: Gradle@2
# Only run for Java 1.8 and not for PR
condition: and(eq(variables['java.version'], '1.11'), ne(variables['Build.Reason'], 'PullRequest'))
displayName: SonarQube
inputs:
gradleWrapperFile: 'jhdf/gradlew'
workingDirectory: jhdf
tasks: 'sonarqube'
jdkVersionOption: $(java.version)
publishJUnitResults: false
gradleOptions: '-Dsonar.login=$(sonar.login)'

# SonarQube for Pull requests
- task: Gradle@2
# Only run for Java 1.8 and PR
condition: and(eq(variables['java.version'], '1.11'), eq(variables['Build.Reason'], 'PullRequest'))
displayName: SonarQube PR
inputs:
gradleWrapperFile: 'jhdf/gradlew'
workingDirectory: jhdf
tasks: 'sonarqube'
jdkVersionOption: $(java.version)
publishJUnitResults: false
gradleOptions: '-Dsonar.login=$(sonar.login)
-Dsonar.pullrequest.branch=$(Build.SourceBranch)
-Dsonar.pullrequest.key=$(System.PullRequest.PullRequestNumber)
-Dsonar.pullrequest.base=$(System.PullRequest.TargetBranch)
-Dsonar.pullrequest.github.repository=$(Build.Repository.Uri)'

- job: Windows
pool:
Expand All @@ -90,14 +60,14 @@ jobs:
Java 11:
java.version: '1.11'
steps:

# Build using a Gradle wrapper script
- task: Gradle@2
displayName: Build/Test
inputs:
gradleWrapperFile: 'jhdf/gradlew'
workingDirectory: jhdf
tasks: 'build'
tasks: 'build'
publishJUnitResults: true
testResultsFiles: 'jhdf/build/test-results/test/TEST-*.xml'
testRunTitle: $(osName) $(Agent.JobName)
Expand Down Expand Up @@ -125,14 +95,14 @@ jobs:
Java 11:
java.version: '1.11'
steps:

# Build using a Gradle wrapper script
- task: Gradle@2
displayName: Build/Test
inputs:
gradleWrapperFile: 'jhdf/gradlew'
workingDirectory: jhdf
tasks: 'build'
tasks: 'build'
publishJUnitResults: true
testResultsFiles: 'jhdf/build/test-results/test/TEST-*.xml'
testRunTitle: $(osName) $(Agent.JobName)
Expand Down

0 comments on commit 06b3db1

Please sign in to comment.