Skip to content

Commit 4c12f52

Browse files
authored
style: add pre commit hook for style check and format (#29)
* fix: fetch data fail due to different endpoint in SessionDataSet; update Docker configuration and .NET version; enhance command-line options * fix typo * style: add pre commit hook for every pr or commit and format code style * add license check ignore for pre commit check * remove: delete obsolete iotdb symlink * fix: add TMPDIR for pre-commit to avoid resolve permission issue * fix: clean up dotnet temporary folder in pre-commit workflow
1 parent 63e8016 commit 4c12f52

Some content is hidden

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

49 files changed

+2190
-2098
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Formatting
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- '**'
8+
merge_group:
9+
branches: [ main ]
10+
schedule:
11+
- cron: "0 0 * * *"
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
formatting-checks:
19+
runs-on: ubuntu-20.04
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Setup dotnet
25+
uses: actions/setup-dotnet@v4
26+
with:
27+
dotnet-version: '9.0.x'
28+
29+
- name: Setup Python environment (for pre-commit)
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.10'
33+
34+
- name: Clean dotnet temporary folder
35+
run: |
36+
sudo rm -rf /tmp/.dotnet
37+
38+
- name: Install pre-commit and dependencies
39+
run: |
40+
pip install pre-commit
41+
pre-commit install-hooks
42+
43+
- name: Run pre-commit checks
44+
env:
45+
TMPDIR: ${{ runner.temp }}
46+
DOTNET_CLI_HOME: ${{ runner.temp }}
47+
run: |
48+
pre-commit run --all-files

.licenserc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ header:
3232
- 'Apache.IoTDB.sln'
3333
- '.gitignore'
3434
- '.dockerignore'
35+
- '.pre-commit-config.yaml'
3536

3637
comment: on-failure

.pre-commit-config.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
3+
repos:
4+
- repo: local
5+
hooks:
6+
- id: dotnet-format
7+
name: dotnet format
8+
entry: dotnet format --include
9+
language: system
10+
pass_filenames: true
11+
files: '\.(cs|vb|fs|sln|csproj|fsproj)$'
12+
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v4.6.0
15+
hooks:
16+
- id: trailing-whitespace
17+
- id: end-of-file-fixer
18+
- id: check-added-large-files
19+
- id: check-yaml
20+
- id: check-json
21+
- id: check-xml
22+
23+
- repo: https://github.com/codespell-project/codespell
24+
rev: v2.2.6
25+
hooks:
26+
- id: codespell
27+
args: ["--ignore-words-list=fo,teh,ba"]
28+
29+
exclude: |
30+
(?x)^(
31+
src/Apache\.IoTDB/Rpc/|
32+
.*\.md$
33+
)

Apache-IoTDB-Client-CSharp-UserCase/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,3 @@ static async Task Main(string[] args)
118118
}
119119

120120
}
121-

Apache.IoTDB.sln

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{DEAC57D3-4
2626
docs\time_profile_zh.pdf = docs\time_profile_zh.pdf
2727
EndProjectSection
2828
EndProject
29-
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{4D457769-80CB-401F-9155-C3125C04FACD}"
30-
EndProject
3129
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.IoTDB.Data", "src\Apache.IoTDB.Data\Apache.IoTDB.Data.csproj", "{4308656F-D174-49A6-ACE4-15894B017D55}"
3230
EndProject
3331
Global

docker-compose-2c2d.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ services:
130130
dockerfile: samples/Apache.IoTDB.Samples/Dockerfile
131131
command: ["--multi", "localhost:6667", "localhost:6668"]
132132
# command: ["sleep", "infinity"]
133-
network_mode: host
133+
network_mode: host

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
networks:
1616
iotdb-network:
1717
ipv4_address: 172.18.0.2
18-
18+
1919
iotdb:
2020
image: apache/iotdb:2.0.1-beta-datanode
2121
restart: always
@@ -38,7 +38,7 @@ services:
3838
- dn_rpc_address=iotdb
3939
- dn_internal_address=iotdb
4040
- dn_seed_config_node=iotdb-confignode-1:22277
41-
41+
4242
iotdb-confignode-1:
4343
image: apache/iotdb:2.0.1-beta-confignode
4444
restart: always
@@ -58,6 +58,6 @@ services:
5858
- cn_seed_config_node=iotdb-confignode-1:22277
5959

6060

61-
networks:
61+
networks:
6262
iotdb-network:
6363
external: true

launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
}
1212
}
1313
}
14-
}
14+
}

