Static Analysis #104
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Static Analysis | |
# Run on all push and pull requests | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
# 11:59 PM UTC every Sunday | |
- cron: '59 23 * * 0' | |
jobs: | |
#Checks for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action. | |
check-for-duplicates: | |
runs-on: ${{ github.repository_owner == 'cFS' && 'linux' || 'ubuntu-latest' }} | |
# Map a step output to a job output | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@master | |
with: | |
concurrent_skipping: 'same_content' | |
skip_after_successful_duplicate: 'true' | |
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' | |
static-analysis: | |
name: Run cppcheck | |
needs: check-for-duplicates | |
runs-on: ${{ github.repository_owner == 'cFS' && 'linux' || 'ubuntu-latest' }} | |
steps: | |
- name: Checkout bundle | |
uses: actions/checkout@v3 | |
with: | |
repository: arielswalker/cFS | |
- name: Checkout submodule | |
uses: actions/checkout@v3 | |
with: | |
path: source | |
submodules: true | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '14' | |
- name: Make script executable | |
run: chmod +x ./.github/scripts/cppcheck.sh | |
- name: Run static analysis script | |
run: ./.github/scripts/cppcheck.sh | |
env: | |
STRICT_DIR_LIST: './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' | |
- name: Upload SARIF results | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: cppcheck_err.sarif | |
checkout_path: ${{ github.workspace }}/source | |
category: 'cppcheck' | |
- name: Archive static analysis artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cppcheck-errors | |
path: ./*cppcheck_err.* | |
- name: Check for reported errors | |
run: tail -n 1 cppcheck_err.txt | grep -q '^\*\*0 error(s) reported\*\*$' |