Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-20.04, windows-latest]
python-version: ["3.6"]
Comment on lines +17 to 18
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
os: [ubuntu-20.04, windows-latest]
python-version: ["3.6"]
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.11"]

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The issue is that the compiled core module are of python 3.6.

defaults:
run:
Expand All @@ -23,17 +23,37 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v3

- name: Fetch core files from open_dev branch
run: |
git fetch origin open_dev
git checkout origin/open_dev -- _core
Comment on lines +29 to +30
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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.

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

Copilot uses AI. Check for mistakes.

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install cython setuptools
pip install -r requirements.txt
pip install pytest

- name: Copy core files to geatpy/core
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
OS_DIR="Windows"
else
OS_DIR="Linux"
Comment on lines +47 to +48
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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.

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

Copilot uses AI. Check for mistakes.
fi
PY_VERSION="v${{ matrix.python-version }}"
mkdir -p geatpy/core
cp -r "_core/${OS_DIR}/lib64/${PY_VERSION}/"* geatpy/core/
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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/

Copilot uses AI. Check for mistakes.

- name: Build
run: python setup.py install

- name: Test with pytest
run: |
python -m geatpy --version
Expand Down
Loading