-
Notifications
You must be signed in to change notification settings - Fork 51
61 lines (53 loc) · 2.32 KB
/
ci.yml
File metadata and controls
61 lines (53 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: CI
on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Install tools
run: sudo apt-get update && sudo apt-get install -y lcov g++ qt5-qmake qtbase5-dev qtchooser 2>/dev/null || true
- name: Build
run: |
PRO_FILE=$(find . -maxdepth 2 -name "*.pro" | head -1)
if [ -n "$PRO_FILE" ]; then
echo "Building with qmake: $PRO_FILE"
qmake "$PRO_FILE" "QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage" "QMAKE_LFLAGS += -fprofile-arcs -ftest-coverage" && make -j$(nproc) || true
elif [ -f CMakeLists.txt ]; then
echo "Building with CMake"
cmake -B build -DCMAKE_CXX_FLAGS="--coverage" && cmake --build build || true
elif [ -f Makefile ]; then
echo "Building with Makefile"
make || true
else
echo "Compiling C++ files directly"
find . -name "*.cpp" -not -path "./build/*" | head -20 | xargs g++ -fprofile-arcs -ftest-coverage -o /dev/null 2>&1 || true
fi
- name: Run tests
run: make check 2>/dev/null || ctest 2>/dev/null || true
- name: Coverage report
if: always()
run: |
lcov --capture --directory . --output-file coverage.info --ignore-errors source 2>/dev/null || true
if [ -f coverage.info ] && [ -s coverage.info ]; then
lcov --remove coverage.info '/usr/*' '*/moc_*' '*/ui_*' --output-file coverage.info 2>/dev/null || true
echo "## Test Coverage Report" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
lcov --summary coverage.info 2>&1 | grep -E "lines|functions" >> $GITHUB_STEP_SUMMARY || echo "No data" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
else
echo "## Code Inventory" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "C++ files: $(find . -name '*.cpp' -o -name '*.h' | wc -l)" >> $GITHUB_STEP_SUMMARY
find . -name '*.cpp' -o -name '*.h' | xargs wc -l 2>/dev/null | tail -1 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi