-
Notifications
You must be signed in to change notification settings - Fork 391
Extract test script #1476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract test script #1476
Conversation
addac6b to
32c17b0
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9a8a663 to
51beff2
Compare
32c17b0 to
5af9d37
Compare
There was a problem hiding this 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 extracts duplicated build and test logic from two CI workflow files into a single reusable bash script, addressing DRY principles and improving CI performance by switching from pip to uv for Python dependency installation.
Key Changes:
- Created
.github/scripts/build-and-test.shscript that consolidates build logic with parameterized Scala version - Replaced inline bash scripts in both CI workflows with calls to the new script
- Switched from
piptouvfor faster Python package installation with virtual environment isolation
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
.github/workflows/ci-backend-2.13.yml |
Replaced inline build script with call to shared build-and-test.sh script for Scala 2.13.6 |
.github/workflows/ci-backend-2.12.yml |
Replaced inline build script with call to shared build-and-test.sh script for Scala 2.12.12 |
.github/scripts/build-and-test.sh |
New reusable script containing build/test logic with uv-based dependency installation and virtual environment support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Get jep installation details | ||
| echo "Configuring jep library paths..." | ||
| jep_site_packages_path=$(uv pip show jep | grep "^Location:" | cut -d ':' -f 2 | xargs) |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script uses uv pip show jep which requires jep to be installed, but there's no guarantee that jep is in the requirements.txt or was successfully installed. If jep isn't found, jep_site_packages_path will be empty, leading to incorrect path constructions in lines 50-51 and potentially breaking the build. Consider adding error handling to verify jep was installed successfully before attempting to get its location.
| jep_site_packages_path=$(uv pip show jep | grep "^Location:" | cut -d ':' -f 2 | xargs) | |
| jep_site_packages_path=$(uv pip show jep | grep "^Location:" | cut -d ':' -f 2 | xargs) | |
| if [ -z "$jep_site_packages_path" ]; then | |
| echo "Error: 'jep' is not installed or not found in the Python environment. Please ensure 'jep' is listed in requirements.txt and installed successfully." | |
| exit 1 | |
| fi |
|
|
||
| # Set up environment variables for jep | ||
| export LD_LIBRARY_PATH="${jep_path}:${jep_site_packages_path}:${jep_lib_path}:${LD_LIBRARY_PATH:-}" | ||
| export LD_PRELOAD="$(dirname "$(dirname "$(realpath "$(which python3)")")")/lib/libpython3.so" |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This path construction assumes the virtual environment's python3 will be found by which, but there's no verification that the file exists at the constructed path. If the libpython3.so file doesn't exist at this location (e.g., different Python installation structure), LD_PRELOAD will point to a non-existent file, potentially causing runtime failures. The original code used realpath ${jep_site_packages_path}/../../ which was more reliable. Consider adding a check to verify the file exists or reverting to a more robust path resolution method.
| export LD_PRELOAD="$(dirname "$(dirname "$(realpath "$(which python3)")")")/lib/libpython3.so" | |
| LIBPYTHON_SO="${jep_lib_path}/libpython3.so" | |
| if [ -f "${LIBPYTHON_SO}" ]; then | |
| export LD_PRELOAD="${LIBPYTHON_SO}" | |
| else | |
| echo "Warning: libpython3.so not found at ${LIBPYTHON_SO}. LD_PRELOAD will not be set." | |
| fi |
| # Create a Python virtual environment if it doesn't exist | ||
| if [ ! -d ".venv" ]; then | ||
| echo "Creating Python virtual environment in .venv..." | ||
| python -m venv .venv |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script uses python to create the virtual environment but later uses python3 in line 55. This inconsistency could cause issues if python and python3 point to different Python versions or if python doesn't exist on the system. Use python3 consistently throughout the script.
| python -m venv .venv | |
| python3 -m venv .venv |
jonathanindig
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
1642615 to
8e462d6
Compare
5af9d37 to
647b363
Compare
8e462d6 to
593c2ba
Compare
647b363 to
f4dbb79
Compare
f4dbb79 to
695e42c
Compare
With a later goal to have a single command to run tests locally as well.
Problem
Duplicated build logic across CI workflows: The build and test steps were duplicated across both
ci-backend-2.12.ymlandci-backend-2.13.ymlworkflows, with identical multi-line bash scripts. Thisviolates DRY principles, makes maintenance difficult, and uses the slower
pipfor Python dependency installation.Solution
Extracted build logic into reusable script
Created
.github/scripts/build-and-test.sh:uvinstead ofpipfor significantly faster Python dependency installation.venvfor better isolationuvif not presentset -euo pipefail./build-and-test.sh 2.12.12Simplified CI workflows
Both
ci-backend-2.12.ymlandci-backend-2.13.ymlnow use the same script:Benefits