Skip to content

Commit

Permalink
Fix #338, Add MISRA Addons for cppcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
arielswalker committed Aug 18, 2021
1 parent ed34865 commit 49dd75e
Showing 1 changed file with 76 additions and 8 deletions.
84 changes: 76 additions & 8 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

jobs:
#Checks for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action.
#Checks for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action.
check-for-duplicates:
runs-on: ubuntu-latest
# Map a step output to a job output
Expand All @@ -19,7 +19,6 @@ jobs:
concurrent_skipping: 'same_content'
skip_after_successful_duplicate: 'true'
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'

static-analysis:
#Continue if check-for-duplicates found no duplicates. Always runs for pull-requests.
needs: check-for-duplicates
Expand All @@ -32,7 +31,7 @@ jobs:
matrix:
cppcheck: [bundle, cfe, osal, psp]

steps:
steps:
- name: Install cppcheck
run: sudo apt-get install cppcheck -y

Expand All @@ -41,30 +40,99 @@ jobs:
uses: actions/checkout@v2
with:
submodules: true

- name: Run bundle cppcheck
if: ${{matrix.cppcheck =='bundle'}}
run: cppcheck --force --inline-suppr --quiet . 2> ${{matrix.cppcheck}}_cppcheck_err.txt

run: |
cppcheck --force --inline-suppr --quiet . 2> ${{matrix.cppcheck}}_cppcheck_err.txt
# Run strict static analysis for embedded portions of cfe, osal, and psp
- name: cfe strict cppcheck
if: ${{matrix.cppcheck =='cfe'}}
run: |
cd ${{matrix.cppcheck}}
cppcheck --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./modules/core_api/fsw ./modules/core_private/fsw ./modules/es/fsw ./modules/evs/fsw ./modules/fs/fsw ./modules/msg/fsw ./modules/resourceid/fsw ./modules/sb/fsw ./modules/sbr/fsw ./modules/tbl/fsw ./modules/time/fsw -UCFE_PLATFORM_TIME_CFG_CLIENT -DCFE_PLATFORM_TIME_CFG_SERVER 2> ../${{matrix.cppcheck}}_cppcheck_err.txt
- name: osal strict cppcheck
if: ${{matrix.cppcheck =='osal'}}
run: |
cd ${{matrix.cppcheck}}
cppcheck --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./src/bsp ./src/os 2> ../${{matrix.cppcheck}}_cppcheck_err.txt
- name: psp strict cppcheck
if: ${{matrix.cppcheck =='psp'}}
run: |
cd ${{matrix.cppcheck}}
cppcheck --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./fsw 2> ../${{matrix.cppcheck}}_cppcheck_err.txt
- name: Archive Static Analysis Artifacts
uses: actions/upload-artifact@v2
with:
name: ${{matrix.cppcheck}}-cppcheck-err
path: ./*cppcheck_err.txt

- name: Check for errors
run: |
if [[ -s ${{matrix.cppcheck}}_cppcheck_err.txt ]];
then
cat ${{matrix.cppcheck}}_cppcheck_err.txt
exit -1
fi
misra-analysis:
#Continue if check-for-duplicates found no duplicates. Always runs for pull-requests.
needs: check-for-duplicates
if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }}
name: Run cppcheck with misra
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
cppcheck: [bundle, cfe, osal, psp]

steps:
- name: Install cppcheck
run: sudo apt-get install cppcheck -y

# Checks out a copy of the cfs bundle
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: true

- name: get MISRA addon
run: |
sudo apt-get install git -y
git clone https://github.com/danmar/cppcheck.git
cp cppcheck/addons/misra.py misra.py
cp cppcheck/addons/cppcheckdata.py cppcheckdata.py
cp cppcheck/addons/misra_9.py misra_9.py
- name: Run bundle cppcheck
if: ${{matrix.cppcheck =='bundle'}}
run: |
cppcheck --addon=misra --force --inline-suppr --quiet . 2> ${{matrix.cppcheck}}_cppcheck_err.txt
# Run strict static analysis for embedded portions of cfe, osal, and psp
- name: cfe strict cppcheck
if: ${{matrix.cppcheck =='cfe'}}
run: |
cd ${{matrix.cppcheck}}
cppcheck --addon=misra --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./modules/core_api/fsw ./modules/core_private/fsw ./modules/es/fsw ./modules/evs/fsw ./modules/fs/fsw ./modules/msg/fsw ./modules/resourceid/fsw ./modules/sb/fsw ./modules/sbr/fsw ./modules/tbl/fsw ./modules/time/fsw -UCFE_PLATFORM_TIME_CFG_CLIENT -DCFE_PLATFORM_TIME_CFG_SERVER 2> ../${{matrix.cppcheck}}_cppcheck_err.txt
- name: osal strict cppcheck
if: ${{matrix.cppcheck =='osal'}}
run: |
cd ${{matrix.cppcheck}}
cppcheck --addon=misra --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./src/bsp ./src/os 2> ../${{matrix.cppcheck}}_cppcheck_err.txt
- name: psp strict cppcheck
if: ${{matrix.cppcheck =='psp'}}
run: |
cd ${{matrix.cppcheck}}
cppcheck --addon=misra --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./fsw 2> ../${{matrix.cppcheck}}_cppcheck_err.txt
- name: Archive Static Analysis Artifacts
uses: actions/upload-artifact@v2
with:
Expand Down

0 comments on commit 49dd75e

Please sign in to comment.