-
Notifications
You must be signed in to change notification settings - Fork 314
123 lines (110 loc) · 4.58 KB
/
sonar.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Sonar
on:
workflow_run:
workflows: [Build]
types: [completed]
env:
BUILD_TYPE: RelWithDebInfo
jobs:
sonarscanner:
runs-on: ubuntu-22.04
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: 'Install dependencies'
run: |
sudo apt-get update
sudo apt-get install -y libboost-dev \
libeigen3-dev \
libepoxy-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libjpeg-dev \
libpng-dev \
libglu1-mesa-dev \
qtbase5-dev \
qtbase5-dev-tools \
libqt5opengl5-dev \
libfreetype6-dev \
libsdl2-dev \
libluajit-5.1-dev \
libicu-dev \
ninja-build \
gperf \
cmake
- name: 'Checkout source code'
uses: actions/checkout@v4
with:
submodules: true
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_branch }}
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: 'Download PR details'
if: github.event.workflow_run.event == 'pull_request'
uses: actions/download-artifact@v4
with:
name: pr-details
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: 'Extract PR details'
id: pr_details
if: github.event.workflow_run.event == 'pull_request'
run: |
cat pr-details.txt >> "$GITHUB_OUTPUT"
- name: 'Checkout base branch'
if: github.event.workflow_run.event == 'pull_request'
run: |
git remote add upstream ${{ github.event.repository.clone_url }}
git fetch upstream ${{ steps.pr_details.outputs.PR_BASE }}
git checkout -B ${{ steps.pr_details.outputs.PR_BASE }} upstream/${{ steps.pr_details.outputs.PR_BASE }}
git checkout ${{ github.event.workflow_run.head_branch }}
yes no | git clean -fxd
git reset --hard HEAD
- name: 'Download autogenerated headers'
uses: actions/download-artifact@v4
with:
name: celestia-autogenerated-headers
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: 'Unzip autogenerated headers'
run: |
unzip -n celestia-autogenerated-headers.zip && rm celestia-autogenerated-headers.zip
- name: 'Install sonar'
uses: SonarSource/sonarcloud-github-c-cpp@v3
- name: 'Configure CMake'
run: |
cmake -B ${{github.workspace}}/build \
-G Ninja \
-DENABLE_GLES=ON \
-DENABLE_SPICE=OFF \
-DENABLE_TOOLS=OFF \
-DENABLE_TESTS=OFF \
-DENABLE_SDL=ON \
-DENABLE_GTK=OFF \
-DENABLE_QT5=ON \
-DENABLE_FFMPEG=ON \
-DENABLE_MINIAUDIO=ON \
-DUSE_ICU=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Analyze push
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.head_repository.full_name == github.event.repository.full_name
run: |
sonar-scanner \
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} \
-Dsonar.branch.name=${{ github.event.workflow_run.head_branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Analyze pull request
if: github.event.workflow_run.event == 'pull_request'
run: |
sonar-scanner \
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} \
-Dsonar.pullrequest.key=${{ steps.pr_details.outputs.PR_KEY }} \
-Dsonar.pullrequest.branch=${{ steps.pr_details.outputs.PR_BRANCH }} \
-Dsonar.pullrequest.base=${{ steps.pr_details.outputs.PR_BASE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}