Skip to content

ci: add static code analysis tools #155

ci: add static code analysis tools

ci: add static code analysis tools #155

Workflow file for this run

name: Brainrot CI
on:
workflow_dispatch:
push:
branches: ["main"]
paths-ignore:
- "**/*.md"
- "CODEOWNERS"
- "Makefile"
pull_request:
branches: ["main"]
paths-ignore:
- "**/*.md"
- "CODEOWNERS"
- "Makefile"
jobs:
static-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install analysis tools
run: |
sudo apt-get update
sudo apt-get install cppcheck clang-tidy clang-format flawfinder splint -y
- name: Run cppcheck
run: cppcheck --enable=all --inconclusive --error-exitcode=1 --suppress=unusedFunction .
- name: Run clang-tidy
run: |
find . -name '*.c' -o -name '*.h' | xargs clang-tidy -checks=*,-clang-analyzer-security.insecureAPI.* --
- name: Check formatting
run: |
find . -name '*.c' -o -name '*.h' | xargs clang-format --dry-run -Werror
- name: Run flawfinder
run: flawfinder --minlevel=1 .
- name: Run splint
run: find . -name '*.c' -o -name '*.h' | xargs splint
build:
needs: static-analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install gcc flex bison libfl-dev -y
- name: Build Brainrot
run: |
make
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: brainrot
path: brainrot
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Brainrot artifact
uses: actions/download-artifact@v4
with:
name: brainrot
- name: Grant execute permissions to Brainrot
run: chmod +x brainrot
- name: Install Python and dependencies
run: |
sudo apt-get update
sudo apt-get install python3 python3-pip valgrind -y
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
working-directory: tests
- name: Run Pytest
run: |
source .venv/bin/activate
pytest -v test_brainrot.py
working-directory: tests
- name: Run Valgrind on all .brainrot tests
run: |
for f in test_cases/*.brainrot; do
echo "Running Valgrind on $f..."
valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
echo
done
working-directory: .