Skip to content

Commit 2bcd56e

Browse files
committed
CI: put linting and coverage into separate workflow
1 parent e2412f1 commit 2bcd56e

2 files changed

Lines changed: 161 additions & 153 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -4,80 +4,9 @@ name: CI
44
on: [push, pull_request]
55

66
jobs:
7-
8-
lint:
9-
runs-on: ubuntu-24.04
10-
strategy:
11-
fail-fast: false
12-
env:
13-
BUILD_TYPE: Release
14-
CMAKE_FLAGS: >
15-
-DSPIRIT_UI_USE_IMGUI=ON
16-
-DSPIRIT_UI_CXX_USE_QT=OFF
17-
-DSPIRIT_ENABLE_PINNING=ON
18-
-DSPIRIT_ENABLE_DEFECTS=ON
19-
SOURCES: >
20-
find
21-
core/include/
22-
core/src/
23-
ui-cpp/utility/
24-
ui-cpp/ui-imgui/include/
25-
ui-cpp/ui-imgui/src/
26-
-iname *.hpp -o -iname *.cpp"
27-
28-
steps:
29-
- uses: actions/checkout@v4
30-
31-
- name: 📚 Install required system packages
32-
run: |
33-
sudo apt-get update
34-
sudo apt-get install -y xorg-dev libglu1-mesa-dev libgtk-3-dev tree
35-
36-
- uses: actions/setup-python@v5
37-
with:
38-
python-version: '3.10'
39-
40-
- name: 📚 Install python packages
41-
run: >
42-
pip install --user numpy pylint
43-
"black==22.10.0"
44-
"clang-format==18.1.8"
45-
"clang-tidy==18.1.8"
46-
47-
- name: 📁 Create build folder
48-
run: cmake -E make_directory ${{runner.workspace}}/build
49-
50-
- name: ⚙ Configure
51-
shell: bash
52-
working-directory: ${{runner.workspace}}/build
53-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CMAKE_FLAGS
54-
55-
- name: 🧪 clang-format linting
56-
if: always()
57-
shell: bash
58-
run: |
59-
clang-format --version
60-
OUTPUT=$($SOURCES | xargs clang-format -n 2>&1)
61-
if [[ $OUTPUT ]]; then
62-
echo "$OUTPUT"
63-
exit 1
64-
fi
65-
66-
- name: 🧪 clang-tidy linting
67-
if: always()
68-
shell: bash
69-
run: |
70-
clang-tidy --version
71-
72-
- name: 🧪 Python code formatting check
73-
shell: bash
74-
run: |
75-
git ls-files core/python/{,**/}*.py | xargs black --check
76-
git ls-files ui-python/{,**/}*.py | xargs black --check
77-
78-
- name: 🧪 Python code quality checks, linting
79-
shell: bash
80-
run: pylint core/python/spirit --fail-under=8
7+
call-quality:
8+
uses: ./.github/workflows/quality.yml
9+
secrets: inherit
8110

8211
test-gcc:
8312
name: gcc ${{ matrix.parallelisation }} (${{ matrix.os }})
@@ -459,85 +388,6 @@ jobs:
459388
working-directory: ${{runner.workspace}}/build
460389
run: ctest -C $BUILD_TYPE -E $EXCLUDETESTS --output-on-failure
461390

462-
test-coverage:
463-
name: test coverage (${{ matrix.os }})
464-
runs-on: ${{ matrix.os }}
465-
strategy:
466-
fail-fast: false
467-
matrix:
468-
include:
469-
- os: ubuntu-22.04
470-
env:
471-
BUILD_TYPE: Debug
472-
CMAKE_FLAGS: >
473-
-DSPIRIT_UI_USE_IMGUI=OFF
474-
-DSPIRIT_UI_CXX_USE_QT=OFF
475-
-DSPIRIT_BUILD_TEST=ON
476-
steps:
477-
- uses: actions/checkout@v4
478-
479-
- uses: actions/setup-python@v5
480-
with:
481-
python-version: '3.x'
482-
483-
- name: 📚 Install python packages
484-
run: pip install --user numpy
485-
486-
- name: 📚 Install coverage packages
487-
run: |
488-
python -m pip install --upgrade pip
489-
python -m pip install coverage 'coveralls<3'
490-
sudo apt-get update
491-
sudo apt-get install -y lcov
492-
493-
- name: 📁 Create build folder
494-
run: cmake -E make_directory ${{runner.workspace}}/build
495-
496-
- name: ⚙ Configure (with coverage)
497-
shell: bash
498-
working-directory: ${{runner.workspace}}/build
499-
run: >
500-
cmake $GITHUB_WORKSPACE
501-
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
502-
-DSPIRIT_TEST_COVERAGE=ON
503-
$CMAKE_FLAGS
504-
505-
- name: 🛠 Build
506-
shell: bash
507-
working-directory: ${{runner.workspace}}/build
508-
run: cmake --build . --config $BUILD_TYPE -j 2
509-
510-
- name: 🧪 Generate C++ coverage
511-
shell: bash
512-
working-directory: ${{runner.workspace}}/build
513-
run: |
514-
lcov -c -i --no-external --directory . --base-directory $GITHUB_WORKSPACE/core -o baseline.info
515-
make test
516-
lcov -c --no-external --directory . --base-directory $GITHUB_WORKSPACE/core -o after_test.info
517-
lcov -a baseline.info -a after_test.info -o total_test.info
518-
lcov -r total_test.info \*thirdparty\* \*/test/\* \*Collection\* \*DLL_\* -o coverage.info
519-
520-
- name: ⬆ Upload C++ coverage
521-
uses: codecov/codecov-action@v3
522-
with:
523-
files: ${{runner.workspace}}/build/coverage.info
524-
525-
- name: 🧪 Generate Python API coverage
526-
if: matrix.coverage == true
527-
working-directory: ./core/python
528-
env:
529-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
530-
run: |
531-
coverage run --source spirit --omit=spirit/spiritlib.py \
532-
-m unittest discover \
533-
--start-directory ./test \
534-
--pattern "*.py" \
535-
> cov.txt
536-
head cov.txt
537-
coverage report -m
538-
coverage xml
539-
coveralls
540-
541391
test-other-configurations:
542392
name: test ${{ matrix.configuration }} (${{ matrix.os }})
543393
runs-on: ${{ matrix.os }}

