From bf0001ad41552b0278ad5ba5c0da5875ed6527c8 Mon Sep 17 00:00:00 2001 From: abelbarreira Date: Mon, 21 Apr 2025 12:32:44 +0200 Subject: [PATCH 1/4] feat: activated Unit Testing workflows --- .github/workflows/macos.yml | 44 +++++++++--------- .github/workflows/ubuntu.yml | 86 +++++++++++++++++------------------ .github/workflows/windows.yml | 44 +++++++++--------- cmake/CodeCoverage.cmake | 10 ++-- notes.md | 10 ++++ 5 files changed, 102 insertions(+), 92 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index e344845..a817641 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -1,24 +1,24 @@ -# name: MacOS CI Test +name: MacOS CI Test -# on: -# push: -# branches: [ main, master, dev ] -# pull_request: -# branches: [ main, master, dev ] +on: + push: + branches: [ main, master, dev ] + pull_request: + branches: [ main, master, dev ] -# jobs: -# build: -# runs-on: macos-latest -# steps: -# - uses: actions/checkout@v2 -# - name: prepare -# run: | -# make prepare -# - name: configure -# run: | -# cmake -H. -Bbuild -DCMAKE_BUILD_TYPE="Debug" -# - name: building and testing -# run: | -# cmake --build build --config Debug -# cd build -# ctest . +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: prepare + run: | + make prepare + - name: configure + run: | + cmake -H. -Bbuild -DCMAKE_BUILD_TYPE="Debug" + - name: building and testing + run: | + cmake --build build --config Debug + cd build + ctest . diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 73acc64..d035f68 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -1,45 +1,45 @@ -# name: Ubuntu CI Test +name: Ubuntu CI Test -# on: -# push: -# branches: [ main, master, dev ] -# pull_request: -# branches: [ main, master, dev ] +on: + push: + branches: [ main, master, dev ] + pull_request: + branches: [ main, master, dev ] -# jobs: -# build: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v2 -# - name: install -# run: | -# pip install --user -U gcovr -# - name: prepare -# run: | -# make prepare -# - name: configure -# run: | -# cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=On -# - name: building and testing -# run: | -# cmake --build build --config Debug --target coverage -j4 -# cd build -# ctest . -# - name: Code Coverage Report -# uses: irongut/CodeCoverageSummary@v1.3.0 -# with: -# filename: build/coverage/coverage.cobertura.xml -# badge: true -# fail_below_min: true -# format: markdown -# hide_branch_rate: false -# hide_complexity: true -# indicators: true -# output: both -# thresholds: '60 80' -# - name: Add Coverage PR Comment -# uses: marocchino/sticky-pull-request-comment@v2 -# if: github.event_name == 'pull_request' -# with: -# recreate: true -# path: code-coverage-results.md +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: install + run: | + pip install --user -U gcovr + - name: prepare + run: | + make prepare + - name: configure + run: | + cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=On + - name: building and testing + run: | + cmake --build build --config Debug --target coverage -j4 + cd build + ctest . + - name: Code Coverage Report + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + filename: build/coverage/coverage.cobertura.xml + badge: true + fail_below_min: true + format: markdown + hide_branch_rate: false + hide_complexity: true + indicators: true + output: both + thresholds: '60 80' + - name: Add Coverage PR Comment + uses: marocchino/sticky-pull-request-comment@v2 + if: github.event_name == 'pull_request' + with: + recreate: true + path: code-coverage-results.md diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index a54b9aa..5cce786 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,24 +1,24 @@ -# name: Windows CI Test +name: Windows CI Test -# on: -# push: -# branches: [ main, master, dev ] -# pull_request: -# branches: [ main, master, dev ] +on: + push: + branches: [ main, master, dev ] + pull_request: + branches: [ main, master, dev ] -# jobs: -# build: -# runs-on: windows-latest -# steps: -# - uses: actions/checkout@v2 -# - name: prepare -# run: | -# make prepare -# - name: configure -# run: | -# cmake -H"." -Bbuild -T host=x86 -A x64 -DCMAKE_BUILD_TYPE="Debug" -# - name: building and testing -# run: | -# cmake --build build --config Debug -# cd build -# ctest . +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: prepare + run: | + make prepare + - name: configure + run: | + cmake -H"." -Bbuild -T host=x86 -A x64 -DCMAKE_BUILD_TYPE="Debug" + - name: building and testing + run: | + cmake --build build --config Debug + cd build + ctest . diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 6eac0b4..02cd9d2 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -135,7 +135,7 @@ function(setup_target_for_coverage_gcovr_html) --json-summary --json-summary-pretty --html-theme - blue) + github.dark-green) set(GCOVR_HTML_CMD ${GCOVR_PATH} ${GCOVR_EXTRA_FLAGS} @@ -145,10 +145,10 @@ function(setup_target_for_coverage_gcovr_html) --json-summary ${Coverage_NAME}/summary.json --json-summary-pretty - # --cobertura - # ${Coverage_NAME}/coverage.cobertura.xml - # --cobertura-pretty - # --decisions + --cobertura + ${Coverage_NAME}/coverage.cobertura.xml + --cobertura-pretty + --decisions -r ${BASEDIR} ${GCOVR_ADDITIONAL_ARGS} diff --git a/notes.md b/notes.md index 93bb2db..0537fdf 100644 --- a/notes.md +++ b/notes.md @@ -85,3 +85,13 @@ - [Creating an Example Workflow](https://docs.github.com/en/actions/use-cases-and-examples/creating-an-example-workflow) - [GitHub Actions](https://github.com/actions) for automate your GitHub workflows - [Disable/Enabling workflows](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/disabling-and-enabling-a-workflow?tool=webui) + +- **GitHub Pull Requests**: + - [Git Pull Request](https://www.geeksforgeeks.org/git-pull-request/) + - In GitLab is called Merge Request + +- **GitHub Actions** for Unit Testing and Code Coverage: + - Following workflows: + - [MAC OS](.github/workflows/macos.yml) + - [Ubuntu](.github/workflows/ubuntu.yml) + - [Windows](.github/workflows/windows.yml) From b042b0bea64c895fc8989cbd0c956a051c85a6ac Mon Sep 17 00:00:00 2001 From: abelbarreira Date: Mon, 21 Apr 2025 13:01:14 +0200 Subject: [PATCH 2/4] chore: commented cobertura flag --- cmake/CodeCoverage.cmake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 02cd9d2..90813c8 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -135,7 +135,7 @@ function(setup_target_for_coverage_gcovr_html) --json-summary --json-summary-pretty --html-theme - github.dark-green) + blue) set(GCOVR_HTML_CMD ${GCOVR_PATH} ${GCOVR_EXTRA_FLAGS} @@ -145,16 +145,18 @@ function(setup_target_for_coverage_gcovr_html) --json-summary ${Coverage_NAME}/summary.json --json-summary-pretty - --cobertura - ${Coverage_NAME}/coverage.cobertura.xml - --cobertura-pretty - --decisions + # --cobertura + # ${Coverage_NAME}/coverage.cobertura.xml + # --cobertura-pretty + # --decisions -r ${BASEDIR} ${GCOVR_ADDITIONAL_ARGS} ${GCOVR_EXCLUDE_ARGS} --object-directory=${PROJECT_BINARY_DIR}) + message(STATUS "PROJECT_BINARY_DIR: ${PROJECT_BINARY_DIR}") + add_custom_target( ${Coverage_NAME} COMMAND ${GCOVR_HTML_EXEC_TESTS_CMD} From 1dcfe3e285391b6ea6f777bb58e2dccf3a33e749 Mon Sep 17 00:00:00 2001 From: abelbarreira Date: Mon, 21 Apr 2025 13:08:11 +0200 Subject: [PATCH 3/4] chore: reverted coverage and added ignore errors --- cmake/CodeCoverage.cmake | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 90813c8..ecbb86a 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -135,7 +135,8 @@ function(setup_target_for_coverage_gcovr_html) --json-summary --json-summary-pretty --html-theme - blue) + github.dark-green + --gcov-ignore-errors=no_working_dir_found) set(GCOVR_HTML_CMD ${GCOVR_PATH} ${GCOVR_EXTRA_FLAGS} @@ -145,18 +146,16 @@ function(setup_target_for_coverage_gcovr_html) --json-summary ${Coverage_NAME}/summary.json --json-summary-pretty - # --cobertura - # ${Coverage_NAME}/coverage.cobertura.xml - # --cobertura-pretty - # --decisions + --cobertura + ${Coverage_NAME}/coverage.cobertura.xml + --cobertura-pretty + --decisions -r ${BASEDIR} ${GCOVR_ADDITIONAL_ARGS} ${GCOVR_EXCLUDE_ARGS} --object-directory=${PROJECT_BINARY_DIR}) - message(STATUS "PROJECT_BINARY_DIR: ${PROJECT_BINARY_DIR}") - add_custom_target( ${Coverage_NAME} COMMAND ${GCOVR_HTML_EXEC_TESTS_CMD} From 03755187dd12f06cafacab0b4c9d936efef583c8 Mon Sep 17 00:00:00 2001 From: abelbarreira Date: Mon, 21 Apr 2025 13:25:10 +0200 Subject: [PATCH 4/4] chore: added a comment --- cmake/CodeCoverage.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index ecbb86a..b1bc35d 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -136,7 +136,7 @@ function(setup_target_for_coverage_gcovr_html) --json-summary-pretty --html-theme github.dark-green - --gcov-ignore-errors=no_working_dir_found) + --gcov-ignore-errors=no_working_dir_found) # ABR added since workflow `.github/workflows/ubuntu.yml` failed set(GCOVR_HTML_CMD ${GCOVR_PATH} ${GCOVR_EXTRA_FLAGS}