Skip to content
Draft
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
145 changes: 145 additions & 0 deletions .github/workflows/build-test-cpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Build & Test (CPU only)

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:

jobs:
build-test-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout hws
uses: actions/checkout@v4.2.0

- name: Install dependencies
run: |
sudo apt update
sudo apt-get install -y \
gcc \
g++ \
python3 \
python3-dev \
python3-pip \
libfmt-dev

- name: Install pytest
run: |
python3 -m pip install pytest numpy matplotlib

- name: Configure CMake
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug \
-DHWS_ENABLE_CPU_SAMPLING=ON \
-DHWS_ENABLE_GPU_NVIDIA_SAMPLING=OFF \
-DHWS_ENABLE_GPU_AMD_SAMPLING=OFF \
-DHWS_ENABLE_GPU_INTEL_SAMPLING=OFF \
-DHWS_ENABLE_PYTHON_BINDINGS=ON \
-DHWS_ENABLE_ERROR_CHECKS=OFF \
..

- name: Build
run: |
cd build
cmake --build .

- name: Run Python tests
run: |
cd build
python3 -m pytest ../bindings/tests/ 2>/dev/null || echo "No tests found"
python3 -c "import sys; sys.path.insert(0, '.'); import HardwareSampling" || echo "Python bindings test skipped"

- name: Run example
run: |
cd build
ctest -R example_cpp --output-on-failure


build-test-macos:
runs-on: macos-latest
steps:
- name: Checkout hws
uses: actions/checkout@v4.2.0

- name: Install dependencies
run: |
brew install fmt pybind11 python

- name: Install pytest
run: |
python3 -m pip install pytest numpy matplotlib

- name: Configure CMake
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug \
-DHWS_ENABLE_CPU_SAMPLING=ON \
-DHWS_ENABLE_GPU_NVIDIA_SAMPLING=OFF \
-DHWS_ENABLE_GPU_AMD_SAMPLING=OFF \
-DHWS_ENABLE_GPU_INTEL_SAMPLING=OFF \
-DHWS_ENABLE_PYTHON_BINDINGS=ON \
-DHWS_ENABLE_ERROR_CHECKS=OFF \
..

- name: Build
run: |
cd build
cmake --build .

- name: Run example
run: |
cd build
ctest -R example_cpp --output-on-failure


build-test-windows:
runs-on: windows-latest
steps:
- name: Checkout hws
uses: actions/checkout@v4.2.0

- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install cmake
choco install fmt -y

- name: Install pytest
run: |
python -m pip install pytest numpy matplotlib

