Add automated testing workflow with GTest integration#2
Add automated testing workflow with GTest integration#2
Conversation
Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com>
Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com>
Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com>
…ency Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com>
Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com>
|
@copilot Non puoi usare conan-io/setup-conan@v2 perchè non esiste, devi usare la versione conan-io/setup-conan@v1 |
There was a problem hiding this comment.
Pull request overview
This PR adds automated CI/CD testing infrastructure for an existing GTest-based unit test suite that previously only supported manual execution. The changes introduce a GitHub Actions workflow that builds and runs tests on every push/PR to main, with test result visualization.
Key changes:
- New test workflow that builds the project and executes unit tests with XML result generation
- Enhanced test runner script supporting multiple build types and improved test discovery
- Added test execution documentation with examples for local and CI/CD scenarios
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
.github/workflows/test.yaml |
New workflow that builds project, runs GTest suite, and publishes results with EnricoMi action |
src/run_all_ut.sh |
Enhanced to accept build type parameter, search multiple locations, and report test execution status |
README.md |
Added test workflow badge and comprehensive test execution documentation section |
.github/workflows/compilation.yaml |
Upgraded Conan action from v1 to v2 and added explicit permissions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for file in "$location"/ut_*; do | ||
| if [ -x "$file" ]; then | ||
| echo "Running test: $file" | ||
| "$file" | ||
| TESTS_FOUND=$((TESTS_FOUND + 1)) | ||
| fi |
There was a problem hiding this comment.
The script searches for test executables matching the pattern ut_*, but there's no validation that the matched files are actually executable files (not directories). The check if [ -x "$file" ] helps, but the glob pattern "$location"/ut_* could match a non-existent file if no files match, causing the script to try to execute a literal string like "build/Release/ut_*". Consider adding a check if [ -f "$file" ] before the executable check.
| comment_mode: "off" | ||
|
|
||
| - name: Test Summary | ||
| if: always() |
There was a problem hiding this comment.
The Test Summary step always shows success even if tests fail. Since the "Run unit tests" step has continue-on-error: false, failures will be caught, but this message is misleading. Consider making it conditional or reflecting the actual test status using GitHub Actions expressions like if: success() instead of if: always().
| if: always() | |
| if: success() |
| I test verificano la correttezza dell'implementazione SHA-1 e SHA-256 confrontandola con la libreria OpenSSL, includendo: | ||
| - Test con stringhe vuote, corte, lunghe e molto lunghe | ||
| - Test con caratteri speciali e non-ASCII | ||
| - Test di determinismo | ||
| - Test dell'effetto valanga (avalanche effect) | ||
| - Test di performance |
There was a problem hiding this comment.
The documentation mentions SHA-0 in line 8 ("In questo progetto è stata effettuata l'implementazione degli algoritmi SHA-0, SHA-1 e SHA-256"), but the test verification section only mentions SHA-1 and SHA-256. If SHA-0 is not being tested, this inconsistency could confuse users about what's covered by the test suite.
| @@ -5,9 +5,32 @@ set -e | |||
| # Nella cartella ./build avviare tutti gli eseguibili che iniziano con ut_ | |||
There was a problem hiding this comment.
The comment on line 5 is in Italian ("Nella cartella ./build avviare tutti gli eseguibili che iniziano con ut_") but no longer accurately describes the script's behavior. The script now searches in multiple locations and accepts a build type parameter, which is not mentioned in the comment. Consider updating the comment to reflect the current functionality.
| # Nella cartella ./build avviare tutti gli eseguibili che iniziano con ut_ | |
| # Script per eseguire tutti gli eseguibili di test che iniziano con ut_ | |
| # Cerca nelle cartelle di build (es. ./build/<BUILD_TYPE> e ./build) usando un BUILD_TYPE opzionale (default: Release) |
| ./run_all_ut.sh Release | ||
| # Also generate XML output for test reporting | ||
| ./build/Release/ut_sha_functions --gtest_output=xml:test-results.xml | ||
| continue-on-error: false |
There was a problem hiding this comment.
The workflow explicitly sets continue-on-error: false which is already the default behavior for GitHub Actions steps. This line is redundant and can be removed without changing functionality.
| continue-on-error: false |
| ./run_all_ut.sh Release | ||
| # Also generate XML output for test reporting |
There was a problem hiding this comment.
The tests are being run twice - once via run_all_ut.sh and again directly with --gtest_output=xml. This means the test suite executes twice on every run, doubling the CI execution time unnecessarily. Consider removing line 44 and modifying run_all_ut.sh to accept an optional parameter for generating XML output, or just run the test executable directly with the XML flag.
| ./run_all_ut.sh Release | |
| # Also generate XML output for test reporting |
| exit 1 | ||
| fi | ||
|
|
||
| echo "All tests completed successfully! ($TESTS_FOUND test suite(s) executed)" No newline at end of file |
There was a problem hiding this comment.
The message "All tests completed successfully!" is misleading because it will be printed even if tests fail. The script uses set -e which should cause it to exit on test failure, but the message assumes success. Consider making the success message conditional or removing it since the exit code already indicates success.
| echo "All tests completed successfully! ($TESTS_FOUND test suite(s) executed)" | |
| echo "Test execution completed. ($TESTS_FOUND test suite(s) executed)" |
Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com>
The repository had a comprehensive GTest test suite (
ut_sha_functions.cc) but no automated CI/CD testing—only manual execution viarun_all_ut.sh.Changes
New GitHub Actions workflow (
.github/workflows/test.yaml)main--gtest_output=xmlflagEnricoMi/publish-unit-test-result-action@v2for result visualizationcontents: read,checks: write)Enhanced test runner (
src/run_all_ut.sh)./run_all_ut.sh [Debug|Release]build/$BUILD_TYPEandbuilddirectoriesDocumentation
Security & consistency
conan-io/setup-conan@v1Test suite validates SHA-1/SHA-256 implementations against OpenSSL across edge cases (empty strings, Unicode, million-char strings, avalanche effect, performance benchmarks).
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.