Skip to content
Merged

Exp #59

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
---
# Clang-Format Configuration File
# ----------------------------------------------------
BasedOnStyle: LLVM
Language: Cpp

# Indentation and Tab Settings
IndentWidth: 6
UseTab: Never
TabWidth: 6
ContinuationIndentWidth: 6

# Brace Wrapping
BreakBeforeBraces: Allman

# Formatting Geometry & Constraints
ColumnLimit: 100
PointerAlignment: Right
ReferenceAlignment: Right

# Include Management
SortIncludes: CaseInsensitive
IncludeBlocks: Regroup
# Spacing rules
SpaceBeforeParens: ControlStatements
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
Expand All @@ -23,5 +36,7 @@ AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortBlocksOnASingleLine: Empty
# Braced initializer list formatting (e.g. vector/array initialization)
Cpp11BracedListStyle: true
SpacesInAngles: Never
...
12 changes: 0 additions & 12 deletions .devops/Dockerfile.dev.frontend

This file was deleted.

30 changes: 14 additions & 16 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ on:
- "**/*.py"
- "**/*.cpp"
- "**/*.c"
- "**/*.h"
- "**/*.hpp"
pull_request:
branches: [ "master" ]
paths:
- "**/*.py"
- "**/*.cpp"
- "**/*.c"
- "**/*.h"
- "**/*.hpp"

jobs:
syntax-check:
Expand All @@ -35,38 +39,32 @@ jobs:

- name: Lint Python Files
run: |
# Only checks syntax and severe errors
flake8 . --count --select=E999,F821,F822,F823 --show-source --statistics

# --- C/C++ Syntax Check ---
- name: Install C/C++ Compiler (GCC)
run: |
sudo apt-get update
sudo apt-get install -y gcc g++

# E9, F63, F7, F82 checks syntax errors & undefined variables
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Check C/C++ Syntax
run: |
echo "Checking C and C++ files for syntax errors..."
errors=0

# Using redirect loops to properly catch errors without subshell issues
# Loop through C files (-I. includes local root directory for header lookups)
while read -r file; do
if [ -z "$file" ]; then continue; fi
echo "Checking $file"
if ! gcc -fsyntax-only "$file"; then
echo "Syntax error in $file"
if ! gcc -fsyntax-only -I. "$file"; then
echo "::error file=$file::Syntax error in $file"
errors=$((errors + 1))
fi
done < <(find . -name "*.c")
done < <(find . -type f -name "*.c")

# Loop through C++ files
while read -r file; do
if [ -z "$file" ]; then continue; fi
echo "Checking $file"
if ! g++ -fsyntax-only "$file"; then
echo "syntax error in $file"
if ! g++ -fsyntax-only -I. "$file"; then
echo "::error file=$file::Syntax error in $file"
errors=$((errors + 1))
fi
done < <(find . -name "*.cpp")
done < <(find . -type f -name "*.cpp")

if [ $errors -ne 0 ]; then
echo "$errors file(s) failed syntax verification."
Expand Down
118 changes: 68 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Build & Test
on:
push:
branches: [ master, main, develop ]

jobs:
cpp-quality:
runs-on: ubuntu-latest
Expand All @@ -22,7 +23,7 @@ jobs:
- name: Clang-Format Check
id: clang-format
run: |
echo "### 🔍 Clang-Format Code Style Check" >> $GITHUB_STEP_SUMMARY
echo "### Clang-Format Code Style Check" >> $GITHUB_STEP_SUMMARY
find . -name "*.cpp" -o -name "*.h" -o -name "*.hpp" | grep -v build > cpp_files.txt

if [ -s cpp_files.txt ]; then
Expand All @@ -32,10 +33,10 @@ jobs:
cat format_output.txt >> $GITHUB_STEP_SUMMARY
exit 1
else
echo " Code formatting is correct" >> $GITHUB_STEP_SUMMARY
echo "Code formatting is correct" >> $GITHUB_STEP_SUMMARY
fi
else
echo " No C++ files found" >> $GITHUB_STEP_SUMMARY
echo "No C++ files found" >> $GITHUB_STEP_SUMMARY
fi
continue-on-error: true

Expand All @@ -55,7 +56,7 @@ jobs:
echo "Issues detected:" >> $GITHUB_STEP_SUMMARY
cat cppcheck_output.txt >> $GITHUB_STEP_SUMMARY
else
echo " No critical issues found" >> $GITHUB_STEP_SUMMARY
echo "No critical issues found" >> $GITHUB_STEP_SUMMARY
fi
continue-on-error: true

