Skip to content

Commit cf8d096

Browse files
[SNOW-921048] Add linter to fail pipeline
1 parent bc329ab commit cf8d096

File tree

5 files changed

+102
-71
lines changed

5 files changed

+102
-71
lines changed

.EditorConfig

Lines changed: 0 additions & 61 deletions
This file was deleted.

.editorconfig

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
root = true
2+
# yml files
3+
[*.yml]
4+
indent_style = space
5+
indent_size = 2
6+
7+
# All files
8+
[*.*]
9+
indent_style = space
10+
indent_size = 4
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
charset = utf-8
14+
max_line_length = 150
15+
16+
## Interfaces should start with I and PascalCase
17+
dotnet_naming_style.prefix_and_pascal_case.required_prefix = I
18+
dotnet_naming_style.prefix_and_pascal_case.capitalization = pascal_case
19+
dotnet_naming_symbols.interfaces.applicable_kinds = interface
20+
dotnet_naming_rule.interfaces_begin_with_I.severity = error
21+
dotnet_naming_rule.interfaces_begin_with_I.symbols = interfaces
22+
dotnet_naming_rule.interfaces_begin_with_I.style = prefix_and_pascal_case
23+
dotnet_diagnostic.interfaces_begin_with_I.enabled = true
24+
25+
## Static fields should start with _s
26+
dotnet_naming_style.prefix_s.required_prefix = _s
27+
dotnet_naming_style.prefix_s.capitalization = camel_case
28+
dotnet_naming_rule.static_fields_begin_with_s.style = prefix_s
29+
dotnet_naming_symbols.static_fields.applicable_kinds = field
30+
dotnet_naming_symbols.static_fields.applicable_accessibilities = public, internal, private, protected, protected_internal
31+
dotnet_naming_symbols.static_fields.required_modifiers = static
32+
dotnet_naming_rule.static_fields_begin_with_s.severity = error
33+
dotnet_naming_rule.static_fields_begin_with_s.symbols = static_fields
34+
dotnet_diagnostic.static_fields_begin_with_s.enabled = true
35+
36+
## Internal or private member should prefixed with _
37+
dotnet_naming_style.internal_prefix_.required_prefix = _
38+
dotnet_naming_style.internal_prefix_.capitalization = camel_case
39+
dotnet_naming_rule.private_internal_prefix_.style = internal_prefix_
40+
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
41+
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = internal, private, protected_internal
42+
dotnet_naming_rule.private_internal_prefix_.severity = error
43+
dotnet_naming_rule.private_internal_prefix_.symbols = private_internal_fields
44+
dotnet_diagnostic.private_internal_prefix_.enabled = true
45+
46+
# Enforce use of Pascal case in enums, classes, const and methods
47+
dotnet_naming_style.pascal_case_cap.capitalization = pascal_case
48+
dotnet_naming_rule.enforce_pascal_case.style = pascal_case_cap
49+
dotnet_naming_symbols.methods.applicable_kinds = method
50+
dotnet_naming_symbols.enums.applicable_kinds = enum
51+
dotnet_naming_symbols.consts.applicable_kinds = field
52+
dotnet_naming_symbols.consts.applicable_modifiers = const
53+
dotnet_naming_symbols.public_methods.applicable_kinds = method
54+
dotnet_naming_symbols.public_methods.applicable_accessibilities = public
55+
dotnet_naming_symbols.public_classes.applicable_kinds = class
56+
dotnet_naming_symbols.public_classes.applicable_accessibilities = public
57+
dotnet_naming_symbols.enum_members.applicable_kinds = enum_member
58+
dotnet_naming_symbols.enum_members.applicable_accessibilities = *
59+
dotnet_naming_rule.enforce_pascal_case.severity = error
60+
dotnet_naming_rule.enforce_pascal_case.symbols = methods, enums, consts, public_methods, public_classes, enum_members
61+
dotnet_diagnostic.enforce_pascal_case.enabled = true

.github/workflows/linter.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
tags:
1414
description: "Linter"
1515
required: false
16+
permissions: { }
1617

1718
concurrency:
1819
# older builds for the same pull request number or branch should be cancelled
@@ -26,14 +27,20 @@ jobs:
2627
steps:
2728
- name: Check out Git repository
2829
uses: actions/checkout@v3
29-
- name: Set up .NET
30-
uses: actions/setup-dotnet@v1
3130
with:
32-
dotnet-version: '8.0.x'
33-
dotnet-quality: 'ga'
34-
- name: Run linters
35-
uses: wearerequired/lint-action@v2
31+
depth: 0
32+
33+
- name: Set up .NET
34+
uses: actions/setup-dotnet@v4
3635
with:
37-
dotnet_format: true
38-
continue_on_error: true
39-
check_name: ${linter} run
36+
dotnet-version: '6.0.103'
37+
38+
- name: Install dotnet format
39+
run: dotnet tool install -g dotnet-format
40+
41+
- name: Add dotnet tools to PATH
42+
run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
43+
44+
- name: Run Linter Bash Script
45+
run: |
46+
bash ci/scripts/linter.sh

Snowflake.Data/Core/Session/ISessionPoolEventHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ internal interface ISessionPoolEventHandler
55
void OnNewSessionCreated(SessionPool sessionPool);
66

77
void OnWaitingForSessionStarted(SessionPool sessionPool);
8-
8+
99
void OnWaitingForSessionStarted(SessionPool sessionPool, long millisLeft);
1010

1111
void OnWaitingForSessionSuccessful(SessionPool sessionPool);

ci/scripts/linter.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash -e
2+
#
3+
# Apply Linter to changed files in PR
4+
set -e
5+
set -o pipefail
6+
7+
current_branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
8+
git fetch --no-tags origin master:master
9+
git fetch --no-tags origin $current_branch:$current_branch
10+
11+
BASE_SHA=$(git merge-base $GITHUB_BASE_REF $current_branch)
12+
13+
changed_files=$(git diff --name-only $BASE_SHA HEAD)
14+
15+
echo "All files changed:"
16+
for file in $changed_files; do
17+
echo "$file"
18+
done
19+
20+
echo "Run dotnet restore"
21+
dotnet restore
22+
23+
echo "Running Dotnet format to changed files"
24+
dotnet format --include $changed_files --verify-no-changes --no-restore

0 commit comments

Comments
 (0)