Skip to content

Commit

Permalink
Merge pull request #20 from SiliconLabs/add-coding-convention-check-w…
Browse files Browse the repository at this point in the history
…orkflow

Add coding convention check workflow
  • Loading branch information
silabs-bingocth authored Oct 9, 2024
2 parents 0bc4033 + e5a170d commit eeacedd
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 141 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/coding_convention.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

name: Coding Convention
on:
push:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
REPO_LINK: https://github.com/${{ github.repository }}.git
jobs:
job1:
name: Check coding convention
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/[email protected]
with:
ref: update-source-code-lib-iec60730
- name: Install python3.11
if: always()
run: |
sudo apt update
sudo apt upgrade
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update
sudo apt install python3.11
python3.11 --version
which python3.11
sudo apt install python3.11-full
curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3.11
- name: Install Pre-commmit
run: |
python3.11 -m pip install pre-commit
sudo apt install uncrustify clang-tidy cppcheck
- name: Run test
run: |
pre-commit install
pre-commit run --all-files > CodingConventionTool.txt
- name: Upload Result
if: always()
uses: actions/[email protected]
with:
name: CodingConventionResult
path: CodingConventionTool.txt
warn: Output a warning but do not fail the action
retention-days: 90
152 changes: 76 additions & 76 deletions tools/.clang-format
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
---
BasedOnStyle: LLVM
IndentWidth: 2
TabWidth: 2
UseTab: Never


# General formatting
AccessModifierOffset: -2
MaxEmptyLinesToKeep: 1
# BreakBeforeBraces: Allman

# Line length
ColumnLimit: 80

# Bracing style
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterControlStatement: Never
AfterFunction: true
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false

# Use of spaces
SpacesBeforeTrailingComments: 1
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false

# Use of comments
CommentPragmas: "^ IWYU pragma:"

AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveMacros: true
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: No
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
Cpp11BracedListStyle: true
IncludeBlocks: Regroup
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: None
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Right
ReflowComments: false
SortIncludes: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
---
BasedOnStyle: LLVM
IndentWidth: 2
TabWidth: 2
UseTab: Never


# General formatting
AccessModifierOffset: -2
MaxEmptyLinesToKeep: 1
# BreakBeforeBraces: Allman

# Line length
ColumnLimit: 80

# Bracing style
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterControlStatement: Never
AfterFunction: true
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false

# Use of spaces
SpacesBeforeTrailingComments: 1
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false

# Use of comments
CommentPragmas: "^ IWYU pragma:"

AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveMacros: true
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: No
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
Cpp11BracedListStyle: true
IncludeBlocks: Regroup
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: None
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Right
ReflowComments: false
SortIncludes: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
100 changes: 50 additions & 50 deletions tools/.clang-tidy
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
Checks: >
-*,
readability-identifier-naming,
readability-magic-numbers,
readability-braces-around-statements
WarningsAsErrors: >
readability-identifier-naming,
readability-magic-numbers,
readability-braces-around-statements
HeaderFilterRegex: ''
FormatStyle: none
InheritParentConfig: true
User: user
CheckOptions:
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.GlobalConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.GlobalConstantPrefix
value: SL_
- key: readability-identifier-naming.ConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.ConstantPrefix
value: SL_
- key: readability-identifier-naming.EnumConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.EnumConstantPrefix
value: SL_
- key: readability-identifier-naming.EnumCase
value: lower_case
- key: readability-identifier-naming.EnumPrefix
value: sl_
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: 'sli_.*'
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.FunctionPrefix
value: 'sl_'
- key: readability-identifier-naming.StructCase
value: lower_case
- key: readability-identifier-naming.StructPrefix
value: 'sl_'
- key: readability-identifier-naming.StructMemberCase
value: lower_case
- key: readability-identifier-naming.TypedefCase
value: lower_case
- key: readability-identifier-naming.TypedefPrefix
value: 'sl_'
Checks: >
-*,
readability-identifier-naming,
readability-magic-numbers,
readability-braces-around-statements
WarningsAsErrors: >
readability-identifier-naming,
readability-magic-numbers,
readability-braces-around-statements
HeaderFilterRegex: ''
FormatStyle: none
InheritParentConfig: true
User: user
CheckOptions:
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.GlobalConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.GlobalConstantPrefix
value: SL_
- key: readability-identifier-naming.ConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.ConstantPrefix
value: SL_
- key: readability-identifier-naming.EnumConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.EnumConstantPrefix
value: SL_
- key: readability-identifier-naming.EnumCase
value: lower_case
- key: readability-identifier-naming.EnumPrefix
value: sl_
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: 'sli_.*'
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.FunctionPrefix
value: 'sl_'
- key: readability-identifier-naming.StructCase
value: lower_case
- key: readability-identifier-naming.StructPrefix
value: 'sl_'
- key: readability-identifier-naming.StructMemberCase
value: lower_case
- key: readability-identifier-naming.TypedefCase
value: lower_case
- key: readability-identifier-naming.TypedefPrefix
value: 'sl_'
20 changes: 10 additions & 10 deletions tools/.codespell/.codespellrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# See: https://github.com/codespell-project/codespell#using-a-config-file
[codespell]
# In the event of a false positive, add the problematic word, in all lowercase, to 'ignore-words.txt' (one word per line).
# Or copy & paste the whole problematic line to 'exclude-file.txt'
ignore-words = ./tools/.codespell/ignore-words.txt
exclude-file = ./tools/.codespell/exclude-file.txt
check-filenames =
check-hidden =
count =
skip = .git,*.a,
# See: https://github.com/codespell-project/codespell#using-a-config-file
[codespell]
# In the event of a false positive, add the problematic word, in all lowercase, to 'ignore-words.txt' (one word per line).
# Or copy & paste the whole problematic line to 'exclude-file.txt'
ignore-words = ./tools/.codespell/ignore-words.txt
exclude-file = ./tools/.codespell/exclude-file.txt
check-filenames =
check-hidden =
count =
skip = .git,*.a,
1 change: 1 addition & 0 deletions tools/.codespell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions tools/.codespell/exclude-file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tools/**
.github/**
10 changes: 5 additions & 5 deletions tools/.codespell/ignore-words.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
teh
foobar
pris
bu
dout
teh
foobar
pris
bu
dout
1 change: 1 addition & 0 deletions tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit eeacedd

Please sign in to comment.