samples/Apache.IoTDB.Samples/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ RUN dotnet publish "Apache.IoTDB.Samples.csproj" -c Release -o /app/publish
3636
FROM base AS final
3737
WORKDIR /app
3838
COPY --from=publish /app/publish .
39-
ENTRYPOINT ["dotnet", "Apache.IoTDB.Samples.dll"]
39+
ENTRYPOINT ["dotnet", "Apache.IoTDB.Samples.dll"]

samples/Apache.IoTDB.Samples/Program.cs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,48 +35,48 @@ public static async Task Main(string[] args)
3535
() => "localhost",
3636
description: "Use single endpoint (e.g. --single localhost)");
3737

38-
var multiOption = new Option<List<string>>(
39-
"--multi",
40-
description: "Use multiple endpoints (e.g. --multi localhost:6667 localhost:6668)")
41-
{
42-
AllowMultipleArgumentsPerToken = true
43-
};
38+
var multiOption = new Option<List<string>>(
39+
"--multi",
40+
description: "Use multiple endpoints (e.g. --multi localhost:6667 localhost:6668)")
41+
{
42+
AllowMultipleArgumentsPerToken = true
43+
};
4444

45-
var rootCommand = new RootCommand
45+
var rootCommand = new RootCommand
4646
{
4747
singleOption,
4848
multiOption
4949
};
5050

51-
rootCommand.SetHandler(async (string single, List<string> multi) =>
52-
{
53-
var utilsTest = new UtilsTest();
54-
utilsTest.TestParseEndPoint();
51+
rootCommand.SetHandler(async (string single, List<string> multi) =>
52+
{
53+
var utilsTest = new UtilsTest();
54+
utilsTest.TestParseEndPoint();
5555

56-
SessionPoolTest sessionPoolTest;
56+
SessionPoolTest sessionPoolTest;
5757

58-
if (!string.IsNullOrEmpty(single) && (multi == null || multi.Count == 0))
59-
{
60-
sessionPoolTest = new SessionPoolTest(single);
61-
}
62-
else if (multi != null && multi.Count != 0)
63-
{
64-
sessionPoolTest = new SessionPoolTest(multi);
65-
}
66-
else
67-
{
68-
Console.WriteLine("Please specify either --single or --multi endpoints.");
69-
return;
70-
}
58+
if (!string.IsNullOrEmpty(single) && (multi == null || multi.Count == 0))
59+
{
60+
sessionPoolTest = new SessionPoolTest(single);
61+
}
62+
else if (multi != null && multi.Count != 0)
63+
{
64+
sessionPoolTest = new SessionPoolTest(multi);
65+
}
66+
else
67+
{
68+
Console.WriteLine("Please specify either --single or --multi endpoints.");
69+
return;
70+
}
7171

72-
await sessionPoolTest.Test();
72+
await sessionPoolTest.Test();
7373

74-
var tableSessionPoolTest = new TableSessionPoolTest(sessionPoolTest);
75-
await tableSessionPoolTest.Test();
74+
var tableSessionPoolTest = new TableSessionPoolTest(sessionPoolTest);
75+
await tableSessionPoolTest.Test();
7676

77-
}, singleOption, multiOption);
77+
}, singleOption, multiOption);
7878

79-
await rootCommand.InvokeAsync(args);
79+
await rootCommand.InvokeAsync(args);
8080
}
8181

8282
public static void OpenDebugMode(this SessionPool session)

samples/Apache.IoTDB.Samples/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
"commandName": "Docker"
88
}
99
}
10-
}
10+
}

samples/Apache.IoTDB.Samples/SessionPoolTest.AlignedRecord.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,4 @@ public async Task TestInsertAlignedStringRecordsOfOneDevice()
496496
Console.WriteLine("TestInsertAlignedStringRecordsOfOneDevice Passed!");
497497
}
498498
}
499-
}
499+
}

samples/Apache.IoTDB.Samples/SessionPoolTest.AlignedTablet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,4 @@ public async Task TestInsertAlignedTablets()
192192
Console.WriteLine("TestInsertAlignedTablets Passed!");
193193
}
194194
}
195-
}
195+
}

samples/Apache.IoTDB.Samples/SessionPoolTest.Record.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,12 @@ public async Task TestInsertRecords()
305305
row = res.Next();
306306
break;
307307
}
308-
308+
309309
Console.WriteLine($"{testDatabaseName}.{testDevice}.{row.Measurements[0]} {testMeasurements[3]}");
310310
System.Diagnostics.Debug.Assert($"{testDatabaseName}.{testDevice}.{testMeasurements[3]}" == row.Measurements[0]);
311311
System.Diagnostics.Debug.Assert($"{testDatabaseName}.{testDevice}.{testMeasurements[1]}" == row.Measurements[1]);
312312
System.Diagnostics.Debug.Assert($"{testDatabaseName}.{testDevice}.{testMeasurements[2]}" == row.Measurements[2]);
313-
313+
314314
status = await session_pool.DeleteDatabaseAsync(testDatabaseName);
315315
System.Diagnostics.Debug.Assert(status == 0);
316316
await session_pool.Close();
@@ -641,7 +641,7 @@ public async Task TestInsertRecordsWithAllType()
641641
var rowRecord2 = new RowRecord(2, values2, measurements, dataTypes);
642642
var rowRecord3 = new RowRecord(3, values3, measurements, dataTypes);
643643