- name: Configure CMake
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug `
-DHWS_ENABLE_CPU_SAMPLING=OFF `
-DHWS_ENABLE_GPU_NVIDIA_SAMPLING=OFF `
-DHWS_ENABLE_GPU_AMD_SAMPLING=OFF `
-DHWS_ENABLE_GPU_INTEL_SAMPLING=OFF `
-DHWS_ENABLE_PYTHON_BINDINGS=ON `
-DHWS_ENABLE_ERROR_CHECKS=OFF `
..

- name: Build
run: |
cd build
cmake --build . --config Debug

- name: Run example
run: |
cd build
ctest -R example_cpp --output-on-failure --build-config Debug
59 changes: 59 additions & 0 deletions .github/workflows/cmake-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CMake Configuration Matrix

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:

jobs:
cmake-matrix:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build-type: [Debug, Release]
python-version: [3.12]

steps:
- name: Checkout hws
uses: actions/checkout@v4.2.0

- name: Install dependencies
run: |
sudo apt update
sudo apt-get install -y libfmt-dev python3 python3-dev

- name: Configure CMake
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DHWS_ENABLE_CPU_SAMPLING=ON \
-DHWS_ENABLE_GPU_NVIDIA_SAMPLING=OFF \
-DHWS_ENABLE_GPU_AMD_SAMPLING=OFF \
-DHWS_ENABLE_GPU_INTEL_SAMPLING=OFF \
-DHWS_ENABLE_PYTHON_BINDINGS=ON \
-DHWS_ENABLE_ERROR_CHECKS=OFF \
-DHWS_SAMPLING_INTERVAL=100ms \
..

- name: Build
run: |
cd build
cmake --build .

- name: Test build
run: |
cd build
ctest -j$(nproc) --output-on-failure || true

- name: Run example
run: |
cd build
ctest -R example_cpp --output-on-failure || true
65 changes: 65 additions & 0 deletions .github/workflows/fuzzing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Fuzzing

on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch:

jobs:
fuzzing:
runs-on: ubuntu-latest
steps:
- name: Checkout hws
uses: actions/checkout@v4.2.0

- name: Set up Clang
run: |
sudo apt update
sudo apt-get install -y clang-16 llvm

- name: Configure CMake with Fuzzing
run: |
mkdir build
cd build
export CXX=clang++-16
export CC=clang-16
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-fsanitize=fuzzer-no-link" \
-DHWS_ENABLE_CPU_SAMPLING=ON \
-DHWS_ENABLE_GPU_NVIDIA_SAMPLING=OFF \
-DHWS_ENABLE_GPU_AMD_SAMPLING=OFF \
-DHWS_ENABLE_GPU_INTEL_SAMPLING=OFF \
-DHWS_ENABLE_PYTHON_BINDINGS=OFF \
..

- name: Build fuzzer
run: |
cd build
export CXX=clang++-16
export CC=clang-16
clang++-16 -fsanitize=fuzzer \
-DI_HWS_SOURCES \
-I../include \
-I../src \
-c ../src/hws/hardware_sampler.cpp \
-o hw_sampler_fuzz.o

clang++-16 -fsanitize=fuzzer \
-DI_HWS_SOURCES \
-I../include \
-I../src \
-c ../src/hws/system_hardware_sampler.cpp \
-o system_fuzz.o

clang++-16 \
hw_sampler_fuzz.o system_fuzz.o \
-o hws_fuzzer \
-L. -lhws \
-lfmt

- name: Run fuzzer
run: |
cd build
mkdir -p fuzz_corpus
echo "test" > fuzz_corpus/input
timeout 60s ./hws_fuzzer fuzz_corpus || true
69 changes: 69 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Python Tests

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
python-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout hws
uses: actions/checkout@v4.2.0

- name: Install dependencies
run: |
sudo apt update
sudo apt-get install -y \
python3 \
python3-dev \
python3-pip \
libfmt-dev \
libelf-dev \
libdwarf-dev

- name: Install Python packages
run: |
python3 -m pip install --upgrade pip
python3 -m pip install pytest numpy matplotlib pytest-cov

- name: Configure CMake
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug \
-DHWS_ENABLE_CPU_SAMPLING=ON \
-DHWS_ENABLE_GPU_NVIDIA_SAMPLING=OFF \
-DHWS_ENABLE_GPU_AMD_SAMPLING=OFF \
-DHWS_ENABLE_GPU_INTEL_SAMPLING=OFF \
-DHWS_ENABLE_PYTHON_BINDINGS=ON \
-DHWS_ENABLE_ERROR_CHECKS=OFF \
..

- name: Build
run: |
cd build
cmake --build .

- name: Test Python bindings
run: |
cd build
export PYTHONPATH=$(pwd):$PYTHONPATH
python3 -c "
import HardwareSampling as hws
print('Import successful')
print('HardwareSampling version:', hws.__version__)
" || echo "Python bindings test skipped"

- name: Run example scripts
run: |
cd build
export PYTHONPATH=$(pwd):$PYTHONPATH
python3 ../examples/python/main.py || true
47 changes: 47 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Static Analysis

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:

jobs:
cppcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout hws
uses: actions/checkout@v4.2.0

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

- name: Run cppcheck
run: |
cppcheck --enable=all \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--check-config \
--std=c++17 \
--platform=unix64 \
--inconclusive \
-i build \
-i cmake-build-* \
src \
include \
bindings \
examples

- name: Upload report
if: failure()
uses: actions/upload-artifact@v4.3.1
with:
name: cppcheck-report
path: cppcheck.log
Loading
Loading