Skip to content

Commit dfe6ea8

Browse files
committed
cpp client code format
1 parent 4e06946 commit dfe6ea8

41 files changed

Lines changed: 21183 additions & 20972 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
BasedOnStyle: LLVM
3+
IndentWidth: 2
4+
TabWidth: 2
5+
UseTab: Never
6+
ColumnLimit: 100
7+
BreakBeforeBraces: Attach
8+
AllowShortIfStatementsOnASingleLine: false
9+
AllowShortFunctionsOnASingleLine: Empty
10+
PointerAlignment: Left
11+
DerivePointerAlignment: false
12+
SortIncludes: false
13+
ReflowComments: false
14+
Standard: c++11
15+
...

.github/workflows/client-cpp-package.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ jobs:
8787
run: |
8888
set -euxo pipefail
8989
sudo apt-get update
90-
sudo apt-get install -y libboost-all-dev openssl libssl-dev
90+
sudo apt-get install -y libboost-all-dev openssl libssl-dev clang-format-17
91+
clang-format-17 --version
9192
- name: Cache Maven packages
9293
uses: actions/cache@v5
9394
with:
@@ -99,9 +100,7 @@ jobs:
99100
shell: bash
100101
run: |
101102
set -euxo pipefail
102-
./mvnw clean package -P with-cpp -pl iotdb-client/client-cpp -am \
103-
-DskipTests \
104-
-Dspotless.check.skip=true -Dspotless.apply.skip=true
103+
./mvnw clean package -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests
105104
- name: Upload zip artifact
106105
uses: actions/upload-artifact@v6
107106
with:
@@ -133,7 +132,9 @@ jobs:
133132
shell: bash
134133
run: |
135134
set -euxo pipefail
136-
brew install boost openssl
135+
brew install boost openssl llvm@17
136+
echo "$(brew --prefix llvm@17)/bin" >> "$GITHUB_PATH"
137+
clang-format --version
137138
- name: Cache Maven packages
138139
uses: actions/cache@v5
139140
with:
@@ -147,9 +148,7 @@ jobs:
147148
MACOSX_DEPLOYMENT_TARGET: "12.0"
148149
run: |
149150
set -euxo pipefail
150-
./mvnw clean package -P with-cpp -pl iotdb-client/client-cpp -am \
151-
-DskipTests \
152-
-Dspotless.check.skip=true -Dspotless.apply.skip=true
151+
./mvnw clean package -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests
153152
- name: Upload zip artifact
154153
uses: actions/upload-artifact@v6
155154
with:
@@ -194,6 +193,8 @@ jobs:
194193
$sslPath = (Get-ChildItem 'C:\Program Files\OpenSSL*' -Directory | Select-Object -First 1).FullName
195194
echo "$sslPath\bin" >> $env:GITHUB_PATH
196195
echo "OPENSSL_ROOT_DIR=$sslPath" >> $env:GITHUB_ENV
196+
choco install llvm --version=17.0.6 -y
197+
clang-format --version
197198
- name: Cache Maven packages
198199
uses: actions/cache@v5
199200
with:
@@ -208,9 +209,7 @@ jobs:
208209
IOTDB_TOOLS_THRIFT_VERSION: ${{ matrix.iotdb_tools_thrift_version }}
209210
run: |
210211
set -euxo pipefail
211-
MVN_ARGS=(./mvnw clean package -P with-cpp -pl iotdb-client/client-cpp -am \
212-
-DskipTests \
213-
-Dspotless.check.skip=true -Dspotless.apply.skip=true)
212+
MVN_ARGS=(./mvnw clean package -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests)
214213
if [ -n "${CMAKE_GENERATOR:-}" ]; then
215214
MVN_ARGS+=("-Dcmake.generator=${CMAKE_GENERATOR}")
216215
fi

