Update CI workflow to fetch core files from open_dev branch#399
Update CI workflow to fetch core files from open_dev branch#399geatpy-dev merged 1 commit intogeatpy-dev:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request updates the CI workflow to fetch pre-built core binary files from a separate open_dev branch instead of building them locally. The workflow now pulls platform-specific compiled binaries and copies them to the appropriate location before building and testing.
Changes:
- Changed Ubuntu runner from
ubuntu-latesttoubuntu-20.04to ensure Python 3.6 compatibility - Added step to fetch and checkout the
_coredirectory from theopen_devbranch - Added step to copy platform-specific core files from
_coretogeatpy/corebased on OS and Python version
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fi | ||
| PY_VERSION="v${{ matrix.python-version }}" | ||
| mkdir -p geatpy/core | ||
| cp -r "_core/${OS_DIR}/lib64/${PY_VERSION}/"* geatpy/core/ |
There was a problem hiding this comment.
The copy operation lacks error handling and validation. If the source path "_core/${OS_DIR}/lib64/${PY_VERSION}/" doesn't exist or contains no files, the command will fail but the error may not be clear. Consider adding a check to verify the source directory exists and contains files before attempting the copy, or using 'set -e' to ensure the script fails fast on errors.
| cp -r "_core/${OS_DIR}/lib64/${PY_VERSION}/"* geatpy/core/ | |
| SRC_DIR="_core/${OS_DIR}/lib64/${PY_VERSION}" | |
| if [[ ! -d "$SRC_DIR" ]]; then | |
| echo "Error: Source directory '$SRC_DIR' does not exist." >&2 | |
| exit 1 | |
| fi | |
| shopt -s nullglob | |
| files=("$SRC_DIR"/*) | |
| if [[ ${#files[@]} -eq 0 ]]; then | |
| echo "Error: No files found to copy in '$SRC_DIR'." >&2 | |
| exit 1 | |
| fi | |
| cp -r "${files[@]}" geatpy/core/ |
| else | ||
| OS_DIR="Linux" |
There was a problem hiding this comment.
The script assumes that macOS runners will never be used. If the matrix is expanded to include macOS in the future, the OS_DIR will be set to "Linux" for macOS, which is likely incorrect. Consider adding an explicit check for macOS or documenting this limitation.
| else | |
| OS_DIR="Linux" | |
| elif [[ "$RUNNER_OS" == "Linux" ]]; then | |
| OS_DIR="Linux" | |
| else | |
| echo "Unsupported RUNNER_OS '$RUNNER_OS'. This workflow currently supports only Windows and Linux." | |
| exit 1 |
| os: [ubuntu-20.04, windows-latest] | ||
| python-version: ["3.6"] |
There was a problem hiding this comment.
Python 3.6 reached end-of-life in December 2021 and is no longer supported. The change to ubuntu-20.04 may be to ensure Python 3.6 availability, but this creates a maintenance burden as ubuntu-20.04 itself will reach end-of-life soon (April 2025 for standard support). Consider upgrading to a supported Python version (3.8+) to ensure long-term maintainability and security.
| os: [ubuntu-20.04, windows-latest] | |
| python-version: ["3.6"] | |
| os: [ubuntu-latest, windows-latest] | |
| python-version: ["3.8", "3.11"] |
There was a problem hiding this comment.
The issue is that the compiled core module are of python 3.6.
| git fetch origin open_dev | ||
| git checkout origin/open_dev -- _core |
There was a problem hiding this comment.
The git fetch and checkout operations lack error handling. If the 'open_dev' branch doesn't exist or the '_core' directory is not present in that branch, the workflow will fail silently or with unclear errors. Consider adding error handling to verify the branch exists and the checkout was successful before proceeding.
| git fetch origin open_dev | |
| git checkout origin/open_dev -- _core | |
| set -e | |
| # Verify that the remote branch 'open_dev' exists | |
| if ! git ls-remote --exit-code origin open_dev >/dev/null 2>&1; then | |
| echo "Error: remote branch 'open_dev' not found on 'origin'." >&2 | |
| exit 1 | |
| fi | |
| # Fetch the latest state of the 'open_dev' branch | |
| git fetch origin open_dev | |
| # Attempt to check out the '_core' directory from the remote branch | |
| if ! git checkout origin/open_dev -- _core; then | |
| echo "Error: failed to check out '_core' directory from 'origin/open_dev'." >&2 | |
| exit 1 | |
| fi | |
| # Verify that the '_core' directory now exists | |
| if [ ! -d "_core" ]; then | |
| echo "Error: '_core' directory not found after checkout. Verify it exists in the 'open_dev' branch." >&2 | |
| exit 1 | |
| fi |
No description provided.