Skip to content

Commit

Permalink
Separate sonar scan as new workflow
Browse files Browse the repository at this point in the history
This change is necessary in order to have at least green build job when PR is opened through fork repo.
The project is still using java 11 but sonarcloud.io requires scans using minimum java 17, so sonar scans will be executed using java 17 instead 11
  • Loading branch information
theghost5800 committed Nov 14, 2023
1 parent 331bc86 commit 07fee46
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,5 @@ jobs:
java-version: '11'
distribution: 'zulu'

- name: Build and Analyze Code Coverage
run: mvn clean install -Pcoverage

- name: Sonar Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn sonar:sonar -Dsonar.projectKey=cloudfoundry_multiapps
- name: Build and Run Unit Tests
run: mvn clean install
20 changes: 3 additions & 17 deletions .github/workflows/pull-request-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'zulu'

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


- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build and Analyze Code Coverage
run: mvn clean install -Pcoverage

- name: Sonar Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn sonar:sonar -Dsonar.projectKey=cloudfoundry_multiapps
- name: Build and Run Unit Tests
run: mvn clean install
28 changes: 28 additions & 0 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Multiapps Sonar Scan

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'

- name: Build and Analyze Code Coverage
run: mvn clean install -Pcoverage

- name: Sonar Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn sonar:sonar -Dsonar.projectKey=cloudfoundry_multiapps

0 comments on commit 07fee46

Please sign in to comment.