Skip to content
Merged
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
27 changes: 27 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
build_type: [Release, Debug]

steps:
- uses: actions/checkout@v3

- name: Configure CMake
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: cmake --build build --config ${{ matrix.build_type }}

- name: Run tests
run: cd build && ctest -C ${{ matrix.build_type }} --output-on-failure
38 changes: 38 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Code Formatting

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
format:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v5

# Install clang-format if needed
- name: Install clang-format (Linux)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y clang-format

- name: Install clang-format (macOS)
if: matrix.os == 'macos-latest'
run: brew install clang-format || true

# Check formatting
- name: Check C/C++ formatting
run: |
misformatted=$(find . -name '*.c' -o -name '*.h' -print0 | xargs -0 clang-format -style=file -output-replacements-xml | grep "<replacement " || true)
if [ -n "$misformatted" ]; then
echo "ERROR: Some files are not properly formatted. Run clang-format -i."
exit 1
else
echo "All files are properly formatted."
exit 0
fi
33 changes: 33 additions & 0 deletions .github/workflows/sanitizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: ASan+UBSan

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v5

# Configure CMake with ASan + UBSan
- name: Configure with sanitizers
run: cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g" \
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g" \
-DBUILD_TESTING=ON

# Build
- name: Build
run: cmake --build build --config Debug

# Run tests
- name: Run tests under ASan+UBSan
run: cd build && ctest --output-on-failure
26 changes: 26 additions & 0 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Valgrind

on: [push, pull_request]

jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y valgrind

- name: Configure Debug build
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON

- name: Build
run: cmake --build build --config Debug

- name: Run tests under Valgrind
run: |
valgrind --leak-check=full --show-leak-kinds=all \
--track-origins=yes --show-reachable=yes \
--error-exitcode=1 build/bin/all_tests
6 changes: 3 additions & 3 deletions src/explorers/DtonsEq.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ static inline void modify_bounds(Constraints *constraints, int i, double aij,
#ifndef TESTING
static inline
#endif
Old_and_new_coeff update_row_A_dton(Matrix *A, int i, int q, int j, int k,
double aij, double aik, int *row_size,
PostsolveInfo *postsolve_info)
Old_and_new_coeff
update_row_A_dton(Matrix *A, int i, int q, int j, int k, double aij, double aik,
int *row_size, PostsolveInfo *postsolve_info)
{
int ii, start, end, insertion;
double old_val = 0.0;
Expand Down
7 changes: 4 additions & 3 deletions src/explorers/Parallel_rows.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ static inline uint32_t hash_double_array_with_scale(const double *arr, int size)
#ifndef TESTING
static inline
#endif
void compute_supp_and_coeff_hash(const Matrix *A, const RowTag *rowtags,
int *sparsity_IDs, int *coeff_hashes,
RowTag INACTIVE_TAG)
void
compute_supp_and_coeff_hash(const Matrix *A, const RowTag *rowtags,
int *sparsity_IDs, int *coeff_hashes,
RowTag INACTIVE_TAG)
{

for (int i = 0; i < A->m; i++)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_Constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static char *test_2_constraints()
constraints_new(A, AT, lhs, rhs, bounds, data, row_tags, col_tags);

// remove rows 1, 3, 5
iVec_append_array(data->rows_to_delete, (int[]) {1, 3, 5}, 3);
iVec_append_array(data->rows_to_delete, (int[]){1, 3, 5}, 3);
delete_inactive_rows(constraints);

// test for correctness
Expand Down Expand Up @@ -286,7 +286,7 @@ static char *test_4_constraints()
constraints_new(A, AT, lhs, rhs, bounds, data, row_tags, col_tags);

// remove cols 1, 3, 5
iVec_append_array(data->fixed_cols_to_delete, (int[]) {1, 3, 5}, 3);
iVec_append_array(data->fixed_cols_to_delete, (int[]){1, 3, 5}, 3);
delete_inactive_cols_from_A_and_AT(constraints);

// test for correctness
Expand Down