Repository navigation
159 lines (152 loc) · 6.02 KB
/
Copy pathsonar-codecov.yml
File metadata and controls
159 lines (152 loc) · 6.02 KB
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
158
159
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Sonar-Codecov
on:
push:
branches:
- master
- "rel/*"
- "rc/*"
paths-ignore:
- "docs/**"
- "site/**"
- "iotdb-client/client-cpp/**"
- ".github/workflows/client-cpp-package.yml"
- ".github/scripts/package-client-cpp-*.sh"
- ".github/workflows/multi-language-client.yml"
pull_request:
branches:
- master
- "rel/*"
- "new_*"
- "rc/*"
- "force_ci/**"
paths-ignore:
- "docs/**"
- "site/**"
- "iotdb-client/client-cpp/**"
- ".github/workflows/client-cpp-package.yml"
- ".github/scripts/package-client-cpp-*.sh"
- ".github/workflows/multi-language-client.yml"
# allow manually run the action:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
MAVEN_ARGS: --batch-mode --no-transfer-progress
PR_NUMBER: ${{ github.event.number }}
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
jobs:
codecov:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'apache/iotdb' || github.event_name == 'push'
steps:
- uses: actions/checkout@v5
- name: Cache Maven packages
uses: actions/cache@v5
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2-
- name: Test
run: |
mvn -B -P with-code-coverage clean package -pl distribution,iotdb-client/cli,iotdb-client/session,iotdb-client/jdbc -am -Dtest.port.closed=true -DforkCount=4
mvn -B -P with-code-coverage post-integration-test -pl code-coverage
- name: Upload JaCoCo report for SonarCloud
uses: actions/upload-artifact@v6
with:
name: jacoco-merged-report
path: code-coverage/target/jacoco-merged-reports/jacoco.xml
retention-days: 1
if-no-files-found: warn
- name: Upload coverage reports to codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./code-coverage/target/jacoco-merged-reports/jacoco.xml
sonar:
needs: [codecov]
runs-on: ubuntu-latest
if: ${{ !cancelled() && ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'apache/iotdb') || github.event_name == 'push') }}
env:
MAVEN_OPTS: -Xms2g -Xmx8g -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
- name: Check SonarCloud scan scope
id: sonar-scope
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
run: |
set -euo pipefail
if [ "${EVENT_NAME}" = "push" ]; then
echo "Push event on ${GITHUB_REF}: running full SonarCloud scan (excluding distribution)."
echo 'run_sonar=true' >> "${GITHUB_OUTPUT}"
exit 0
fi
if ! git rev-parse --verify --quiet "refs/remotes/origin/${BASE_REF}" >/dev/null; then
git fetch --no-tags origin "+refs/heads/${BASE_REF}:refs/remotes/origin/${BASE_REF}"
fi
python3 .github/scripts/check-sonar-pr-diff.py \
--base-ref "refs/remotes/origin/${BASE_REF}" \
--head-ref HEAD \
--github-output "${GITHUB_OUTPUT}"
- name: Download JaCoCo report from codecov job
if: steps.sonar-scope.outputs.run_sonar == 'true' && needs.codecov.result == 'success'
continue-on-error: true
uses: actions/download-artifact@v7
with:
name: jacoco-merged-report
path: ${{ runner.temp }}/sonar-coverage
- name: Set up JDK 21
if: steps.sonar-scope.outputs.run_sonar == 'true'
uses: actions/setup-java@v5
with:
distribution: corretto
java-version: 21
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Maven packages
if: steps.sonar-scope.outputs.run_sonar == 'true'
uses: actions/cache@v5
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2-
- name: Cache SonarCloud packages
if: steps.sonar-scope.outputs.run_sonar == 'true'
uses: actions/cache@v5
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: SonarCloud Report
if: steps.sonar-scope.outputs.run_sonar == 'true'
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
JACOCO_REPORT: ${{ runner.temp }}/sonar-coverage/jacoco.xml
run: |
set -euo pipefail
SONAR_ARGS=(
-Dsonar.organization=apache
-Dsonar.projectKey=apache_iotdb
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.token="${SONAR_TOKEN}"
)
if [ -f "${JACOCO_REPORT}" ]; then
echo "Using JaCoCo coverage report: ${JACOCO_REPORT}"
SONAR_ARGS+=("-Dsonar.coverage.jacoco.xmlReportPaths=${JACOCO_REPORT}")
else
echo "JaCoCo coverage report not found at ${JACOCO_REPORT}; running SonarCloud without coverage."
fi
mvn -B verify sonar:sonar \
"${SONAR_ARGS[@]}" \
-DskipTests -pl '!distribution' -am