.github/workflows/quality.yml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
name: Code Quality
3+
4+
on: workflow_call
5+
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-24.04
9+
strategy:
10+
fail-fast: false
11+
env:
12+
BUILD_TYPE: Release
13+
CMAKE_FLAGS: >
14+
-DSPIRIT_UI_USE_IMGUI=ON
15+
-DSPIRIT_UI_CXX_USE_QT=OFF
16+
-DSPIRIT_ENABLE_PINNING=ON
17+
-DSPIRIT_ENABLE_DEFECTS=ON
18+
SOURCES: >
19+
find
20+
core/include/
21+
core/src/
22+
ui-cpp/utility/
23+
ui-cpp/ui-imgui/include/
24+
ui-cpp/ui-imgui/src/
25+
-iname *.hpp -o -iname *.cpp"
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Install required system packages
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y xorg-dev libglu1-mesa-dev libgtk-3-dev tree
34+
35+
- uses: actions/setup-python@v5
36+
with:
37+
python-version: '3.10'
38+
39+
- name: Install python packages
40+
run: >
41+
pip install --user numpy pylint
42+
"black==22.10.0"
43+
"clang-format==18.1.8"
44+
"clang-tidy==18.1.8"
45+
46+
- name: Create build folder
47+
run: cmake -E make_directory ${{runner.workspace}}/build
48+
49+
- name: Configure
50+
shell: bash
51+
working-directory: ${{runner.workspace}}/build
52+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CMAKE_FLAGS
53+
54+
- name: clang-format linting
55+
if: always()
56+
shell: bash
57+
run: |
58+
clang-format --version
59+
OUTPUT=$($SOURCES | xargs clang-format -n 2>&1)
60+
if [[ $OUTPUT ]]; then
61+
echo "$OUTPUT"
62+
exit 1
63+
fi
64+
65+
- name: clang-tidy linting
66+
if: always()
67+
shell: bash
68+
run: |
69+
clang-tidy --version
70+
71+
- name: Python code formatting check
72+
shell: bash
73+
run: |
74+
git ls-files core/python/{,**/}*.py | xargs black --check
75+
git ls-files ui-python/{,**/}*.py | xargs black --check
76+
77+
- name: Python code quality checks, linting
78+
shell: bash
79+
run: pylint core/python/spirit --fail-under=8
80+
81+
test-coverage:
82+
name: test coverage (${{ matrix.os }})
83+
runs-on: ${{ matrix.os }}
84+
strategy:
85+
fail-fast: false
86+
matrix:
87+
include:
88+
- os: ubuntu-22.04
89+
env:
90+
BUILD_TYPE: Debug
91+
CMAKE_FLAGS: >
92+
-DSPIRIT_UI_USE_IMGUI=OFF
93+
-DSPIRIT_UI_CXX_USE_QT=OFF
94+
-DSPIRIT_BUILD_TEST=ON
95+
steps:
96+
- uses: actions/checkout@v4
97+
98+
- uses: actions/setup-python@v5
99+
with:
100+
python-version: '3.x'
101+
102+
- name: Install python packages
103+
run: pip install --user numpy
104+
105+
- name: Install coverage packages
106+
run: |
107+
python -m pip install --upgrade pip
108+
python -m pip install coverage 'coveralls<3'
109+
sudo apt-get update
110+
sudo apt-get install -y lcov
111+
112+
- name: Create build folder
113+
run: cmake -E make_directory ${{runner.workspace}}/build
114+
115+
- name: Configure (with coverage)
116+
shell: bash
117+
working-directory: ${{runner.workspace}}/build
118+
run: >
119+
cmake $GITHUB_WORKSPACE
120+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
121+
-DSPIRIT_TEST_COVERAGE=ON
122+
$CMAKE_FLAGS
123+
124+
- name: Build
125+
shell: bash
126+
working-directory: ${{runner.workspace}}/build
127+
run: cmake --build . --config $BUILD_TYPE -j 2
128+
129+
- name: Generate C++ coverage
130+
shell: bash
131+
working-directory: ${{runner.workspace}}/build
132+
run: |
133+
lcov -c -i --no-external --directory . --base-directory $GITHUB_WORKSPACE/core -o baseline.info
134+
make test
135+
lcov -c --no-external --directory . --base-directory $GITHUB_WORKSPACE/core -o after_test.info
136+
lcov -a baseline.info -a after_test.info -o total_test.info
137+
lcov -r total_test.info \*thirdparty\* \*/test/\* \*Collection\* \*DLL_\* -o coverage.info
138+
139+
- name: Upload C++ coverage
140+
uses: codecov/codecov-action@v3
141+
with:
142+
files: ${{runner.workspace}}/build/coverage.info
143+
144+
- name: Generate Python API coverage
145+
if: matrix.coverage == true
146+
working-directory: ./core/python
147+
env:
148+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149+
run: |
150+
coverage run --source spirit --omit=spirit/spiritlib.py \
151+
-m unittest discover \
152+
--start-directory ./test \
153+
--pattern "*.py" \
154+
> cov.txt
155+
head cov.txt
156+
coverage report -m
157+
coverage xml
158+
coveralls

0 commit comments

Comments
 (0)