-
Notifications
You must be signed in to change notification settings - Fork 70
91 lines (73 loc) · 2.18 KB
/
sonarqube-workflows.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
79
80
81
82
83
84
85
86
87
88
89
90
91
name: sonarqube-workflows
on:
push:
branches:
- master
pull_request:
jobs:
build-jar:
name: Build Jar File
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Maven
run: mvn -e --no-transfer-progress package -Pno-validations
- name: Upload Jar File
uses: actions/upload-artifact@v4
with:
name: jar-file
path: target/checkstyle-sonar-plugin*.jar
retention-days: 1
execute-sonar:
name: Test SonarQube Plugin
runs-on: ubuntu-latest
needs: build-jar
steps:
- uses: actions/checkout@v4
- name: Download workspace
uses: actions/download-artifact@v4
with:
name: jar-file
path: target
- name: Run SonarQube
uses: addnab/docker-run-action@v3
with:
image: sonarqube:9.9-community
options: -d -p 9000:9000 -p 9092:9092 -v ${{ github.workspace }}/target/:/opt/sonarqube/extensions/plugins/
- name: Run SonarQube Analysis
run: |
mvn -e --no-transfer-progress sonar:sonar -Dsonar.login=admin -Dsonar.password=admin
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: sonar-results
path: target/sonar/checkstyle-result.xml
- name: Collect logs
uses: jwalton/gh-docker-logs@v2
with:
dest: logs
- name: Check logs for error
run: grep "ERROR" ./logs/* || test $? = 1
sonarqube-analysis:
name: Analyse with SonarQube
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
- name: Install jq
run: sudo apt-get install -y jq
- name: Run sonarqube
run: ./.ci/sonarqube.sh
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BRANCH_NAME: ${{ github.head_ref }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}