Skip to content

Commit

Permalink
Upgraded Python Tests GA to setup-uv
Browse files Browse the repository at this point in the history
Removed system from uv pip

Installing Python is not explicit

Added glob cache

Add flake8 to dev requirements

Removed pyflake

not installing to system

Removed frozen

Fixed syntax

Moved benchmarking and publish to setup-uv

Changed publish GA action

Added lockfile

Moved all actions to 3.13

Went back to python version via uv

Uniformed GA
  • Loading branch information
alcides committed Dec 9, 2024
1 parent fb1ad24 commit 8f5bd25
Show file tree
Hide file tree
Showing 7 changed files with 1,030 additions and 100 deletions.
76 changes: 42 additions & 34 deletions .github/workflows/python-benchmarking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,52 @@ name: Python Benchmarking

on:
push:
branches: [ main ]
branches: ["*"]
pull_request:
branches: ["*"]


jobs:
benchmark:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
python-version: ["3.13"]

steps:
- uses: actions/checkout@v4.1.1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-benchmark mypy
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
- name: Check install
run: |
pip install -e .
- name: Test with pytest
run: |
pytest --benchmark-only --benchmark-json output.json
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Python Benchmark with pytest-benchmark
tool: 'pytest'
output-file-path: output.json
# Use personal access token instead of GITHUB_TOKEN due to https://github.community/t/github-action-not-triggering-gh-pages-upon-push/16096
github-token: ${{ secrets.BENCHMARK_REPO_TOKEN }}
gh-repository: github.com/alcides/GeneticEngineBenchmarkResults
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
alert-comment-cc-users: '@alcides'
- uses: actions/checkout@v4
- name: Install the latest version of uv and set the python version
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: |
**/requirements*.txt
**/pyproject.toml
- name: Create venv
run: |
uv venv
- name: Install dependencies
run: |
if [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then uv pip install -r requirements-dev.txt; fi
- name: Check install
run: |
uv pip install -e .
- name: Test with pytest
run: |
uv run --frozen pytest --benchmark-only --benchmark-json output.json
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Python Benchmark with pytest-benchmark
tool: 'pytest'
output-file-path: output.json
# Use personal access token instead of GITHUB_TOKEN due to https://github.community/t/github-action-not-triggering-gh-pages-upon-push/16096
github-token: ${{ secrets.BENCHMARK_REPO_TOKEN }}
gh-repository: github.com/alcides/GeneticEngineBenchmarkResults
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
alert-comment-cc-users: '@alcides'
56 changes: 34 additions & 22 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,42 @@

name: Upload Python Package

on: [push, pull_request]
on:
push:
branches: ["main"]

jobs:
deploy:

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13"]

steps:
- uses: actions/checkout@v4.1.1
- name: Set up Python
uses: actions/setup-python@v5.0.0
with:
python-version: '3.x'
# - name: Set env
# run: echo "VIRTUAL_ENV=$(python -c 'import sys; print(sys.prefix)')">> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade uv
uv pip install --system build
- name: Build package
run: python -m build
- name: Publish package
if: github.repository == 'alcides/GeneticEngine' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v4
- name: Install the latest version of uv and set the python version
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: |
**/requirements*.txt
**/pyproject.toml
- name: Create venv
run: |
uv venv
- name: Install dependencies
run: |
if [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then uv pip install -r requirements-dev.txt; fi
- name: Lint with mypy
run: |
uv run mypy --no-strict-optional --ignore-missing-imports --explicit-package-bases geneticengine
- name: Check install
run: |
uv pip install -e .
- name: Build package
run: uv build
- name: Publish
run: uv publish -t ${{ secrets.PYPI_API_TOKEN }}
42 changes: 19 additions & 23 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,44 @@ name: Python Tests

on:
push:
branches: [main]
branches: ["*"]
pull_request:
branches: [main]
branches: ["*"]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4.1.1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- name: Install the latest version of uv and set the python version
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
# - name: Set env
# run: echo "VIRTUAL_ENV=$(python -c 'import sys; print(sys.prefix)')">> $GITHUB_ENV
enable-cache: true
cache-dependency-glob: |
**/requirements*.txt
**/pyproject.toml
- name: Create venv
run: |
uv venv
- name: Install dependencies
run: |
python -m pip install --upgrade uv
uv pip install --system flake8 pytest mypy
if [ -f requirements.txt ]; then uv pip install --system -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then uv pip install --system -r requirements-dev.txt; fi
if [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then uv pip install -r requirements-dev.txt; fi
- name: Lint with mypy
run: |
mypy --no-strict-optional --ignore-missing-imports --explicit-package-bases geneticengine
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
uv run mypy --no-strict-optional --ignore-missing-imports --explicit-package-bases geneticengine
- name: Check install
run: |
uv pip install --system -e .
uv pip install -e .
- name: Test with pytest
run: |
pytest --cov --benchmark-skip
run: uv run --frozen pytest --cov --benchmark-skip
- name: Upload coverage reports to Codecov
if: ${{ (matrix.python-version == '3.11') }}
if: ${{ (matrix.python-version == '3.13') }}
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
48 changes: 28 additions & 20 deletions .github/workflows/run-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,33 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
python-version: ["3.13"]


steps:
- uses: actions/checkout@v4.1.1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# - name: Set env
# run: echo "VIRTUAL_ENV=$(python -c 'import sys; print(sys.prefix)')">> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade uv
uv pip install --system flake8 pytest mypy
if [ -f requirements.txt ]; then uv pip install --system -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then uv pip install --system -r requirements-dev.txt; fi
- name: Check install
run: |
uv pip install --system -e .
- name: Run Examples Bash
run: |
bash run_examples.sh
- uses: actions/checkout@v4
- name: Install the latest version of uv and set the python version
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: |
**/requirements*.txt
**/pyproject.toml
- name: Create venv
run: |
uv venv
- name: Install dependencies
run: |
if [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then uv pip install -r requirements-dev.txt; fi
- name: Lint with mypy
run: |
uv run mypy --no-strict-optional --ignore-missing-imports --explicit-package-bases geneticengine
- name: Check install
run: |
uv pip install -e .
- name: Run Examples Bash
run: |
source .venv/bin/activate
bash run_examples.sh
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
'dill==0.3.9',
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ mypy==1.13.0
pre-commit
pycln
pytest
pytest-cov
pytest-codspeed
pytest-cov
ruff
Loading

0 comments on commit 8f5bd25

Please sign in to comment.