Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
vla5924 committed Mar 30, 2024
1 parent 7636712 commit 2dce2b8
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 1 deletion.
98 changes: 98 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
WarningsAsErrors: '*'

Checks: >
-*,
bugprone-assignment-in-if-condition,
bugprone-forward-declaration-namespace,
bugprone-infinite-loop,
bugprone-integer-division,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-move-forwarding-reference,
bugprone-redundant-branch-condition,
bugprone-reserved-identifier,
bugprone-suspicious-include,
bugprone-suspicious-semicolon,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-unused-raii,
bugprone-unused-return-value,
cppcoreguidelines-macro-usage,
llvm-include-order,
llvm-namespace-comment,
misc-confusable-identifiers,
misc-definitions-in-headers,
misc-header-include-cycle,
misc-include-cleaner,
misc-misplaced-const,
misc-non-copyable-objects,
misc-redundant-expression,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
misc-unconventional-assign-operator,
misc-unused-alias-decls,
misc-unused-parameters,
misc-unused-using-decls,
misc-use-anonymous-namespace,
modernize-avoid-c-arrays,
modernize-deprecated-headers,
modernize-loop-convert,
modernize-make-shared,
modernize-make-unique,
modernize-raw-string-literal,
modernize-return-braced-init-list,
modernize-type-traits,
modernize-use-auto,
modernize-use-constraints,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-override,
modernize-use-starts-ends-with,
modernize-use-std-numbers,
performance-avoid-endl,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-no-automatic-move,
performance-trivially-destructible,
performance-unnecessary-copy-initialization,
performance-unnecessary-value-param,
readability-avoid-const-params-in-decls,
readability-avoid-nested-conditional-operator,
readability-avoid-return-with-void-value,
readability-const-return-type,
readability-container-contains,
readability-identifier-naming,
readability-inconsistent-declaration-parameter-name,
readability-misleading-indentation,
readability-non-const-parameter,
readability-qualified-auto,
readability-redundant-smartptr-get,
readability-redundant-string-init,
readability-simplify-boolean-expr,
readability-simplify-subscript-expr,
readability-uppercase-literal-suffix,
cppcoreguidelines-avoid-goto
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: camelBack
- key: readability-identifier-naming.MemberCase
value: camelBack
- key: readability-identifier-naming.ParameterCase
value: camelBack
- key: readability-identifier-naming.UnionCase
value: camelBack
- key: readability-identifier-naming.VariableCase
value: camelBack
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 1
- key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
value: 1
- key: modernize-use-default-member-init.UseAssignment
value: 1
56 changes: 55 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: CI

permissions:
contents: read
actions: read
security-events: write

on:
push:
branches:
Expand Down Expand Up @@ -47,7 +52,7 @@ jobs:
submodules: true
- name: Build
run: |
cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_IR_GENERATOR=OFF
cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_CODEGEN=OFF
ninja -C build
- name: Archive binaries
run: tar cf binaries.tar -C build bin
Expand Down Expand Up @@ -118,3 +123,52 @@ jobs:
file: ./build/coverage.info
format: lcov
fail-on-error: false

clang-tidy:
name: Clang-tidy analysis
runs-on: ubuntu-latest
needs: code-style-check
if: github.event_name == 'pull_request'
container:
image: ghcr.io/vla5924-practice/compiler-project/devcontainer:latest
options: --user root
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
steps:
- name: Install dependencies
run: |
wget --no-check-certificate -qL -O clang-tidy-sarif https://github.com/psastras/sarif-rs/releases/download/clang-tidy-sarif-v0.4.2/clang-tidy-sarif-x86_64-unknown-linux-gnu
chmod +x clang-tidy-sarif
mv clang-tidy-sarif /usr/bin
ln -s /usr/share/clang/clang-tidy-diff.py /usr/bin/clang-tidy-diff
- name: Initialize repository
uses: actions/checkout@v4
with:
fetch-depth: 50
submodules: true
- name: Configure Git
run: |
git config --global --add safe.directory $(pwd)
git fetch origin main
- name: Build compilation database
run: |
cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_CODEGEN=OFF
cmake --build build --parallel
- name: Run clang-tidy analysis
run: |
git diff -U0 origin/main | clang-tidy-diff -p1 -path build > clang-tidy.log
cat clang-tidy.log
clang-tidy-sarif clang-tidy.log clang-tidy.json
sed -i -E "s@${PWD}/@@" clang-tidy.json
- name: Upload report
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: clang-tidy.json
category: clang-tidy
- name: Verify result
run: |
if grep -q '"level": "error"' clang-tidy.json; then
echo "Errors were found during clang-tidy analysis."
false
fi
1 change: 1 addition & 0 deletions compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ endif()
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/archive)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down

0 comments on commit 2dce2b8

Please sign in to comment.