-
Notifications
You must be signed in to change notification settings - Fork 138
78 lines (76 loc) · 2.57 KB
/
sonarqube.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
70
71
72
73
74
75
76
77
78
on:
push:
branches:
- master
- sq-10
paths-ignore:
- '.github/actions/**'
pull_request_target:
branches:
- master
paths-ignore:
- '.github/actions/**'
release:
types:
- created
# set necessary permissions for SQ's GitHub integration
# https://docs.sonarqube.org/latest/analysis/github-integration/#header-2
permissions:
checks: write
contents: read
pull-requests: write
statuses: read
jobs:
build:
# Forked repos do not have access to the Sonar account
if: github.repository == 'spotbugs/sonar-findbugs'
runs-on: ubuntu-20.04
env:
# previous LTS version
SONAR_SERVER_VERSION: 8.9.9.56886
SONAR_PLUGIN_API_VERSION: 8.9.9.56886
SONAR_PLUGIN_API_GROUPID: org.sonarsource.sonarqube
SONAR_JAVA_VERSION: 6.15.1.26025
steps:
- name: Decide the ref to check out
uses: haya14busa/action-cond@v1
id: condval
with:
cond: ${{ github.event_name == 'pull_request_target' }}
if_true: refs/pull/${{ github.event.pull_request.number }}/merge
if_false: ${{ github.ref }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ steps.condval.outputs.value }}
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: |
~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build
run: |
mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar -B -e -V -DskipITs \
-Dsonar.server.version=${{ env.SONAR_SERVER_VERSION }} \
-Dsonar-plugin-api.version=${{ env.SONAR_PLUGIN_API_VERSION }} \
-Dsonar-plugin-api.groupId=${{ env.SONAR_PLUGIN_API_GROUPID }} \
-Dsonar-java.version=${{ env.SONAR_JAVA_VERSION }} \
-Dsonar.projectKey=com.github.spotbugs:sonar-findbugs-plugin \
-Dsonar.organization=spotbugs \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=$SONAR_LOGIN \
${PR_NUMBER:+ -Dsonar.pullrequest.key=$PR_NUMBER -Dsonar.pullrequest.branch=$PR_BRANCH }
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_LOGIN: ${{ secrets.SONAR_LOGIN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
CI: true