From d70c60ee9ddb321837309c08db102c36552175c2 Mon Sep 17 00:00:00 2001 From: Linus Boehm Date: Mon, 14 Oct 2024 15:33:12 -0400 Subject: [PATCH 1/2] feat: add automatic linting suggestion github workflow --- .github/workflows/reviewdog.yml | 42 +++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 33 ++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 .github/workflows/reviewdog.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 0000000..9742e08 --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,42 @@ +name: linter-checks +on: [pull_request] +jobs: + cpp: + permissions: + contents: read + checks: write + issues: write + pull-requests: write + name: pre-commit + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.11 + + - name: Cache pre-commit hooks + uses: actions/cache@v2 + with: + path: ~/.cache/pre-commit + key: ${{ runner.os }}-precommit-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Install dependencies + run: | + pip install pre-commit + + - name: Run pre-commit hooks + run: | + pre-commit run --all-files + continue-on-error: true + + - name: suggester / pre-commit + uses: reviewdog/action-suggester@v1 + with: + tool_name: pre-commit + fail_on_error: true + level: warning + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..049fccf --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + # Clang-format for C++ + # This brings in a portable version of clang-format. + # See also: https://github.com/ssciwr/clang-format-wheel + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v18.1.8 + hooks: + - id: clang-format + types_or: [c++, c] + + # CMake linting and formatting + - repo: https://github.com/BlankSpruce/gersemi + rev: 0.15.1 + hooks: + - id: gersemi + name: CMake linting + + # Markdown linting + # Config file: .markdownlint.yaml + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.42.0 + hooks: + - id: markdownlint From 14667a9a767f898618c95e29c3ff282b086839b6 Mon Sep 17 00:00:00 2001 From: Linus Boehm Date: Mon, 14 Oct 2024 15:36:11 -0400 Subject: [PATCH 2/2] add cpp file with bad formatting --- src/beman/exemplar/badly_formatted_main.cpp | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/beman/exemplar/badly_formatted_main.cpp diff --git a/src/beman/exemplar/badly_formatted_main.cpp b/src/beman/exemplar/badly_formatted_main.cpp new file mode 100644 index 0000000..d59abd8 --- /dev/null +++ b/src/beman/exemplar/badly_formatted_main.cpp @@ -0,0 +1,3 @@ +int main() +{ + return 0; }