Skip to content
Open
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
120 changes: 120 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
# Clang-format configuration for Liquid Engine Flight Software
# Based on Google C++ style with aerospace-specific customizations

Language: Cpp
BasedOnStyle: Google

# Indentation
IndentWidth: 4
TabWidth: 4
UseTab: Never
ContinuationIndentWidth: 4

# Line length
ColumnLimit: 100

# Braces
BreakBeforeBraces: Attach
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false

# Spacing
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: true
AlignTrailingComments: true

# Includes
IncludeBlocks: Regroup
SortIncludes: true
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3

# Function formatting
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortBlocksOnASingleLine: false

# Pointer alignment
PointerAlignment: Left

# Reference alignment
ReferenceAlignment: Left

# Penalties for breaking
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200

# Line breaking
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true

# Namespace formatting
NamespaceIndentation: None
FixNamespaceComments: true

# Keep format for specific constructs
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1

# Constructor initializers
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4

# Access modifiers
AccessModifierOffset: -4

# Comment formatting
ReflowComments: true

# Macro formatting
IndentPPDirectives: None

# Lambda formatting
AllowShortLambdasOnASingleLine: None

# Template formatting
AlwaysBreakTemplateDeclarations: Yes
147 changes: 147 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: CI/CD Pipeline

on:
push:
branches: [ main, develop, Test_Branch ]
pull_request:
branches: [ main, develop ]

jobs:
build-and-test:
runs-on: ubuntu-latest

strategy:
matrix:
build-type: [Debug, Release]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
cmake \
libeigen3-dev \
clang-format \
pkg-config \
valgrind \
cppcheck

- name: Install optional dependencies
run: |
# Try to install libcanard-dev, but don't fail if not available
sudo apt-get install -y libcanard-dev || echo "libcanard-dev not available, continuing without CAN bus support"

- name: Create build directory
run: mkdir build

- name: Configure CMake
run: |
cd build
echo "Configuring CMake for ${{ matrix.build-type }} build..."
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} ..
echo "CMake configuration completed successfully"

- name: Build project
run: |
cd build
make -j$(nproc)

- name: Run static analysis
run: |
cppcheck --enable=all --inconclusive --std=c++17 \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--suppress=noExplicitConstructor \
FSW/ comms/ utl/ || true

- name: Check code formatting
run: |
./format.sh --check

- name: Run tests (if available)
run: |
cd build
if [ -f "engine_controller" ]; then
# Add your test commands here when tests are implemented
echo "Tests would run here"
fi

- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: matrix.build-type == 'Release'
with:
name: engine-controller-${{ matrix.build-type }}
path: build/engine_controller

code-quality:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install clang-format
run: sudo apt-get update && sudo apt-get install -y clang-format

- name: Check formatting
run: |
echo "Checking code formatting..."
if ./format.sh --check; then
echo "✅ All files are properly formatted"
else
echo "❌ Formatting issues found - run './format.sh' to fix"
echo "This is a warning, not a failure - code will still build"
fi

- name: Check for TODO/FIXME comments
run: |
echo "Checking for TODO/FIXME/HACK comments..."
if grep -r "TODO\|FIXME\|HACK" --include="*.cpp" --include="*.hpp" FSW/ comms/ utl/; then
echo "Warning: Found TODO/FIXME/HACK comments in code - consider addressing before release"
else
echo "No TODO/FIXME/HACK comments found"
fi

security-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Python and pip
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip

- name: Install security tools
run: |
# Install semgrep via pip (more reliable than apt)
pip3 install --user semgrep
# Add to PATH
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Run security scan
run: |
# Scan for common security issues in C++ code
if command -v semgrep &> /dev/null; then
echo "Running semgrep security scan..."
semgrep --config=auto --exclude="external/" --exclude="build/" . || echo "Semgrep found potential issues (non-fatal)"
else
echo "Semgrep not available, skipping security scan"
fi

# Basic security checks for C++ code
echo "Running basic security checks..."

# Check for hardcoded secrets/keys
if grep -r -i "password\|secret\|key\|token" --include="*.cpp" --include="*.hpp" FSW/ comms/ utl/ | grep -v "// TODO\|// FIXME"; then
echo "Warning: Potential hardcoded secrets found"
fi

# Check for dangerous functions
if grep -r -E "strcpy|sprintf|gets|scanf" --include="*.cpp" --include="*.hpp" FSW/ comms/ utl/; then
echo "Warning: Potentially unsafe C functions found"
fi
Loading
Loading