Skip to content
This repository was archived by the owner on Nov 22, 2023. It is now read-only.

Commit

Permalink
ci: Check editorconfig settings
Browse files Browse the repository at this point in the history
  • Loading branch information
zarubaf committed Dec 7, 2020
1 parent d54b22e commit ba4006f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

# SystemVerilog wants 2 spaces of indentation
[*.{sv,svh}]
Expand Down
15 changes: 15 additions & 0 deletions .github/editorconfig-checker-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"problemMatcher": [
{
"owner": "editorconfig-checker-matcher",
"pattern": [
{
"regexp": "^(.+) error found in (.+?)(\\d+)?$",
"file": 2,
"line": 3,
"message": 1
}
]
}
]
}
20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ jobs:
with:
clangFormatVersion: 10

######################
# Lint Editor Config #
######################
# Detect trailing whitespaces, missing new lines and wrong file encodings.
lint-editorconfig:
name: Lint Editorconfig
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install requirements
run: pip install -r python-requirements.txt
- name: Check files
run: |
echo "::add-matcher::.github/editorconfig-checker-matcher.json"
util/lint-editorconfig
echo "::remove-matcher owner=editorconfig-checker-matcher::"
################
# Lint Commits #
################
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
2 changes: 1 addition & 1 deletion hw/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
1 change: 1 addition & 0 deletions python-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

editorconfig-checker
gitpython
hjson
mako
Expand Down
15 changes: 15 additions & 0 deletions util/lint-editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# Copyright 2020 ETH Zurich and University of Bologna.
# Solderpad Hardware License, Version 0.51, see LICENSE for details.
# SPDX-License-Identifier: SHL-0.51

set -e
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)

# Skip third party sources and disable identation as it doesn't cope well with
# lines which belong to the previous line.
cd $ROOT && \
editorconfig-checker \
-disable-indentation \
-v \
-exclude "(hw/vendor/*)|(sw/vendor/*)|(util/lowrisc_misc-linters/*)"
2 changes: 1 addition & 1 deletion util/vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,4 +771,4 @@ def main(argv):
raise
except KeyboardInterrupt:
log.info("Aborting operation on user request.")
sys.exit(1)
sys.exit(1)

0 comments on commit ba4006f

Please sign in to comment.