|
24 | 24 |
|
25 | 25 | - name: Run tests |
26 | 26 | run: cd build && ctest --output-on-failure |
| 27 | + |
| 28 | + test-case-coverage: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Install dependencies |
| 35 | + run: sudo apt-get update && sudo apt-get install -y cmake gcc lcov |
| 36 | + |
| 37 | + - name: Configure CMake (with coverage flags) |
| 38 | + run: | |
| 39 | + cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="--coverage" -DCMAKE_EXE_LINKER_FLAGS="--coverage" |
| 40 | +
|
| 41 | + - name: Build |
| 42 | + run: cmake --build build |
| 43 | + |
| 44 | + - name: Run tests |
| 45 | + run: | |
| 46 | + cd build && ctest --output-on-failure |
| 47 | +
|
| 48 | + - name: Generate coverage report |
| 49 | + run: | |
| 50 | + lcov --capture --directory build --output-file coverage.info |
| 51 | + lcov --remove coverage.info '*/Unity/*' '*/cJSON/*' --output-file coverage.info |
| 52 | + lcov --list coverage.info |
| 53 | + genhtml coverage.info --output-directory out |
| 54 | +
|
| 55 | + - name: Upload coverage artifact |
| 56 | + uses: actions/upload-artifact@v4 |
| 57 | + with: |
| 58 | + name: coverage-report-html |
| 59 | + path: out |
| 60 | + |
| 61 | + memory-check: |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - name: Checkout code |
| 65 | + uses: actions/checkout@v4 |
| 66 | + |
| 67 | + - name: Install dependencies |
| 68 | + run: sudo apt-get update && sudo apt-get install -y cmake gcc valgrind |
| 69 | + |
| 70 | + - name: Configure CMake |
| 71 | + run: cmake -S . -B build |
| 72 | + |
| 73 | + - name: Build |
| 74 | + run: cmake --build build |
| 75 | + |
| 76 | + - name: Run tests with valgrind |
| 77 | + run: | |
| 78 | + cd output |
| 79 | + for t in mjsonrpc-example-*; do |
| 80 | + echo "Running valgrind on $t" |
| 81 | + valgrind --leak-check=full --error-exitcode=1 ./$t || exit 1 |
| 82 | + done |
0 commit comments