Skip to content

use safe memory lib and add memory leaks checks to CI #120

use safe memory lib and add memory leaks checks to CI

use safe memory lib and add memory leaks checks to CI #120

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:
build:
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 valgrind -y
- name: Build Brainrot
run: |
bison -d -Wcounterexamples lang.y -o lang.tab.c
flex lang.l
gcc -o brainrot lib/hm.c lib/mem.c lang.tab.c lex.yy.c ast.c -lfl -lm
- 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 -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: .