644-
var device_id = new List<string> { string.Format("{0}.{1}", testDatabaseName, testDevice),string.Format("{0}.{1}", testDatabaseName, testDevice),string.Format("{0}.{1}", testDatabaseName, testDevice) };
644+
var device_id = new List<string> { string.Format("{0}.{1}", testDatabaseName, testDevice), string.Format("{0}.{1}", testDatabaseName, testDevice), string.Format("{0}.{1}", testDatabaseName, testDevice) };
645645
var rowRecords = new List<RowRecord> { rowRecord1, rowRecord2, rowRecord3 };
646646

647647
status = await session_pool.InsertRecordsAsync(device_id, rowRecords);
@@ -664,4 +664,4 @@ public async Task TestInsertRecordsWithAllType()
664664
Console.WriteLine("TestInsertRecordsWithAllType Passed!");
665665
}
666666
}
667-
}
667+
}

samples/Apache.IoTDB.Samples/SessionPoolTest.Tablet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public async Task TestInsertTabletWithAllType()
271271
TSDataType.BLOB,
272272
TSDataType.STRING
273273
};
274-
var timestamps = new List<long> {1, 2};
274+
var timestamps = new List<long> { 1, 2 };
275275
var tablet = new Tablet(device_id, measurements, datatypes, values, timestamps);
276276
status = await session_pool.InsertTabletAsync(tablet);
277277
System.Diagnostics.Debug.Assert(status == 0);

samples/Apache.IoTDB.Samples/SessionPoolTest.Template.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,4 @@ public async Task TestSetAndUnsetSchemaTemplate()
101101
}
102102
}
103103

104-
}
104+
}

samples/Apache.IoTDB.Samples/SessionPoolTest.TestNetwork.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,4 @@ public async Task TestTestInsertTablets()
351351
}
352352

353353
}
354-
}
354+
}

samples/Apache.IoTDB.Samples/SessionPoolTest.TimeSeries.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,4 @@ await session_pool.CreateTimeSeries(
194194
}
195195
}
196196

197-
}
197+
}

samples/Apache.IoTDB.Samples/SessionPoolTest.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public SessionPoolTest(List<string> _nodeUrls)
6464
}
6565
public async Task Test()
6666
{
67-
if(nodeUrls.Count == 1){
67+
if (nodeUrls.Count == 1)
68+
{
6869
await TestOpenWithNodeUrls();
6970

7071
await TestOpenWith2NodeUrls();
@@ -147,7 +148,8 @@ public async Task Test()
147148

148149
await TestNonSqlBy_ADO();
149150
}
150-
else {
151+
else
152+
{
151153
await TestMultiNodeDataFetch();
152154
}
153155
}
@@ -580,7 +582,8 @@ public async Task TestLastDataQuery()
580582
Console.WriteLine("LastDataQuery Passed");
581583
}
582584

583-
public async Task TestMultiNodeDataFetch(){
585+
public async Task TestMultiNodeDataFetch()
586+
{
584587
System.Diagnostics.Debug.Assert(nodeUrls.Count > 1, "nodeUrls.Count should be greater than 1 in MultiNode Test");
585588
var session_pool = new SessionPool.Builder()
586589
.SetUsername(username)
@@ -596,7 +599,7 @@ public async Task TestMultiNodeDataFetch(){
596599
var data_type_lst = new List<TSDataType> { TSDataType.BOOLEAN, TSDataType.FLOAT };
597600
var encoding_lst = new List<TSEncoding> { TSEncoding.PLAIN, TSEncoding.PLAIN };
598601
var compressor_lst = new List<Compressor> { Compressor.SNAPPY, Compressor.SNAPPY };
599-
var ts_path_lst = new List<string>() {
602+
var ts_path_lst = new List<string>() {
600603
string.Format("{0}.{1}.{2}", testDatabaseName, testDevice, testMeasurements[0]),
601604
string.Format("{0}.{1}.{2}", testDatabaseName, testDevice, testMeasurements[1])
602605
};
@@ -631,4 +634,4 @@ public async Task TestMultiNodeDataFetch(){
631634
Console.WriteLine("MultiNodeDataFetch Passed");
632635
}
633636
}
634-
}
637+
}

0 commit comments

Comments
 (0)