Skip to content

Commit

Permalink
CI fixes and support Python 3.11 (pyinfra-dev#932)
Browse files Browse the repository at this point in the history
* Use latest arch image in Docker e2e tests

* Update CI workflows to use Ubuntu 22.04

* Use explicit MacOS/Windows GitHub runners

Explicit over implict here, even if it requires occaisional maintenance
it avoids unexpected surprises.

* Upgrade CI workflow acion versions

* Use Ubuntu 20.04 for unit tests for Python 3.6

* Cleanup Python versions

* Pin Python versions for lint/type-check

* Run unit tests on Python 3.11

* Run MacOS/Windows unit tests with Python 3.11

* Fix pytest/coverage package versions for Python 3.6 -> 3.11 compatibility

* Fix prints with click 7

* Specify Python version for e2e tests
  • Loading branch information
Fizzadar authored Dec 18, 2022
1 parent ceff67f commit 61cf618
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 30 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ on:

jobs:
deploy:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- name: Clone Source Repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Clone Generated Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository: fizzadar/docs.pyinfra.com
path: docs/public/

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
uses: actions/setup-python@v4

- name: Install
run: |
Expand Down
40 changes: 23 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ jobs:
#

lint:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- run: pip install '.[test]'
- run: flake8

type-check:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- run: pip install '.[test]'
- run: scripts/check-operation-stub-typing.sh
- run: mypy pyinfra pyinfra_cli
Expand All @@ -38,17 +42,17 @@ jobs:
- type-check
strategy:
matrix:
os: [ubuntu-18.04]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
os: [ubuntu-20.04]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
include:
- os: macos-latest
python-version: 3.8
- os: windows-2019
python-version: 3.8
- os: macos-12
python-version: "3.11"
- os: windows-2022
python-version: "3.11"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: pip install '.[test]'
Expand All @@ -63,14 +67,16 @@ jobs:
- unit-test
strategy:
matrix:
os: [ubuntu-18.04]
os: [ubuntu-20.04]
test-name: [local, ssh, docker]
include:
- os: macos-latest
test-name: local
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- run: pip install '.[test]'
- run: pytest -m end_to_end_${{ matrix.test-name }}
6 changes: 3 additions & 3 deletions pyinfra_cli/prints.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ def print_results(state: "State"):
host_args = ("red",)
host_kwargs["bold"] = True

changed_str = "Changed: {0}".format(click.style(changed_ops, bold=True))
changed_str = "Changed: {0}".format(click.style(f"{changed_ops}", bold=True))
if partial_ops:
changed_str = f"{changed_str} ({partial_ops} partial)"

error_str = "Errors: {0}".format(click.style(error_ops, bold=True))
error_str = "Errors: {0}".format(click.style(f"{error_ops}", bold=True))
if ignored_error_ops:
error_str = f"{error_str} ({ignored_error_ops} ignored)"

Expand All @@ -328,7 +328,7 @@ def print_results(state: "State"):
[
host.style_print_prefix(*host_args, **host_kwargs),
changed_str,
"No change: {0}".format(click.style(meta["ops_no_change"], bold=True)),
"No change: {0}".format(click.style(f"{meta['ops_no_change']}", bold=True)),
error_str,
],
),
Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@

TEST_REQUIRES = ANSIBLE_REQUIRES + (
# Unit testing
"pytest==7.0.1",
"pytest-cov==3.0.0",
"coverage==6.2",
# TODO: drop Python 3.6 support
'pytest==7.0.1 ; python_version <= "3.6"',
'coverage==6.2 ; python_version <= "3.6"',
'pytest==7.2.0 ; python_version > "3.6"',
'coverage==6.5 ; python_version > "3.6"',
"pytest-cov==4.0.0",
"codecov==2.1.12",
# Formatting & linting
"black==22.3.0",
Expand Down
3 changes: 2 additions & 1 deletion tests/end-to-end/test_e2e_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def test_int_docker_git_gem_and_pip_on_mult(helpers):
@pytest.mark.end_to_end_docker
def test_int_docker_pacman_on_arch(helpers):
helpers.run_check_output(
"pyinfra --chdir examples @docker/archlinux:base-20220102.0.42924 pacman.py",
# ArchLinux is continuously updated so using latest here seems most sensible
"pyinfra --chdir examples @docker/archlinux:latest pacman.py",
expected_lines=["docker build complete"],
)

Expand Down

0 comments on commit 61cf618

Please sign in to comment.