|
| 1 | +# PyGAD GitHub Actions Workflow |
| 2 | +# This workflow uses a Matrix Strategy to test PyGAD across multiple Python versions in parallel. |
| 3 | +name: PyGAD PyTest Matrix |
| 4 | + |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + # Trigger the workflow on pushes to the 'github-actions' branch. |
| 11 | + branches: |
| 12 | + - github-actions |
| 13 | + # - master |
| 14 | + # Allows manual triggering of the workflow from the GitHub Actions tab. |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +jobs: |
| 18 | + pytest: |
| 19 | + # Use the latest Ubuntu runner for all jobs. |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + # The Strategy Matrix defines the environments to test. |
| 23 | + # GitHub Actions will spawn a separate, parallel job for each version in the list. |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
| 27 | + |
| 28 | + # Dynamic name that appears in the GitHub Actions UI for each parallel job. |
| 29 | + name: PyTest / Python ${{ matrix.python-version }} |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout Repository |
| 33 | + uses: actions/checkout@v3 |
| 34 | + |
| 35 | + # Setup the specific Python version defined in the current matrix iteration. |
| 36 | + - name: Setup Python ${{ matrix.python-version }} |
| 37 | + uses: actions/setup-python@v4 |
| 38 | + with: |
| 39 | + python-version: ${{ matrix.python-version }} |
| 40 | + |
| 41 | + # Install project dependencies from requirements.txt. |
| 42 | + - name: Install Dependencies |
| 43 | + run: | |
| 44 | + python -m pip install --upgrade pip |
| 45 | + pip install -r requirements.txt |
| 46 | +
|
| 47 | + # Build the PyGAD package distribution (generating .tar.gz and .whl files). |
| 48 | + # This ensures the package build process is valid on this Python version. |
| 49 | + - name: Build PyGAD |
| 50 | + run: | |
| 51 | + python3 -m pip install --upgrade build |
| 52 | + python3 -m build |
| 53 | +
|
| 54 | + # Install the newly built .whl file to verify the package is installable. |
| 55 | + - name: Install PyGAD from Wheel |
| 56 | + run: | |
| 57 | + find ./dist/*.whl | xargs pip install |
| 58 | +
|
| 59 | + - name: Install PyTest |
| 60 | + run: pip install pytest |
| 61 | + |
| 62 | + # Run the entire test suite using PyTest. |
| 63 | + # PyTest automatically discovers all test files in the 'tests/' directory. |
| 64 | + # This includes our new tests for visualization, operators, parallel processing, etc. |
| 65 | + - name: Run Tests |
| 66 | + run: | |
| 67 | + pytest |
0 commit comments