-
Notifications
You must be signed in to change notification settings - Fork 83
69 lines (60 loc) · 1.92 KB
/
sonar-analysis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Sonar
on:
push:
paths-ignore:
- publiccode.yml
branches:
- master
- develop
pull_request:
types:
- opened
- reopened
- synchronize
# The branches below must be a subset of the branches above
branches:
- master
- develop
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: Install ffmpeg on Ubuntu
run: sudo apt-get update && sudo apt-get install -y ffmpeg && ffmpeg -version
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- uses: actions/cache@v4
with:
# be careful not to include ~/.m2/settings.xml which contains credentials
path: |
~/.m2/repository
~/.m2/wrapper
key: release-m2-${{ hashFiles('**/pom.xml', '.mvn/*.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
if [ -n "$SONAR_TOKEN" ]
then
bash mvnw -B jacoco:prepare-agent verify jacoco:report sonar:sonar
else
echo "Skipping sonar if a PR is created from a fork"
echo "Secrets are not available in such PRs for security reason"
fi