Repository navigation
132 lines (128 loc) · 4.76 KB
/
Copy pathanalysis.yml
File metadata and controls
132 lines (128 loc) · 4.76 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
name: Coverage
on:
push:
branches:
- main
paths-ignore:
- "**.md"
- "**/docs/**"
- "**/LICENSE"
- "**/NOTICE"
# Repo metadata that does not affect the build (CODEOWNERS, ai-gate.yml, templates, ...).
# `*` does not cross `/`, so .github/workflows/** changes still trigger this workflow.
- ".github/*"
- ".github/ISSUE_TEMPLATE/**"
- ".github/scripts/**"
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
paths-ignore:
- "**.md"
- "**/docs/**"
- "**/LICENSE"
- "**/NOTICE"
# Repo metadata that does not affect the build (CODEOWNERS, ai-gate.yml, templates, ...).
# `*` does not cross `/`, so .github/workflows/** changes still trigger this workflow.
- ".github/*"
- ".github/ISSUE_TEMPLATE/**"
- ".github/scripts/**"
workflow_dispatch:
inputs:
pr:
description: "Pull request#"
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.number || github.sha }}
cancel-in-progress: true
env:
PREFERRED_LTS_VERSION: "26.8"
PR_NUMBER: ${{ github.event.pull_request.number || '' }}
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
timeout-minutes: 30
env:
# PRs only need client-v2 and jdbc-v2 coverage. Pushes to main and manual runs analyse
# every module, so released V1 modules keep their SonarCloud (SAST) coverage.
COVERAGE_MODULES: ${{ github.event_name == 'pull_request' && '--also-make --projects client-v2,jdbc-v2' || '' }}
SONAR_MODULES: ${{ github.event_name == 'pull_request' && '--projects client-v2,jdbc-v2' || '' }}
steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check out head
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
if: github.event_name == 'pull_request'
- name: Check out PR
run: |
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 \
origin pull/${{ github.event.inputs.pr }}/head:the-pr && git checkout the-pr
if: github.event.inputs.pr != ''
- name: Install JDK and Maven
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17
cache: "maven"
- name: Setup Toolchain
shell: bash
run: |
mkdir -p $HOME/.m2 \
&& cat << EOF > $HOME/.m2/toolchains.xml
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>17</version>
</provides>
<configuration>
<jdkHome>${{ env.JAVA_HOME }}</jdkHome>
</configuration>
</toolchain>
</toolchains>
EOF
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Update sonar config
run: |
sed -i -e 's|^\(.*<sonar.projectKey>\).*\(</sonar.projectKey>\)$|\1ClickHouse_clickhouse-java\2|' \
-e 's|^\(.*<sonar.organization>\).*\(</sonar.organization>\)$|\1clickhouse-java\2|' pom.xml
if: github.repository_owner == 'ClickHouse'
- name: Build and install
run: |
find . -type f -name "simplelogger.*" -exec rm -fv '{}' \;
mvn -q --no-transfer-progress --batch-mode $COVERAGE_MODULES -DskipTests install
- name: Generate coverage report
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
TEST_CLICKHOUSE_IMAGE_VERSION: ${{ env.PREFERRED_LTS_VERSION }}
run: |
mvn -fn --no-transfer-progress --batch-mode \
$SONAR_MODULES -Pcoverage verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ClickHouse_clickhouse-java
continue-on-error: true
- name: Generate and post coverage report
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_ARG=''
if [ ! -z $PR_NUMBER ]; then PR_ARG="--pr $PR_NUMBER"; fi;
node jacoco-report-generator.mjs ./client-v2/target/site/jacoco-aggregate/jacoco.csv client-v2-cov.md --title "Client V2 Coverage" ${PR_ARG}
node jacoco-report-generator.mjs ./jdbc-v2/target/site/jacoco-aggregate/jacoco.csv jdbc-v2-cov.md --title "JDBC V2 Coverage" ${PR_ARG}
cat *-cov.md