Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI PR #6: GitHub CI/tox: Update CI to use Python 3.11, 3.12 and 3.13 #148

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
16ed521
Fix GitHub CI and 'tox' for local CI on Ubuntu 24.04
bernhardkaindl Nov 15, 2024
efe4efb
Add checks to compensate code coverage
bernhardkaindl Nov 15, 2024
0c94f63
Cover the code handing a 2nd call of accessor.finish()
bernhardkaindl Nov 15, 2024
32aceac
Fix first half of the pyright warnings in unit tests
bernhardkaindl Nov 15, 2024
d1504af
Fix pylint and 2nd half of the pyright warnings in unit tests
bernhardkaindl Nov 15, 2024
e28224e
pyright: Bump Python version to check for to 3.11
bernhardkaindl Nov 15, 2024
b1c5365
pyright: Fix ErrorHandler taking Response | None
bernhardkaindl Nov 15, 2024
e52d72e
pyright: Skip warning on renamed arg: FTPAccessor.access(name->path)
bernhardkaindl Nov 15, 2024
b5fb04a
tox.ini: Complete the transition from pyre to pyright
bernhardkaindl Nov 15, 2024
cb947a6
pre-commit: Remove the remaining call to pyre in pre-commit
bernhardkaindl Nov 15, 2024
96a73d3
docs: Complete the transition from pyre to pyright
bernhardkaindl Nov 15, 2024
c1ebd7b
`tox.ini/pyright`: Fail `tox` if `pyright` fails (enforce check)
bernhardkaindl Nov 15, 2024
88ad644
pyre: Finally, remove obsolete pyre error suppressions
bernhardkaindl Nov 15, 2024
6357af6
GitHub CI/`tox`: Update CI to use Python `3.11`, `3.12` and `3.13`
bernhardkaindl Nov 15, 2024
ab21598
`test_bootloader.py`/`pylint`: assertRegexpMatches renamed to assertR…
bernhardkaindl Nov 15, 2024
e30a79d
`CONTRIBUTING.md`: Add `venv` setup and using `pipx`
bernhardkaindl Nov 15, 2024
f1b4826
`tests/test_logger.py`: Use `pyfakefs`: don't create a file in the host
bernhardkaindl Nov 15, 2024
fc28eb1
`.github/workflows/main.yml`: Cleanup obsolete code for Python 2.7/3.8
bernhardkaindl Nov 15, 2024
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
23 changes: 4 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: '3.6'
os: ubuntu-20.04
- python-version: '3.10'
os: ubuntu-22.04
- python-version: '3.11'
os: ubuntu-22.04
- python-version: '3.12'
os: ubuntu-22.04
- python-version: '3.13'
os: ubuntu-22.04
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -58,21 +58,6 @@ jobs:
pip install 'virtualenv<20.22' 'tox==4.5.1' tox-gh-actions
tox --workdir .github/workflows/.tox --recreate

# tox >= 4.0.0 is needed for using optional-dependencies from pyproject.toml, which is
# is not available for python <= 3.6, so use the python3.8 of Ubuntu-20.04 to install it:
- name: Run tox for 3.6 and 3.8 on ${{ matrix.os }}'s 3.8 to get 'extras' from pyproject.toml)
if: ${{ matrix.python-version == 2.7 || matrix.python-version == 3.6 }}
run: |
set -xv;curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.8 get-pip.py
# The alternative is installing python3-pip but we don't need full pip function for now:
# sudo apt-get update && sudo apt-get install -y python3-pip
# Let tox-gh-actions get the environment(s) to run tests with from tox.ini:
# Use tox==4.5.1: tox>=4 is needed for reading the extras from pyproject.toml
# Warning: tox>=4.5.2 depends on virutalenv>=20.23, which breaks Python 2.7:
python3.8 -m pip install 'virtualenv<20.22' 'tox==4.5.1' tox-gh-actions
tox --workdir .github/workflows/.tox --recreate