Expand Down Expand Up @@ -88,7 +89,7 @@ jobs:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
Expand All @@ -101,10 +102,10 @@ jobs:
- name: Black Format Check
id: black
run: |
echo "### Black Code Formatting" >> $GITHUB_STEP_SUMMARY
echo "### Black Code Formatting" >> $GITHUB_STEP_SUMMARY
black --check --diff . 2>&1 | tee black_output.txt || true
if [ $? -ne 0 ]; then
echo " Formatting issues detected:" >> $GITHUB_STEP_SUMMARY
echo "Formatting issues detected:" >> $GITHUB_STEP_SUMMARY
head -30 black_output.txt >> $GITHUB_STEP_SUMMARY
else
echo "Black formatting passed" >> $GITHUB_STEP_SUMMARY
Expand All @@ -127,38 +128,38 @@ jobs:
- name: Flake8 Linting
id: flake8
run: |
echo "### Flake8 Linting" >> $GITHUB_STEP_SUMMARY
echo "### Flake8 Linting" >> $GITHUB_STEP_SUMMARY
flake8 . --max-line-length=127 --count --statistics 2>&1 | tee flake8_output.txt || true
if [ $? -ne 0 ]; then
echo "Linting violations:" >> $GITHUB_STEP_SUMMARY
cat flake8_output.txt >> $GITHUB_STEP_SUMMARY
else
echo " Flake8 passed" >> $GITHUB_STEP_SUMMARY
echo "Flake8 passed" >> $GITHUB_STEP_SUMMARY
fi
continue-on-error: true

- name: Pylint Analysis
id: pylint
run: |
echo "### Pylint Code Analysis" >> $GITHUB_STEP_SUMMARY
echo "### Pylint Code Analysis" >> $GITHUB_STEP_SUMMARY
find . -name "*.py" -type f | grep -v __pycache__ | xargs pylint \
--fail-under=7.0 \
--disable=C0111,C0103,R0913,W0212 \
2>&1 | tee pylint_output.txt || true

if grep -q "rated at" pylint_output.txt; then
echo " Pylint analysis complete" >> $GITHUB_STEP_SUMMARY
echo "Pylint analysis complete" >> $GITHUB_STEP_SUMMARY
tail -3 pylint_output.txt >> $GITHUB_STEP_SUMMARY
fi
continue-on-error: true

- name: Bandit Security Scan
id: bandit
run: |
echo "### Bandit Security Check" >> $GITHUB_STEP_SUMMARY
echo "### Bandit Security Check" >> $GITHUB_STEP_SUMMARY
bandit -r . -ll 2>&1 | tee bandit_output.txt || true
if grep -q "Issue:" bandit_output.txt; then
echo " Security issues found:" >> $GITHUB_STEP_SUMMARY
echo "Security issues found:" >> $GITHUB_STEP_SUMMARY
grep -A1 "Issue:" bandit_output.txt >> $GITHUB_STEP_SUMMARY
else
echo "No security issues detected" >> $GITHUB_STEP_SUMMARY
Expand All @@ -171,6 +172,10 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false

defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v4
Expand All @@ -181,12 +186,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential g++

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install gcc
sudo apt-get install -y build-essential g++ libomp-dev

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
Expand All @@ -196,39 +196,57 @@ jobs:
- name: Build inference executable
id: build-inference
run: |
echo "### 🔨 Building Inference Executable" >> $GITHUB_STEP_SUMMARY
echo "### Building Inference Executable" >> $GITHUB_STEP_SUMMARY

if [ -f "main.cpp" ]; then
g++ -std=c++17 -O2 -I. -Iinclude -o quadtrix_inference main.cpp 2>&1 | tee inference_build.txt || true

if [ -f "quadtrix_inference" ] || [ -f "quadtrix_inference.exe" ]; then
echo " Inference build successful" >> $GITHUB_STEP_SUMMARY
if [ "$RUNNER_OS" == "macOS" ]; then
echo "Building for macOS with Metal framework support..."
if [ -f "llm.mm" ] && [ -f "main.cpp" ]; then
clang++ -std=c++17 -O3 -I. -Iinclude main.cpp llm.mm -framework Foundation -framework Metal -framework MetalPerformanceShaders -o llm 2>&1 | tee inference_build.txt || true
elif [ -f "main.cpp" ]; then
clang++ -std=c++17 -O3 -I. -Iinclude main.cpp -o llm 2>&1 | tee inference_build.txt || true
fi

if [ -f "llm" ]; then
echo "Inference build successful (macOS)" >> $GITHUB_STEP_SUMMARY
else
echo "Inference build failed" >> $GITHUB_STEP_SUMMARY
echo "Inference build failed (macOS)" >> $GITHUB_STEP_SUMMARY
cat inference_build.txt >> $GITHUB_STEP_SUMMARY
fi

else
echo "main.cpp not found - skipping inference build" >> $GITHUB_STEP_SUMMARY
echo "Building for $RUNNER_OS with GCC..."
if [ -f "main.cpp" ]; then
g++ -std=c++17 -O3 -march=native -fopenmp -I. -Iinclude -o llm.exe main.cpp 2>&1 | tee inference_build.txt || true

