Skip to content

Commit

Permalink
Workflow/67 properly upgrade cicd tests to python 312 once the versio…
Browse files Browse the repository at this point in the history
…n is available in the environment (#70)
  • Loading branch information
noexec authored Oct 16, 2024
2 parents 640fbb1 + cca4285 commit 4b42c14
Show file tree
Hide file tree
Showing 29 changed files with 91 additions and 76 deletions.
57 changes: 33 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- develop
- 'release/**'
- 'workflow/**'
- 'bugfix/**'
tags:
- 'v*'
schedule:
Expand All @@ -16,18 +17,21 @@ on:
jobs:
test-venv:
strategy:
fail-fast: false
matrix:
python-version: ['3.12', '3.11', '3.10', '3.9', '3.8', 'pypy3.10', 'pypy3.8']
python-version: ['3.13', '3.12', '3.11', '3.10', '3.9', '3.8', 'pypy3.10', 'pypy3.8']
platform: [ubuntu, windows]
architecture: [x64, x86]
exclude:
- platform: ubuntu
architecture: x86
- platform: windows
python-version: '3.12'
python-version: '3.13'
- platform: windows
architecture: x64
python-version: '3.10'
- platform: windows
architecture: x86
python-version: '3.9'
- platform: windows
python-version: 'pypy3.10'
Expand All @@ -39,7 +43,7 @@ jobs:

steps:
- name: Check out repository and assets
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: recursive
Expand Down Expand Up @@ -72,7 +76,7 @@ jobs:

- name: Archive code coverage report
if: ((success() && matrix.python-version == '3.12' && matrix.platform == 'ubuntu') || steps.test.conclusion == 'failure') && !startsWith(matrix.python-version, 'pypy')
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ github.job }}-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.architecture }}
path: build/tests/coverage/
Expand All @@ -96,21 +100,22 @@ jobs:
test-conda:
strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.8']
python-version: ['3.12', '3.11', '3.8']
platform: [ubuntu, windows, macos]

name: Test miniconda / ${{ matrix.python-version }}-${{ matrix.platform }}
runs-on: ${{ matrix.platform }}-latest

steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Miniconda with Python ${{ matrix.python-version }} and package dependencies
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
miniconda-version: latest
Expand All @@ -125,34 +130,38 @@ jobs:
run: pytest

- name: Archive code coverage report
if: ((success() && matrix.python-version == '3.11' && matrix.platform != 'ubuntu') || steps.test.conclusion == 'failure')
uses: actions/upload-artifact@v3
if: ((success() && matrix.python-version == '3.12' && matrix.platform != 'ubuntu') || steps.test.conclusion == 'failure')
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ github.job }}-${{ matrix.python-version }}-${{ matrix.platform }}
path: build/tests/coverage/


test-platform-packages:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, ubuntu-22.04]

name: Test Linux / platform / wheel
needs: build-dist
runs-on: ubuntu-latest
runs-on: ${{ matrix.platform }}

steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install maximal subset of platform Python packages
run: |
sudo -n apt-get update -y
sudo -n apt-get install -y --no-upgrade libcurl4-openssl-dev
sudo -n apt-get install -y python3-{pycurl,tenacity,tqdm}
sudo -n apt-get install -y python3-{bandit,filelock,mypy,pytest,setuptools-scm,werkzeug,wheel,cairo} black
sudo -n apt-get install -y python3-pytest-{cov,pylint,repeat,sugar,xdist}
sudo -n apt-get install -y python3-{bandit,cairo,filelock,mypy,pytest,rich,setuptools-scm,werkzeug,wheel} black
sudo -n apt-get install -y python3-pytest-{cov,mock,pylint,repeat,sugar,xdist}
- name: Download package distribution
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: curldl-dist
path: dist
Expand All @@ -179,7 +188,7 @@ jobs:
sudo -n apt-get install -y python3-{pycurl,tenacity,tqdm,cairo}
- name: Download package distribution
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: curldl-dist
path: dist
Expand All @@ -202,7 +211,7 @@ jobs:

steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
Expand All @@ -224,7 +233,7 @@ jobs:
run: ./venv.sh misc/scripts/run-sphinx.sh

- name: Upload documentation artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: curldl-docs
path: build/docs/
Expand All @@ -242,7 +251,7 @@ jobs:
run: ./venv.sh pytest --no-cov

- name: Upload build artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: curldl-dist
path: dist/
Expand All @@ -259,7 +268,7 @@ jobs:

steps:
- name: Download package distribution artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: curldl-dist
path: dist
Expand All @@ -271,7 +280,7 @@ jobs:
repository-url: https://test.pypi.org/legacy/