- name: Select the coverage file for upload
if: |
( matrix.python-version == '3.6' || matrix.python-version == '3.11' ) &&
Expand Down
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@ repos:
- toml
- repo: local
hooks:
- id: run-pyre
name: run-pyre (expect this to take 30 seconds)
entry: python pyre_runner.py
types: [python]
language: python
log_file: ".git/pre-commit-pyre.log"
additional_dependencies: [pyre-check,mock]
- id: pytype
name: pytype (may take up to two minutes)
entry: sh -c "pytype >/dev/tty"
Expand Down
6 changes: 4 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ disable=W0142,W0703,C0111,R0201,W0603,W0613,W0212,W0141,
len-as-condition,
no-else-return,
raise-missing-from,
too-many-positional-arguments,
too-many-branches,
too-many-nested-blocks,
too-many-statements,
Expand Down Expand Up @@ -222,8 +223,9 @@ defining-attr-methods=__init__,__new__,setUp

[DESIGN]

# Maximum number of arguments for function / method
max-args=100
# Maximum number of arguments for function / method.
# defaults to: max-args=5
max-args=10

# Argument names that match this expression will be ignored. Default to name
# with leading underscore
Expand Down
33 changes: 30 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Development setup

## Create a virtual environment with the test dependencies

```bash
python -m venv .venv
. .venv/bin/activate
pip install pip-tools==7.3.0
pip-compile --extra=test,mypy,pyright,pytype,tox -o - pyproject.toml | pip install -r /dev/stdin
```

## Development setup on Fedora 37

On Fedora 37, the `tox` rpm installs all Python versions.
Expand All @@ -6,9 +17,26 @@ But this `tox` is older, so install `tox==4.5.1` using `pip` (see below)
```bash
sudo dnf install tox;sudo rpm -e tox
```
But preferably use `tox` from the virtual environment instead.

## Development setup on Ubuntu 24.04

Prefer the virtual environment. Alternatively, an option is to use `pipx`:

```bash
sudo apt install pipx
pipx install tox; pipx install 'pytest<7';pipx install pylint
pipx inject pytest pytest-{forked,localftpserver,pythonpath,subprocess,timeout} pyfakefs pytest_httpserver six mock
pipx inject pylint pyfakefs six mock pytest{,_forked,-localftpserver}
```

Use the `deadsnakes` ppa to install Python versions like 3.8 and 3.11 (see below)

## Development setup on Ubuntu 22.04

Usage of <https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa> to install
other python versions.

```bash
sudo apt update
sudo apt install software-properties-common python{2,3}-dev
Expand Down Expand Up @@ -50,13 +78,12 @@ This project uses `tox` to run the tests for different python versions. Intro:
> A comprehensive beginner's introduction to `tox`":_
> https://www.seanh.cc/2018/09/01/tox-tutorial/

`tox` runs `pytest`, `pylint` and static analysis using `mypy`, `pyre`, `pytype`, and `pyright`.
`tox` runs `pytest`, `pylint` and static analysis using `mypy`, `pytype`, and `pyright`.
Links:

- https://mypy.readthedocs.io/en/stable/
- https://microsoft.github.io/pyright/
- https://google.github.io/pytype/
- https://pyre-check.org/

With `tox`, developers can run the full test suite for Python 2.7 and 3.x.
The same test suite is used in GitHub CI:
Expand All @@ -78,7 +105,7 @@ Using pip-tools, you can extract the requirements and extras from `pyptoject.tom

