forked from ihhub/fheroes2
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (64 loc) · 2.51 KB
/
sonarcloud.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
name: SonarCloud Analyzer
on:
workflow_call:
secrets:
SONAR_TOKEN:
required: true
jobs:
sonarcloud:
name: SonarCloud Analyzer
# This job should be run only for the original repo (either pushes or pull requests originating from the same repo), forks are not allowed.
# Workflows initiated by Dependabot do not have access to repo secrets, so this job should not be run in this case.
if: >-
${{
github.repository == 'ihhub/fheroes2'
&& ( github.event_name == 'push' || ( github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository ) )
&& github.actor != 'dependabot[bot]'
}}
runs-on: ubuntu-latest
timeout-minutes: 60
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Install dependencies
run: |
bash script/android/install_packages.sh
sudo apt-get -y update
sudo apt-get -y install libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev
- uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Prepare SonarCloud cfamily cache
uses: actions/cache@v3
with:
path: ~/.sonar-cfamily-cache
key: sonarcloud-cfamily-cache-${{ hashFiles( 'src/**/*.c', 'src/**/*.cpp', 'src/**/*.h' ) }}
restore-keys: |
sonarcloud-cfamily-cache-
- name: Generate version information
run: |
sed -i~ "s/%{version}/$(cat version.txt)/" sonar-project.properties
- name: Generate Java bytecode
run: |
cd android
./gradlew compileDebugJavaWithJavac
- name: Prepare compile_commands.json
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_STRICT_COMPILATION=ON -DENABLE_IMAGE=ON -DENABLE_TOOLS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Analyze
run: |
sonar-scanner -Dsonar.cfamily.compile-commands=build/compile_commands.json \
-Dsonar.cfamily.analysisCache.mode=fs \
-Dsonar.cfamily.analysisCache.path="$HOME"/.sonar-cfamily-cache \
-Dsonar.java.binaries="android/*/build/**/classes" \
-Dsonar.java.libraries="$ANDROID_HOME/**/*.jar,$HOME/.gradle/**/*.jar" \
-Dsonar.host.url=https://sonarcloud.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}