- name: Publish Release to GitHub
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: dist/*
draft: ${{ contains(github.ref, 'dev') }}
Expand All @@ -291,18 +300,18 @@ jobs:

steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Download code coverage artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage-report-test-venv-3.12-ubuntu-x64
path: coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: coverage
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "assets"]
path = assets
url = ../curldl-assets.git
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2

build:
os: ubuntu-22.04
os: ubuntu-lts-latest
apt_packages:
- libcurl4-openssl-dev
tools:
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,19 @@ Overall, _curldl_ is expected to not have any issues in any environment with Pyt

# Testing

A simplified configuration matrix covered by [CI/CD test + build pipeline](https://github.com/noexec/curldl/actions/workflows/ci.yml) at the time of writing this document is presented below:
A simplified configuration matrix covered by [CI/CD test + build pipeline](https://github.com/noexec/curldl/actions/workflows/ci.yml) is presented below:

| Platform | CPython 3.8 | CPython 3.9+3.12, PyPy 3.8+3.10 | CPython 3.10 | CPython 3.11 |
|-------------|-----------------------|---------------------------------|----------------|--------------|
| Ubuntu-x64 | venv, conda, platform | venv | venv, platform | venv, conda |
| Windows-x64 | venv, conda | | | venv, conda |
| Windows-x86 | venv | | | venv |
| macOS-x64 | conda | | | conda |
| Platform | 3.8 | 3.9 | 3.10 | 3.11 | 3.12 | 3.13 | PyPy 3.8 | PyPy 3.10 |
|-------------|-----|-----|------|------|-------|------|----------|-----------|
| Ubuntu-x64 | v c | v | v p | v c | v c p | v | v | v |
| Windows-x64 | v c | v | | v c | v c | | | |
| Windows-x86 | v | | v | v | v | | | |
| macOS-x64 | c | | | c | c | | | |

In the table:
* _venv_ — virtual environment with all package dependencies and [editable package install](https://pip.pypa.io/en/stable/topics/local-project-installs/); on Ubuntu includes tests with minimal versions of package dependencies;
* _conda__Miniconda_ with package dependencies installed from _mini-forge_ channel, and _curldl_ as editable package install;
* _platform_ — as many dependencies as possible satisfied via Ubuntu package repository, and _curldl_ as _wheel_ install.
* _v_ (venv) — virtual environment with all package dependencies and [editable package install](https://pip.pypa.io/en/stable/topics/local-project-installs/); on Ubuntu includes tests with minimal versions of package dependencies;
* _c_ (conda)_Miniconda_ with package dependencies installed from _mini-forge_ channel, and _curldl_ as editable package install;
* _p_ (platform) — as many dependencies as possible satisfied via Ubuntu package repository, and _curldl_ as _wheel_ install; see [images](https://github.com/actions/runner-images) for OS and platform Python versions.

The CI/CD pipeline succeeds only if _curldl_ package successfully builds and passes all the [pytest](https://pytest.org/) test cases with 100% [code coverage](https://coverage.readthedocs.io/), as well as [Pylint](https://pylint.readthedocs.io/), [Mypy](https://mypy-lang.org/) and [Bandit](https://bandit.readthedocs.io/) static code analysis. Code style checks are also a part of the pipeline. Note that the testing code is also covered by these restrictions.

Expand Down
1 change: 0 additions & 1 deletion assets
Submodule assets deleted from 1573ae
File renamed without changes.
1 change: 1 addition & 0 deletions docs/changelog.d/70.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Extended CI/CD testing matrix with Python 3.13 and more platform-specific configurations
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from importlib import metadata

project = "curldl"
copyright = "2023, Michael Orlov"
copyright = "2024, Michael Orlov"

release = metadata.version(project)
version = ".".join(release.split(".")[:2])
Expand Down Expand Up @@ -56,7 +56,7 @@

html_theme = "furo"

html_theme_options = {"navigation_with_keys": True, "top_of_page_button": None}
html_theme_options = {"navigation_with_keys": True, "top_of_page_buttons": []}

autoclass_content = "both"

Expand Down
8 changes: 4 additions & 4 deletions misc/conda/test-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ dependencies:
- tqdm>=4.50.0
# testing dependencies
- black
- mypy>=0.981
- pytest
- pytest-cov
- pytest-httpserver
- pytest-mock
- pytest-mypy
- pytest-pylint
- pylint
- pytest-sugar
- pytest-sugar>=0.9.7
- setuptools-scm[toml]
- types-pycurl
- types-tqdm
- attrs
# editable install and unsatisfied runtime dependencies
# editable install and testing dependencies missing from conda-forge
- pip
- pip:
- pytest-black-ng
- pytest-isort
- pytest-pylint
- -e ../..
2 changes: 1 addition & 1 deletion misc/scripts/run-isort.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ project_dir="${script_dir}/../.."
code_roots="src tests docs"

cd "${project_dir}"
isort ${code_roots} "$@"
python3 -m isort ${code_roots} "$@"
2 changes: 1 addition & 1 deletion misc/scripts/run-mypy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ project_dir="${script_dir}/../.."
code_roots="src tests"

cd "${project_dir}"
mypy ${code_roots} "$@"
python3 -m mypy ${code_roots} "$@"
20 changes: 16 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: File Transfer Protocol (FTP)",
Expand All @@ -30,19 +34,24 @@ classifiers = [
requires-python = ">=3.8"
dependencies = [
"pycurl>=7.44.0", # PycURL wrapper for cURL library
"pycurl>=7.45.2; python_version>='3.13'", # need Py_TRASHCAN_SAFE_END fix
"pycurl<7.45.2; implementation_name=='pypy'", # need Py_TRASHCAN_BEGIN
"tenacity>=6.2.0", # retry policies
"tqdm>=4.50.0" # console progress bar
]

[project.optional-dependencies]
minimal = [
"pycurl==7.44.0", # need CURLINFO_CONDITION_UNMET
"pycurl==7.44.0; python_version<'3.13'", # need CURLINFO_CONDITION_UNMET
"pycurl==7.45.2; python_version>='3.13'", # need Py_TRASHCAN_SAFE_END fix
"tenacity==6.2.0", # need type hinting and no-warnings asyncio (also requires six)
"tqdm==4.50.0" # need colour parameter (also requires colorama on win32)
]

test = [
"bandit[toml]", # security issues checks
"bandit[toml]>=1.7.5", # security issues checks
"mypy>=0.981", # type hinting verifier
"pycurl<7.45; implementation_name=='pypy'", # JIT-related bug when testing
"pytest", # pytest testing framework
"pytest-black-ng", # code formatter (--black)
"pytest-cov", # code coverage (--cov)
Expand All @@ -52,7 +61,7 @@ test = [
"pytest-mypy", # type hinting verifier (--mypy)
"pytest-pylint", # static code analysis (--pylint)
"pytest-repeat", # repeating tests (@pytest.mark.repeat)
"pytest-sugar", # look-and-feel for pytest progress
"pytest-sugar>=0.9.7", # look-and-feel for pytest progress
"pytest-xdist[psutil]", # distributed tests (-n logical --no-pylint)
"types-pycurl", # external type annotations: pycurl
"types-tqdm" # external type annotations: tqdm
Expand All @@ -64,6 +73,7 @@ dev = [
"pipdeptree", # show packages dependency tree
"pip-autoremove", # remove unused package dependencies
"pip-review", # upgrade outdated packages
"pycparser; implementation_name=='pypy'", # needed for pip check
"towncrier", # producing changelogs
"twine", # PyPI package publishing
"wheel", # build system (also downloaded during build)
Expand Down Expand Up @@ -110,7 +120,7 @@ issue_format = "[#{issue}](https://github.com/noexec/curldl/pull/{issue})"


[tool.pytest.ini_options]
addopts = "--maxfail=10 --mypy --pylint --black --isort --cov --cov-report=term --cov-report=html --cov-report=xml"
addopts = "--mypy --pylint --black --isort --cov --cov-report=term --cov-report=html --cov-report=xml"
testpaths = ["tests", "src"] # "src" required for pylint and mypy (whereas cov considers imported files)
cache_dir = "build/tests/pytest_cache"

Expand All @@ -130,6 +140,7 @@ good-names-rgxs = "^(dl)$"
[tool.pylint.design]
min-public-methods = 1
max-args = 15
max-positional-arguments = 10
max-attributes = 15
max-locals = 20

Expand Down Expand Up @@ -160,6 +171,7 @@ exclude = '[\\/]_version\.py$'


[tool.isort]
known_first_party = ["curldl"]
profile = "black"


Expand Down
1 change: 1 addition & 0 deletions src/curldl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Safely and reliably download files with PycURL.
See :class:`curldl.Curldl` for usage examples."""

from curldl.curldl import Curldl
1 change: 1 addition & 0 deletions src/curldl/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This script is invoked when running the main module, as in:
``python -m curldl``
"""

from curldl import cli

raise SystemExit(cli.main())
Loading

0 comments on commit 4b42c14

Please sign in to comment.