forked from organicmaps/organicmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Andrew Shkrob <[email protected]>
- Loading branch information
1 parent
401a3a8
commit 2d5d680
Showing
8 changed files
with
266 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
name: Coverage Report | ||
on: | ||
workflow_dispatch: # Manual trigger | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- labeled | ||
- unlabeled | ||
|
||
# Cancels previous jobs if the same branch or PR was updated again. | ||
concurrency: | ||
group: ${{ github.workflow }}-coverage-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
should-run-check: | ||
name: Should run coverage | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
run-from-pr: ${{ steps.run-from-pr.outputs.run-from-pr }} | ||
manually-triggered: ${{ steps.manually-triggered.outputs.manually-triggered }} | ||
steps: | ||
- name: Check if PR has 'Coverage' label | ||
id: run-from-pr | ||
if: github.event_name == 'pull_request' | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
LABEL_NAME="Coverage" | ||
LABELS=$(gh pr view https://github.com/$GITHUB_REPOSITORY/pull/$PR_NUMBER --json labels) | ||
if echo "$LABELS" | jq -e '.labels[].name' | grep -q "$LABEL_NAME"; then | ||
echo "run-from-pr=true" >> $GITHUB_OUTPUT | ||
echo "'Coverage' label found in PR." | ||
fi | ||
- name: Check if manually triggered | ||
id: manually-triggered | ||
if: github.event_name == 'workflow_dispatch' | ||
run: echo "manually-triggered=true" >> $GITHUB_OUTPUT | ||
|
||
coverage: | ||
needs: should-run-check | ||
name: Generate coverage report | ||
runs-on: ubuntu-22.04 | ||
if: ${{ needs.should-run-check.outputs.run-from-pr == 'true' || needs.should-run-check.outputs.manually-triggered == 'true'}} | ||
steps: | ||
- name: Free disk space by removing .NET, Android and Haskell | ||
shell: bash | ||
run: | | ||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 100 # enough to get all commits for the current day | ||
|
||
- name: Parallel submodules checkout | ||
shell: bash | ||
run: git submodule update --depth 1 --init --recursive --jobs=$(($(nproc) * 20)) | ||
|
||
- name: Install build tools and dependencies | ||
shell: bash | ||
run: | | ||
sudo apt update -y | ||
sudo apt install -y \ | ||
ninja-build \ | ||
libgl1-mesa-dev \ | ||
libglvnd-dev \ | ||
qt6-base-dev \ | ||
libqt6svg6-dev \ | ||
qt6-positioning-dev \ | ||
libqt6positioning6-plugins \ | ||
libqt6positioning6 \ | ||
llvm | ||
pip install gcovr | ||
- name: Configure | ||
shell: bash | ||
run: ./configure.sh | ||
|
||
- name: Configure ccache | ||
uses: hendrikmuhs/[email protected] | ||
with: | ||
key: ${{ github.workflow }}-coverage | ||
|
||
- name: CMake | ||
shell: bash | ||
env: | ||
CC: clang-14 | ||
CXX: clang++-14 | ||
CMAKE_C_COMPILER_LAUNCHER: ccache | ||
CMAKE_CXX_COMPILER_LAUNCHER: ccache | ||
# -g1 should slightly reduce build time. | ||
run: | | ||
cmake . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug \ | ||
-DCMAKE_CXX_FLAGS=-g1 -DCOVERAGE_REPORT=ON | ||
- name: Compile | ||
shell: bash | ||
working-directory: build | ||
run: ninja | ||
|
||
- name: Tests | ||
shell: bash | ||
working-directory: build | ||
env: | ||
# drape_tests - requires X Window | ||
# generator_integration_tests - https://github.com/organicmaps/organicmaps/issues/225 | ||
# opening_hours_integration_tests - https://github.com/organicmaps/organicmaps/issues/219 | ||
# opening_hours_supported_features_tests - https://github.com/organicmaps/organicmaps/issues/219 | ||
# routing_integration_tests - https://github.com/organicmaps/organicmaps/issues/221 | ||
# shaders_tests - https://github.com/organicmaps/organicmaps/issues/223 | ||
# world_feed_integration_tests - https://github.com/organicmaps/organicmaps/issues/215 | ||
CTEST_EXCLUDE_REGEX: "drape_tests|generator_integration_tests|opening_hours_integration_tests|opening_hours_supported_features_tests|routing_benchmarks|routing_integration_tests|routing_quality_tests|search_quality_tests|storage_integration_tests|shaders_tests|world_feed_integration_tests" | ||
run: | | ||
sudo locale-gen en_US | ||
sudo locale-gen en_US.UTF-8 | ||
sudo locale-gen es_ES | ||
sudo locale-gen es_ES.UTF-8 | ||
sudo locale-gen fr_FR | ||
sudo locale-gen fr_FR.UTF-8 | ||
sudo locale-gen ru_RU | ||
sudo locale-gen ru_RU.UTF-8 | ||
sudo update-locale | ||
ln -s ../data data | ||
ctest -L "omim-test" -E "$CTEST_EXCLUDE_REGEX" --output-on-failure | ||
- name: Run coverage report generation | ||
shell: bash | ||
working-directory: build | ||
run: | | ||
cmake --build . --target omim_coverage | ||
cat coverage_report/summary.txt | ||
- name: Archive the coverage report | ||
working-directory: build/coverage_report | ||
run: zip -r coverage_report.zip html/ | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: coverage-report | ||
path: build/coverage_report/coverage_report.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
add_compile_options(-O0 --coverage) | ||
add_link_options(--coverage) | ||
|
||
set(COVERAGE_REPORT_DIR ${CMAKE_BINARY_DIR}/coverage_report) | ||
|
||
find_program(GCOVR_EXECUTABLE_PATH gcovr) | ||
if (NOT GCOVR_EXECUTABLE_PATH) | ||
message(FATAL_ERROR "'gcovr' is required to generate test coverage report. Details: gcovr.com.") | ||
endif () | ||
|
||
if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU|AppleClang") | ||
set(GCOV_EXECUTABLE "gcov") | ||
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") | ||
set(GCOV_EXECUTABLE "llvm-cov") | ||
endif () | ||
|
||
find_program(GCOV_EXECUTABLE_PATH ${GCOV_EXECUTABLE}) | ||
if (NOT GCOV_EXECUTABLE_PATH) | ||
message(FATAL_ERROR "'${GCOV_EXECUTABLE}' is required to generate test coverage report.") | ||
endif () | ||
|
||
if (${GCOV_EXECUTABLE_PATH} MATCHES "llvm-cov") | ||
set(GCOV_EXECUTABLE_PATH "${GCOV_EXECUTABLE_PATH} gcov") | ||
endif () | ||
|
||
add_custom_target(omim_coverage | ||
# Remove harfbuzz.cc.* files because they reference .rl files that do not exist and cannot be excluded by gcovr. | ||
COMMAND rm -f ${CMAKE_BINARY_DIR}/3party/harfbuzz/CMakeFiles/harfbuzz.dir/harfbuzz/src/harfbuzz.cc.* | ||
# Recreate coverage_report folder | ||
COMMAND rm -rf ${COVERAGE_REPORT_DIR} && mkdir ${COVERAGE_REPORT_DIR} | ||
# Run gcovr | ||
COMMAND ${GCOVR_EXECUTABLE_PATH} | ||
--config=${OMIM_ROOT}/gcovr.cfg | ||
--root=${OMIM_ROOT} | ||
--object-directory=${CMAKE_BINARY_DIR} | ||
--exclude=${CMAKE_BINARY_DIR} # Exclude autogenerated files from Qt and some 3party libraries. | ||
--gcov-executable=${GCOV_EXECUTABLE_PATH} | ||
--html-nested=${COVERAGE_REPORT_DIR}/html/ >> ${COVERAGE_REPORT_DIR}/summary.txt | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
COMMENT "Generating coverage report..." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# gcovr configuration file | ||
# Details: https://gcovr.com/en/master/manpage.html | ||
|
||
# Exclude all subfolders of "3party/" except for "opening_hours" | ||
exclude = ^3party\/(?!opening_hours($|\/)).* | ||
# Exclude testing folders | ||
exclude = testing/ | ||
exclude = qt_tstfrm/ | ||
# Exclude all "*tests*" subfolders | ||
exclude = .*tests.* | ||
|
||
exclude-unreachable-branches = yes | ||
exclude-throw-branches = yes | ||
|
||
print-summary = yes | ||
|
||
gcov-parallel = 20 | ||
gcov-ignore-errors = all | ||
gcov-ignore-parse-errors = all | ||
|
||
html-title = Organic Maps Code Coverage Report | ||
html-self-contained = yes |