Skip to content

Add automated testing workflow with GTest integration#2

Closed
Copilot wants to merge 7 commits intomainfrom
copilot/improve-testing-framework
Closed

Add automated testing workflow with GTest integration#2
Copilot wants to merge 7 commits intomainfrom
copilot/improve-testing-framework

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

The repository had a comprehensive GTest test suite (ut_sha_functions.cc) but no automated CI/CD testing—only manual execution via run_all_ut.sh.

Changes

  • New GitHub Actions workflow (.github/workflows/test.yaml)

    • Builds project and executes unit tests on push/PR to main
    • Generates XML test results with GTest --gtest_output=xml flag
    • Integrates EnricoMi/publish-unit-test-result-action@v2 for result visualization
    • Sets explicit permissions (contents: read, checks: write)
  • Enhanced test runner (src/run_all_ut.sh)

    • Accepts build type argument (defaults to Release): ./run_all_ut.sh [Debug|Release]
    • Auto-detects test executables in build/$BUILD_TYPE and build directories
    • Returns exit code 1 if no tests found
  • Documentation

    • Added test workflow badge to README
    • Added "Esecuzione dei test" section with local test execution examples
  • Security & consistency

    • Added explicit permissions to compilation workflow
    • Both workflows use conan-io/setup-conan@v1

Test suite validates SHA-1/SHA-256 implementations against OpenSSL across edge cases (empty strings, Unicode, million-char strings, avalanche effect, performance benchmarks).

Original prompt

Inprove the testing framework that I have created. Create a new github action for testing.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits January 8, 2026 16:55
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 AI changed the title [WIP] Improve testing framework and add GitHub action Add automated testing workflow with GTest integration Jan 8, 2026
@AndreaCicca AndreaCicca marked this pull request as ready for review January 8, 2026 17:01
Copilot AI requested a review from AndreaCicca January 8, 2026 17:01
@AndreaCicca AndreaCicca requested a review from Copilot January 8, 2026 17:02
@AndreaCicca
Copy link
Owner

@copilot Non puoi usare conan-io/setup-conan@v2 perchè non esiste, devi usare la versione conan-io/setup-conan@v1

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +21 to +26
for file in "$location"/ut_*; do
if [ -x "$file" ]; then
echo "Running test: $file"
"$file"
TESTS_FOUND=$((TESTS_FOUND + 1))
fi
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
comment_mode: "off"

- name: Test Summary
if: always()
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Suggested change
if: always()
if: success()

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +74
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
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@@ -5,9 +5,32 @@ set -e
# Nella cartella ./build avviare tutti gli eseguibili che iniziano con ut_
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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)

Copilot uses AI. Check for mistakes.
./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
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
continue-on-error: false

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +45
./run_all_ut.sh Release
# Also generate XML output for test reporting
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
./run_all_ut.sh Release
# Also generate XML output for test reporting

Copilot uses AI. Check for mistakes.
exit 1
fi

echo "All tests completed successfully! ($TESTS_FOUND test suite(s) executed)" No newline at end of file
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
echo "All tests completed successfully! ($TESTS_FOUND test suite(s) executed)"
echo "Test execution completed. ($TESTS_FOUND test suite(s) executed)"

Copilot uses AI. Check for mistakes.
Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 8, 2026

@copilot Non puoi usare conan-io/setup-conan@v2 perchè non esiste, devi usare la versione conan-io/setup-conan@v1

Fixed in commit 3603e19. Both workflow files now use conan-io/setup-conan@v1.

@AndreaCicca AndreaCicca closed this Jan 8, 2026
@AndreaCicca AndreaCicca deleted the copilot/improve-testing-framework branch January 8, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants