forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 2
158 lines (146 loc) · 5.97 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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
---
name: SonarClout Analysis
on: [push]
jobs:
sonar-cloud-java:
name: "SonarCloud on java"
runs-on: ubuntu-latest
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v3
with:
persist-credentials: false
submodules: recursive
- name: Paths Filter
uses: ./.github/actions/paths-filter
id: filter
with:
filters: |
fe_changes:
- 'fe/**'
- 'gensrc/proto/**'
- 'gensrc/thrift/**'
- name: Set up JDK 17
if: ${{ steps.filter.outputs.fe_changes == 'true' }}
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'adopt'
- name: Cache SonarCloud packages
if: ${{ steps.filter.outputs.fe_changes == 'true' }}
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
if: ${{ steps.filter.outputs.fe_changes == 'true' }}
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Setup thrift
if: ${{ steps.filter.outputs.fe_changes == 'true' }}
run: |
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y thrift-compiler=0.16.0-2
thrift --version
mkdir -p thirdparty/installed/bin/
cd thirdparty/installed/bin/ && ln -s /usr/bin/thrift thrift
- name: Install protoc
if: ${{ steps.filter.outputs.fe_changes == 'true' }}
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler libprotobuf-dev
cd thirdparty/installed/bin/ && ln -s /usr/bin/protoc protoc
- name: Set up environment
if: ${{ steps.filter.outputs.fe_changes == 'true' }}
run: |
# Install Bash if necessary
sudo apt-get update
sudo apt-get install -y bash
- name: Generated Source Code
if: ${{ steps.filter.outputs.fe_changes == 'true' }}
shell: bash
run: |
bash generated-source.sh
- name: Cache local Maven repository
if: ${{ steps.filter.outputs.fe_changes == 'true' }}
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Analyze FE
if: ${{ steps.filter.outputs.fe_changes == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
MAVEN_OPTS: -Xmx4g
run: |
cd fe
mvn --batch-mode verify sonar:sonar -DskipTests -Dsonar.organization=apache -Dsonar.projectKey=apache_incubator-doris -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
sonar-cloud-cpp:
name: "SonarCloud on cpp"
runs-on: ubuntu-22.04
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v3
with:
persist-credentials: false
submodules: recursive
- name: Paths Filter
uses: ./.github/actions/paths-filter
id: filter
with:
filters: |
be_changes:
- 'be/**'
- 'gensrc/proto/**'
- 'gensrc/thrift/**'
- name: Generate compile_commands.json
if: ${{ steps.filter.outputs.be_changes == 'true' }}
run: |
export DEFAULT_DIR='/opt/doris'
mkdir "${DEFAULT_DIR}"
wget https://github.com/amosbird/ldb_toolchain_gen/releases/download/v0.18/ldb_toolchain_gen.sh \
-q -O /tmp/ldb_toolchain_gen.sh
bash /tmp/ldb_toolchain_gen.sh "${DEFAULT_DIR}/ldb-toolchain"
sudo DEBIAN_FRONTEND=noninteractive apt install --yes tzdata byacc
pushd thirdparty
curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-linux-x86_64.tar.xz \
-o doris-thirdparty-prebuilt-linux-x86_64.tar.xz
tar -xvf doris-thirdparty-prebuilt-linux-x86_64.tar.xz
popd
export PATH="${DEFAULT_DIR}/ldb-toolchain/bin/:$(pwd)/thirdparty/installed/bin/:${PATH}"
DISABLE_BE_JAVA_EXTENSIONS=ON DO_NOT_CHECK_JAVA_ENV=ON ENABLE_PCH=OFF DORIS_TOOLCHAIN=clang OUTPUT_BE_BINARY=0 ./build.sh --be
- name: Install sonar-scanner and build-wrapper
if: ${{ steps.filter.outputs.be_changes == 'true' }}
uses: sonarsource/sonarcloud-github-c-cpp@v2
- name: Run sonar-scanner
if: ${{ steps.filter.outputs.be_changes == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: sonar-scanner -Dsonar.cfamily.compile-commands=be/build_Release/compile_commands.json -Dsonar.sources=be