.github/workflows/multi-language-client.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,18 @@ jobs:
5555
shell: bash
5656
run: |
5757
sudo apt-get update
58-
sudo apt-get install libboost-all-dev
59-
sudo apt-get install openssl libssl-dev
58+
sudo apt-get install -y libboost-all-dev
59+
sudo apt-get install -y openssl libssl-dev clang-format-17
60+
clang-format-17 --version
6061
- name: Install CPP Dependencies (Mac)
6162
# remove some xcode to release disk space
6263
if: runner.os == 'macOS'
6364
shell: bash
6465
run: |
6566
brew install boost
66-
brew install openssl
67+
brew install openssl llvm@17
68+
echo "$(brew --prefix llvm@17)/bin" >> "$GITHUB_PATH"
69+
clang-format --version
6770
sudo rm -rf /Applications/Xcode_14.3.1.app
6871
sudo rm -rf /Applications/Xcode_15.0.1.app
6972
sudo rm -rf /Applications/Xcode_15.1.app
@@ -72,21 +75,28 @@ jobs:
7275
- name: Install CPP Dependencies (Windows)
7376
if: runner.os == 'Windows'
7477
run: |
75-
choco install winflexbison3
76-
choco install boost-msvc-14.3
78+
choco install winflexbison3 -y
79+
choco install boost-msvc-14.3 -y
7780
$boost_path = (Get-ChildItem -Path 'C:\local\' -Filter 'boost_*').FullName
7881
echo $boost_path >> $env:GITHUB_PATH
7982
80-
choco install openssl
83+
choco install openssl -y
8184
$sslPath = (Get-ChildItem 'C:\Program Files\OpenSSL*' -Directory | Select-Object -First 1).FullName
8285
echo "$sslPath\bin" >> $env:GITHUB_PATH
8386
echo "OPENSSL_ROOT_DIR=$sslPath" >> $env:GITHUB_ENV
87+
choco install llvm --version=17.0.6 -y
88+
clang-format --version
8489
- name: Cache Maven packages
8590
uses: actions/cache@v5
8691
with:
8792
path: ~/.m2
8893
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
8994
restore-keys: ${{ runner.os }}-m2-
95+
- name: Check C++ format (Spotless)
96+
shell: bash
97+
run: |
98+
./mvnw -P with-cpp -pl iotdb-client/client-cpp spotless:check
99+
./mvnw -P with-cpp -pl example/client-cpp-example spotless:check
90100
- name: Build IoTDB server
91101
shell: bash
92102
run: ./mvnw clean install -pl distribution -am -DskipTests

CONTRIBUTING.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,31 @@ plugin](https://github.com/diffplug/spotless/tree/main/plugin-maven) together wi
107107
import static all other imports
108108
```
109109

110+
### C++ formatting
111+
112+
- Formatter: `clang-format` only
113+
- Version: `17.0.6` (must match CI)
114+
- Entrypoint: Maven Spotless
115+
116+
Check only:
117+
118+
`./mvnw -P with-cpp -pl iotdb-client/client-cpp spotless:check`
119+
120+
`./mvnw -P with-cpp -pl example/client-cpp-example spotless:check`
121+
122+
Auto-fix:
123+
124+
`./mvnw -P with-cpp -pl iotdb-client/client-cpp spotless:apply`
125+
126+
`./mvnw -P with-cpp -pl example/client-cpp-example spotless:apply`
127+
128+
On Windows PowerShell, a comma inside `-pl` can be parsed incorrectly; use the two commands above, or quote the full `-pl` value, for example `./mvnw -P with-cpp "-pl=iotdb-client/client-cpp,example/client-cpp-example" spotless:check`.
129+
130+
Temporarily skip Spotless (not recommended except emergency CI triage):
131+
132+
`-Dspotless.skip=true`
133+
134+
Risk: skipping formatting checks can introduce style drift between contributors and CI, and often causes follow-up format-only commits.
110135

111136
## Contributing code
112137

0 commit comments

Comments
 (0)