if [ -f "llm.exe" ]; then
echo "Inference build successful ($RUNNER_OS)" >> $GITHUB_STEP_SUMMARY
else
echo "Inference build failed ($RUNNER_OS)" >> $GITHUB_STEP_SUMMARY
cat inference_build.txt >> $GITHUB_STEP_SUMMARY
fi
else
echo "main.cpp not found - skipping inference build" >> $GITHUB_STEP_SUMMARY
fi
fi
continue-on-error: true

- name: Test inference executable
id: test-inference
run: |
echo "### Testing Inference Executable" >> $GITHUB_STEP_SUMMARY
echo "### Testing Inference Executable" >> $GITHUB_STEP_SUMMARY

if [ -f "quadtrix_inference" ] || [ -f "quadtrix_inference.exe" ]; then
BINARY="quadtrix_inference"
if [ ! -f "$BINARY" ]; then
BINARY="quadtrix_inference.exe"
fi
BINARY="llm.exe"
if [ "$RUNNER_OS" == "macOS" ]; then
BINARY="llm"
fi

if [ -f "$BINARY" ]; then
if [ -f "data/input.txt" ]; then
./$BINARY data/input.txt 2>&1 | tee inference_test.txt || true
echo "Inference test completed" >> $GITHUB_STEP_SUMMARY
head -20 inference_test.txt >> $GITHUB_STEP_SUMMARY
else
echo " data/input.txt not found - skipping inference test" >> $GITHUB_STEP_SUMMARY
echo "data/input.txt not found - skipping inference test" >> $GITHUB_STEP_SUMMARY
fi
else
echo "Inference executable not found" >> $GITHUB_STEP_SUMMARY
Expand All @@ -244,29 +262,29 @@ jobs:
g++ -std=c++17 -O2 -I. -Iinclude llm.cpp train.cpp -o quadtrix_train 2>&1 | tee training_build.txt || true

if [ -f "quadtrix_train" ] || [ -f "quadtrix_train.exe" ]; then
echo " Training build successful" >> $GITHUB_STEP_SUMMARY
echo "Training build successful" >> $GITHUB_STEP_SUMMARY
else
echo " Training build failed" >> $GITHUB_STEP_SUMMARY
echo "Training build failed" >> $GITHUB_STEP_SUMMARY
cat training_build.txt >> $GITHUB_STEP_SUMMARY
fi
elif [ -f "train.cpp" ]; then
echo " train.cpp found but llm.cpp not found - skipping training build" >> $GITHUB_STEP_SUMMARY
echo "train.cpp found but llm.cpp not found - skipping training build" >> $GITHUB_STEP_SUMMARY
else
echo " train.cpp not found - skipping training build" >> $GITHUB_STEP_SUMMARY
echo "train.cpp not found - skipping training build" >> $GITHUB_STEP_SUMMARY
fi
continue-on-error: true

- name: Test training executable
id: test-training
run: |
echo "### Testing Training Executable" >> $GITHUB_STEP_SUMMARY
echo "### Testing Training Executable" >> $GITHUB_STEP_SUMMARY

if [ -f "quadtrix_train" ] || [ -f "quadtrix_train.exe" ]; then
BINARY="quadtrix_train"
if [ ! -f "$BINARY" ]; then
BINARY="quadtrix_train.exe"
fi
BINARY="quadtrix_train"
if [ -f "quadtrix_train.exe" ]; then
BINARY="quadtrix_train.exe"
fi

if [ -f "$BINARY" ]; then
echo "Running training executable (timeout 30s)..." >> $GITHUB_STEP_SUMMARY
timeout 30 ./$BINARY 2>&1 | tee training_test.txt || true
echo "Training test completed" >> $GITHUB_STEP_SUMMARY
Expand All @@ -289,7 +307,7 @@ jobs:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
Expand All @@ -300,7 +318,7 @@ jobs:
pip install pytest pytest-cov

if [ -f "requirements.txt" ]; then
pip install -r requirements.txt 2>/dev/null || echo " Some requirements failed to install"
pip install -r requirements.txt 2>/dev/null || echo "Some requirements failed to install"
fi

- name: Run Python tests
Expand All @@ -313,11 +331,11 @@ jobs:
if [ $? -eq 0 ]; then
echo "All tests passed" >> $GITHUB_STEP_SUMMARY
else
echo " Some tests failed" >> $GITHUB_STEP_SUMMARY
echo "Some tests failed" >> $GITHUB_STEP_SUMMARY
fi
tail -30 pytest_output.txt >> $GITHUB_STEP_SUMMARY
else
echo " No test files found" >> $GITHUB_STEP_SUMMARY
echo "No test files found" >> $GITHUB_STEP_SUMMARY
fi
continue-on-error: true

Expand Down
Loading
Loading