From 4a7940e7aa6e5650a7c097aa99a15babfc598b38 Mon Sep 17 00:00:00 2001 From: Steven Lizano Date: Wed, 10 Apr 2024 09:58:59 -0600 Subject: [PATCH 1/3] [SNOW-921048]Add linter action - Add linter.yml workflow - Add .EditorConfig --- .EditorConfig | 61 ++++++++++++++++++++++++++++++++++++ .github/workflows/linter.yml | 43 +++++++++++++++++++++++++ .github/workflows/main.yml | 3 +- .gitignore | 3 ++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 .EditorConfig create mode 100644 .github/workflows/linter.yml diff --git a/.EditorConfig b/.EditorConfig new file mode 100644 index 000000000..61ab3ee2c --- /dev/null +++ b/.EditorConfig @@ -0,0 +1,61 @@ +root = true +# All files +[*.*] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 +max_line_length=150 + +# Interfaces should start with I and PascalCase +dotnet_naming_rule.interfaces_begin_with_I.severity = warning +dotnet_naming_rule.interfaces_begin_with_I.symbols = interfaces +dotnet_naming_rule.interfaces_begin_with_I.style = prefix_and_pascal_case +dotnet_naming_rule.interfaces_begin_with_I.required_prefix = I +dotnet_naming_symbols.interfaces.applicable_kinds = interface +dotnet_diagnostic.interfaces_begin_with_I.severity = warning +dotnet_diagnostic.interfaces_begin_with_I.enabled = true + +# Static fields should start with _s +dotnet_naming_rule.static_fields_begin_with_s.severity = warning +dotnet_naming_rule.static_fields_begin_with_s.symbols = static_fields +dotnet_naming_rule.static_fields_begin_with_s.style = custom +dotnet_naming_rule.static_fields_begin_with_s.custom_recommended_prefix = _r +dotnet_naming_rule.static_fields_begin_with_s.required_prefix = _r +dotnet_naming_rule.static_fields_begin_with_s.capitalization = camel_case +dotnet_naming_symbols.static_fields.applicable_kinds = field +dotnet_naming_symbols.static_fields.applicable_accessibilities = public, internal, private, protected, protected_internal +dotnet_naming_symbols.static_fields.required_modifiers = static +dotnet_diagnostic.static_fields_begin_with_s.severity = warning +dotnet_diagnostic.static_fields_begin_with_s.enabled = true + +# Enforce use of Pascal case in enums, classes, const and methods +dotnet_naming_rule.enforce_pascal_case.severity = suggestion +dotnet_naming_rule.enforce_pascal_case.symbols = methods, enums, consts, public_methods, public_classes +dotnet_naming_rule.enforce_pascal_case.style = pascal_case +dotnet_naming_symbols.methods.applicable_kinds = method +dotnet_naming_symbols.enums.applicable_kinds = enum +dotnet_naming_symbols.consts.applicable_kinds = field +dotnet_naming_symbols.consts.applicable_modifiers = const +dotnet_naming_symbols.public_methods.applicable_kinds = method +dotnet_naming_symbols.public_methods.applicable_accessibilities = public +dotnet_naming_symbols.public_classes.applicable_kinds = class +dotnet_naming_symbols.public_classes.applicable_accessibilities = public +dotnet_diagnostic.enforce_pascal_case.severity = suggestion +dotnet_diagnostic.enforce_pascal_case.enabled = true + +# private and internal members should start with underscore +dotnet_naming_rule.private_and_internal_members_start_with_underscore.severity = warning +dotnet_naming_rule.private_and_internal_members_start_with_underscore.symbols = private_fields, internal_fields, private_properties, internal_properties, private_methods, internal_methods +dotnet_naming_rule.private_and_internal_members_start_with_underscore.style = underscore_prefix +dotnet_naming_symbols.private_fields.applicable_kinds = field +dotnet_naming_symbols.internal_fields.applicable_kinds = field +dotnet_naming_symbols.private_properties.applicable_kinds = property +dotnet_naming_symbols.internal_properties.applicable_kinds = property +dotnet_naming_symbols.private_methods.applicable_kinds = method +dotnet_naming_symbols.internal_methods.applicable_kinds = method +dotnet_naming_symbols.private_methods.applicable_accessibilities = private +dotnet_naming_symbols.internal_methods.applicable_accessibilities = internal +dotnet_diagnostic.private_and_internal_members_start_with_underscore.severity = warning +dotnet_diagnostic.private_and_internal_members_start_with_underscore.enabled = true diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 000000000..ad64e1695 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,43 @@ +name: Code standards check + +# Triggers the workflow on pull request events but only for the master branch +on: + pull_request: + branches: [ master ] + workflow_dispatch: + inputs: + logLevel: + default: warning + description: "Log level" + required: true + tags: + description: "Linter" + required: false + +concurrency: + # older builds for the same pull request number or branch should be cancelled + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + DOTNET_VERSION: 6.0 + DOTNET_LEGACY_VERSION: 4.7.1 + +jobs: + run-linter: + name: Run linter + runs-on: windows-latest + steps: + - name: Check out Git repository + uses: actions/checkout@v3 + - name: Set up .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "6.0.x" + - name: Run linters + uses: wearerequired/lint-action@v2 + with: + dotnet_format: true + continue_on_error: true + github_token: ${{ secrets.GITHUB_TOKEN }} + check_name: ${linter} run \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 86da91f0e..d0bd7c6bd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,7 +37,8 @@ jobs: dotnet: ['net6.0', 'net472', 'net471'] cloud_env: ['AZURE', 'GCP', 'AWS'] steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - name: Setup Dotnet uses: actions/setup-dotnet@v3 with: diff --git a/.gitignore b/.gitignore index 325ad49d6..268c8f4dc 100644 --- a/.gitignore +++ b/.gitignore @@ -309,3 +309,6 @@ whitesource/ Snowflake.Data.Tests/macos_*_performance.csv Snowflake.Data.Tests/windows_*_performance.csv Snowflake.Data.Tests/unix_*_performance.csv + +# Ignore Mac files +**/.DS_Store \ No newline at end of file From 801b74ce7d698c69f8df71c8c27915e916533a06 Mon Sep 17 00:00:00 2001 From: Steven Lizano <130484280+sfc-gh-erojaslizano@users.noreply.github.com> Date: Thu, 11 Apr 2024 08:40:19 -0600 Subject: [PATCH 2/3] Update .github/workflows/linter.yml remove github token --- .github/workflows/linter.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index ad64e1695..0c723f321 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -39,5 +39,4 @@ jobs: with: dotnet_format: true continue_on_error: true - github_token: ${{ secrets.GITHUB_TOKEN }} check_name: ${linter} run \ No newline at end of file From e1050ac509b58ac95b573f3deb8fb62ff6e2b389 Mon Sep 17 00:00:00 2001 From: Steven Lizano Date: Tue, 16 Apr 2024 07:50:51 -0600 Subject: [PATCH 3/3] add dotnet-quality to linter.yml --- .github/workflows/linter.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 0c723f321..dc328598f 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -34,9 +34,10 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: "6.0.x" + dotnet-quality: 'ga' - name: Run linters uses: wearerequired/lint-action@v2 with: dotnet_format: true continue_on_error: true - check_name: ${linter} run \ No newline at end of file + check_name: ${linter} run