Skip to content

Commit ce2d467

Browse files
committed
⚗️ Add Source Only Workflow
Emulate an edge case where Sonar Scanner is used only on source code, despite Sonar being designed to operate on Java bytecode.
1 parent 4de16d7 commit ce2d467

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Sonar Scanner for Maven requires that the project is built before the analysis.
2+
# Yet, running the Sonar Scanner action without building the project yields some results.
3+
# This action uses this edge-case set-up, to help us understand what results we can expect when using Sonar Scanner action to analyze Java source files.
4+
name: SonarCloud (Source Only)
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
types: [ opened, synchronize, reopened ]
11+
workflow_dispatch:
12+
13+
jobs:
14+
build:
15+
name: Build and Analyze (Source Only)
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
21+
22+
- name: Analyze Source Only
23+
uses: sonarsource/sonarqube-scan-action@v2
24+
with:
25+
args: >
26+
-Dsonar.host.url=https://sonarcloud.io
27+
-Dsonar.organization=pixee
28+
-Dsonar.projectKey=pixee_bad-java-code
29+
-Dsonar.sources=src/main/java
30+
-Dsonar.java.binaries=.
31+
-Dsonar.sourceEncoding=UTF-8
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
34+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)