From f039554c79a6644c263fe539e9da4f1be496a25f Mon Sep 17 00:00:00 2001 From: Ryan Ho Date: Wed, 24 Apr 2024 21:49:03 -0400 Subject: [PATCH] Added pre-commit hook for clang-format (linter) and integrated GitHub actions workflow for clang-tidy CI --- .clang-format | 3 +++ .github/workflows/clang-tidy.yaml | 36 +++++++++++++++++++++++++++++++ .vscode/settings.json | 5 +++++ 3 files changed, 44 insertions(+) create mode 100644 .clang-format create mode 100644 .github/workflows/clang-tidy.yaml create mode 100644 .vscode/settings.json diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..90c53c3 --- /dev/null +++ b/.clang-format @@ -0,0 +1,3 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +ColumnLimit: 80 \ No newline at end of file diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml new file mode 100644 index 0000000..5fb640a --- /dev/null +++ b/.github/workflows/clang-tidy.yaml @@ -0,0 +1,36 @@ +name: Clang-Tidy CI + +on: + # Run the workflow on every pull request to the main branch + pull_request: + branches: + - main + # Optionally, run the workflow on each push to the repository + push: + branches: + - main + +jobs: + clang_tidy_check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up build environment + run: | + sudo apt update + sudo apt install -y clang-tidy cmake build-essential + + - name: Build project + run: | + mkdir build + cd build + cmake .. + make + + - name: Run Clang-Tidy + run: | + cd build + clang-tidy ../src/**/*.cpp -- -I../include -std=c++20 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e2c18d1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "ostream": "cpp" + } +} \ No newline at end of file