```bash
PYTHON=python3.10
EXTRAS=.,test,mypy,pyre,pytype,tox
EXTRAS=.,test,mypy,pyright,pytype,tox
PFLAGS="--no-warn-conflicts"
$PYTHON -m pip install pip-tools==7.3.0
$PYTHON -m piptools compile --extra=$EXTRAS -o - pyproject.toml |
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The Continuous Integration Tests feature:
- Checking of the combined coverage against the diff to master: Fails if changes are not covered!
- Pylint report in the GitHub Action Summary page, with Warning and Error annotatios, even in the code review.
- Check that changes don't generate pylint warnings (if warning classes which are enabled in .pylintrc)
- Static analysis using `mypy`, `pyre` and `pytype`
- Static analysis using `mypy`, `pylint`, `pyright` and `pytype`

This enforces that any change (besides whitespace):

Expand Down Expand Up @@ -72,7 +72,6 @@ For the installation of the general development dependencies, visit [INSTALL.md]
- Test with `python2.7 -m pytest`
- Run `mypy` (without any arguments - The configuration is in `pyproject.toml`)
- Run `./pytype_runner.py`
- Run `./pyre_runner.py`
- Run `tox -e py36-lint` and fix any `Pylint` warnings
- Run `tox -e py310-covcombine-check` and fix any missing diff-coverage.
- Run `tox` for the full CI test suite
Expand All @@ -86,7 +85,7 @@ The list of `virtualenvs` configured in tox can be shown using this command: `to
$ tox -av
default environments:
py36-lint -> Run in a py36 virtualenv: Run pylint and fail on warnings remaining on lines in the diff to master
py311-pyre -> Run in a py311 virtualenv: Run pyre for static analyis, only passes using: tox -e py311-pyre
py311-pyright -> Run in a py311 virtualenv: Run pyright for static analyis
py38-pytype -> Run in a py38 virtualenv: Run pytype for static analyis, intro: https://youtu.be/abvW0mOrDiY
py310-covcombine-check -> Run in a py310 virtualenv: Generate combined coverage reports with py27-test coverage merged Run mypy for static analyis

Expand All @@ -100,7 +99,7 @@ test -> Run in a python virtualenv: Run pytest in this environ

If you have only one version of Python3, that works too. Use: `tox -e py<ver>-test`

## Static analysis using mypy, pyre, pyright and pytype
## Static analysis using mypy, pylint, pyright and pytype

The preconditions for using static analysis with `mypy` (which passes now but has
only a few type comments) and `pyright` are present now and `mypy` is enabled in `tox`
Expand Down
12 changes: 4 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ mypy = [
"types-six",
"types-toml",
]
# pyre introduced two false-postives recently, pin it to prevent further surprises:
pyre = [
"pyre-check == 0.9.21",
"pyre-extensions == 0.0.30",
]
pytype = [
"pandas",
"pytype",
Expand Down Expand Up @@ -116,11 +111,12 @@ show_error_context = true
error_summary = true
files = ["xcp", "tests/test_*.py"]
mypy_path = "stubs"
python_version = "3.10"
python_version = "3.11"
warn_redundant_casts = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
explicit_package_bases = true
disallow_any_unimported = true
disallow_any_explicit = false
disallow_any_generics = true
Expand Down Expand Up @@ -198,7 +194,7 @@ exclude = [
extraPaths = ["stubs"]
include = ["xcp", "tests"]
pythonPlatform = "Linux"
pythonVersion = "3.6"
pythonVersion = "3.11"
reportFunctionMemberAccess = true
reportGeneralTypeIssues = "warning"
reportOptionalMemberAccess = "warning"
Expand All @@ -211,7 +207,7 @@ stubPath = "stubs"
inputs = ["xcp", "tests", "./*.py"]
keepgoing = true
platform = "linux"
python_version = "3.10"
python_version = "3.11"
pythonpath = ".:stubs"
disable = ["ignored-type-comment"]
overriding_parameter_count_checks = true
Expand Down
62 changes: 0 additions & 62 deletions pyre_runner.py

This file was deleted.

3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
# These are the most of the needed pytest plugins, unfortunately this list does
# not support ;python_version<=3.0 or ;python_version>3.0. Therefore, it can
# only list plugins available for all tested python versions (2.7, 3.6 ... 3.11):
# pytest-localftpserver is also used, but its installation is not checked
# to to its installation not being detected on Ubuntu 24.04:
required_plugins =
pytest_httpserver
pytest-forked
pytest-localftpserver
pytest-pythonpath
pytest-subprocess
pytest-timeout
Expand Down
Empty file removed stubs/pyfakefs/__init__.pyi
Empty file.
Loading
Loading