Skip to content

Commit

Permalink
Update the tools to the latest versions and add new static analysis d…
Browse files Browse the repository at this point in the history
…iagnostics (#210)

There are no semantic changes to the codebase in this changeset.

Closes #209
Closes #207
  • Loading branch information
pavel-kirienko authored Apr 14, 2023
1 parent 5c69d45 commit 8ce8ed2
Show file tree
Hide file tree
Showing 14 changed files with 10,894 additions and 4,915 deletions.
37 changes: 23 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Main Workflow
on: [push, pull_request]
env:
LLVM_VERSION: 13
LLVM_VERSION: 15
jobs:
debug:
if: github.event_name == 'push'
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -16,7 +17,7 @@ jobs:
c-compiler: clang
cxx-compiler: clang++
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
Expand All @@ -36,14 +37,15 @@ jobs:
run: |
make VERBOSE=1
make test
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: always()
with:
name: ${{github.job}}
path: ${{github.workspace}}/**/*
retention-days: 2

optimizations:
if: github.event_name == 'push'
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -57,7 +59,7 @@ jobs:
c-compiler: clang
cxx-compiler: clang++
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: |
sudo apt update -y && sudo apt upgrade -y
sudo apt install gcc-multilib g++-multilib
Expand All @@ -73,20 +75,21 @@ jobs:
run: |
make VERBOSE=1
make test
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: always()
with:
name: ${{github.job}}
path: ${{github.workspace}}/**/*
retention-days: 2

avr:
if: github.event_name == 'push'
runs-on: ubuntu-latest
env:
mcu: at90can64
flags: -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: |
sudo apt update -y && sudo apt upgrade -y
sudo apt install gcc-avr avr-libc
Expand All @@ -97,29 +100,36 @@ jobs:
- run: avr-gcc libcanard/*.c -c -std=gnu11 -mmcu=${{ env.mcu }} ${{ env.flags }}

arm:
if: github.event_name == 'push'
runs-on: ubuntu-latest
env:
flags: -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits -Wcast-align -Wfatal-errors
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: |
sudo apt update -y && sudo apt upgrade -y
sudo apt-get install -y gcc-arm-none-eabi
- run: arm-none-eabi-gcc libcanard/*.c -c -std=c99 ${{ env.flags }}
- run: arm-none-eabi-gcc libcanard/*.c -c -std=c11 ${{ env.flags }}

style_check:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.13
- uses: actions/checkout@v3
- uses: DoozyX/clang-format-lint-action@v0.15
with:
source: './libcanard ./tests'
exclude: './tests/catch'
extensions: 'c,h,cpp,hpp'
clangFormatVersion: ${{ env.LLVM_VERSION }}

sonarcloud:
if: >
github.event_name == 'pull_request' ||
contains(github.ref, '/master') ||
contains(github.ref, '/release') ||
contains(github.event.head_commit.message, '#sonar')
runs-on: ubuntu-latest
env:
SONAR_SCANNER_VERSION: 4.6.1.2450
Expand All @@ -128,7 +138,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -138,9 +148,10 @@ jobs:
sudo apt install -y gcc-multilib g++-multilib
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 11
distribution: zulu

- name: Cache SonarCloud packages
uses: actions/cache@v1
Expand Down Expand Up @@ -184,12 +195,10 @@ jobs:
--define sonar.sources=libcanard
--define sonar.exclusions=libcanard/cavl.h
--define sonar.cfamily.gcov.reportsPath=.
--define sonar.cfamily.cache.enabled=false
--define sonar.cfamily.threads=2
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
--define sonar.host.url="${{ env.SONAR_SERVER_URL }}"
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: always()
with:
name: ${{github.job}}
Expand Down
1 change: 1 addition & 0 deletions .idea/dictionaries/pavel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If you want to contribute, please read [`CONTRIBUTING.md`](/CONTRIBUTING.md).
- Support for the Classic CAN and CAN FD.
- Support for redundant transports.
- Compatibility with 8/16/32/64-bit platforms.
- Compatibility with extremely resource-constrained baremetal environments starting from 32K ROM and 8K RAM.
- Compatibility with extremely resource-constrained baremetal environments starting from 32K ROM and 32K RAM.
- Implemented in ≈1000 lines of code.

## Platforms
Expand Down
1 change: 1 addition & 0 deletions libcanard/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Checks: >-
-cert-dcl03-c,
-hicpp-static-assert,
-misc-static-assert,
-modernize-macro-to-enum,
CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: '99'
Expand Down
1 change: 1 addition & 0 deletions tests/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Checks: >-
-*-no-malloc,
-cert-msc30-c,
-cert-msc50-cpp,
-modernize-macro-to-enum,
WarningsAsErrors: '*'
HeaderFilterRegex: '.*\.hpp'
AnalyzeTemporaryDtors: false
Expand Down
9 changes: 5 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enable_testing()
set(CTEST_OUTPUT_ON_FAILURE ON)
set(library_dir "${CMAKE_SOURCE_DIR}/../libcanard")

set(NO_STATIC_ANALYSIS OFF CACHE BOOL "disable canard static analysis")
set(NO_STATIC_ANALYSIS OFF CACHE BOOL "disable canard static analysis")
set(NO_CANARD_SANITIZER OFF CACHE BOOL "disable canard runtime sanitizers")

# Use -DNO_STATIC_ANALYSIS=1 to suppress static analysis.
Expand All @@ -27,7 +27,7 @@ if (NOT NO_STATIC_ANALYSIS)
endif()
if(NOT NO_CANARD_SANITIZER)
# libclang_rt.builtins-i386.a required by some sanitizers on x86-32 clang
find_library(LLVM_RT_32 NAMES libclang_rt.builtins-i386.a PATHS /usr/lib/clang/12/lib/linux/)
find_library(LLVM_RT_32 NAMES libclang_rt.builtins-i386.a PATHS /usr/lib/clang/)
if(NOT LLVM_RT_32 MATCHES "NOTFOUND")
message(STATUS "adding runtime for sanitizer ${LLVM_RT_32}")
list(APPEND ADDITIONAL_LIBS_32 ${LLVM_RT_32})
Expand Down Expand Up @@ -68,10 +68,11 @@ add_compile_options(
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wsign-promo")

include_directories(catch ${library_dir})
include_directories(${library_dir})
include_directories(SYSTEM catch)
add_definitions(-DCATCH_CONFIG_FAST_COMPILE=1 -DCATCH_CONFIG_ENABLE_ALL_STRINGMAKERS=1)

set(common_sources catch/main.cpp ${library_dir}/canard.c)
set(common_sources ${CMAKE_SOURCE_DIR}/main.cpp ${library_dir}/canard.c)

function(gen_test name files compile_definitions compile_flags link_flags c_standard)
add_executable(${name} ${common_sources} ${files})
Expand Down
Loading

0 comments on commit 8ce8ed2

Please sign in to comment.