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

Update pre-commit, py 3.10 support and support for vmotion work-in-progress #392

Merged
merged 14 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
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
15 changes: 8 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: "3.10"
- name: Set Cache Key
run: echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- name: Install System Deps
Expand All @@ -36,7 +36,7 @@ jobs:
- name: Set up Python 3.7 For Nox
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: "3.10"

- name: Install Nox
run: |
Expand Down Expand Up @@ -67,8 +67,9 @@ jobs:
- 3.7
- 3.8
- 3.9
- "3.10"
salt-version:
- 3005.1
- 3006.4

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -184,9 +185,9 @@ jobs:
max-parallel: 3
matrix:
python-version:
- 3.7
- "3.10"
salt-version:
- 3005.1
- 3006.4

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -307,9 +308,9 @@ jobs:
max-parallel: 3
matrix:
python-version:
- 3.9
- "3.10"
salt-version:
- 3005.1
- 3006.4

steps:
- uses: actions/checkout@v2
Expand Down
114 changes: 87 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,59 @@
---
minimum_pre_commit_version: 1.15.2
default_language_version:
python: python3

exclude: ^(doc/_static/.*|doc/_themes/.*)$
minimum_pre_commit_version: 2.4.0
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
rev: v4.4.0
hooks:
- id: check-merge-conflict # Check for files that contain merge conflict strings.
- id: trailing-whitespace # Trims trailing whitespace.
args: [--markdown-linebreak-ext=md]
exclude: >
(?x)^(
pkg/macos/pkg-resources/.*\.rtf
)$

- id: mixed-line-ending # Replaces or checks mixed line ending.
args: [--fix=auto]
- id: end-of-file-fixer # Makes sure files end in a newline and only a newline.
exclude: changelog/.*
- id: check-merge-conflict # Check for files that contain merge conflict strings.
- id: check-ast # Simply check whether files parse as valid python.
exclude: >
(?x)^(
templates/.*
)$
- id: check-case-conflict # Check for files with names that would conflict on a
# case-insensitive filesystem like MacOS HFS+ or Windows FAT.
- id: check-json # Attempts to load all json files to verify syntax.
- id: check-symlinks # Checks for symlinks which do not point to anything.
- id: debug-statements # Check for debugger imports and py37+ breakpoint() calls in python source.
exclude: >
(?x)^(
templates/.*
)$
- id: fix-byte-order-marker # removes UTF-8 byte order marker
- id: forbid-submodules # forbids any submodules in the repository.
- id: fix-encoding-pragma # Remove `# -*- coding: utf-8 -*-` from the top of python files.
args:
- --remove
exclude: >
(?x)^(
salt/ext/.*
)$

# ----- Formatting ---------------------------------------------------------------------------->
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.2
hooks:
- id: pyupgrade
name: Rewrite Code to be Py3.7+, drop six usage and Py2 support
args: [--py3-plus, --keep-mock]
exclude: src/saltext/vcenter/version.py

- repo: https://github.com/saltstack/pre-commit-remove-import-headers
rev: 1.1.0
hooks:
Expand All @@ -38,36 +77,22 @@ repos:

- repo: https://github.com/s0undt3ch/salt-rewrite
# Automatically rewrite code with known rules
rev: 1.3.2
rev: "2.2.0"
hooks:
- id: salt-rewrite
alias: rewrite-docstrings
name: Salt extensions docstrings auto-fixes
files: ^src/saltext/vcenter/.*\.py$
args: [--silent]
args: [--silent, -F, fix_docstrings]

- repo: https://github.com/s0undt3ch/salt-rewrite
# Automatically rewrite code with known rules
rev: 1.3.2
hooks:
- id: salt-rewrite
alias: rewrite-tests
name: Rewrite the test suite
name: Rewrite Salt's Test Suite
files: ^tests/.*\.py$
args: [--silent, -E, fix_docstrings]

- repo: https://github.com/asottile/pyupgrade
rev: v2.10.0
hooks:
- id: pyupgrade
name: Rewrite Code to be Py3.7+
args: [
--py3-plus
]
exclude: src/saltext/vcenter/version.py
args: [--silent, -E, fix_asserts, -E, fix_docstrings]

- repo: https://github.com/asottile/reorder_python_imports
rev: v2.4.0
rev: v3.10.0
hooks:
- id: reorder-python-imports
args: [
Expand All @@ -76,7 +101,7 @@ repos:
exclude: src/saltext/vcenter/version.py

- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.6.0
hooks:
- id: black
args: [-l 100]
Expand All @@ -103,21 +128,21 @@ repos:

# ----- Security ------------------------------------------------------------------------------>
- repo: https://github.com/PyCQA/bandit
rev: "1.7.0"
rev: "1.7.4"
hooks:
- id: bandit
alias: bandit-salt
name: Run bandit against the code base
args: [--silent, -lll, --skip, B701]
args: [--silent, -lll, --skip, "B701,B324"]
exclude: src/saltext/vcenter/version.py
additional_dependencies: ['importlib_metadata<5']
- repo: https://github.com/PyCQA/bandit
rev: "1.7.0"
rev: "1.7.4"
hooks:
- id: bandit
alias: bandit-tests
name: Run bandit against the test suite
args: [--silent, -lll, --skip, B701]
args: [--silent, -lll, --skip, "B701,B324"]
files: ^tests/.*
additional_dependencies: ['importlib_metadata<5']
# <---- Security -------------------------------------------------------------------------------
Expand All @@ -131,6 +156,7 @@ repos:
# alias: lint-src
# name: Lint Source Code
# files: ^((setup|noxfile)|src/.*)\.py$
# require_serial: True
# args:
# - -e
# - lint-code-pre-commit
Expand All @@ -143,6 +169,7 @@ repos:
# alias: lint-tests
# name: Lint Tests
# files: ^tests/.*\.py$
# require_serial: True
# args:
# - -e
# - lint-tests-pre-commit
Expand All @@ -151,7 +178,7 @@ repos:

# ----- Static Test Requirements -------------------------------------------------------------->
- repo: https://github.com/saltstack/pip-tools-compile-impersonate
rev: dff9089c1003af49665064067ff63c75b9b69dcd
rev: '4.8'
hooks:
- id: pip-tools-compile
alias: compile-3.7-test-requirements
Expand Down Expand Up @@ -185,6 +212,17 @@ repos:
- --py-version=3.9
- --platform=linux
- requirements/tests.in

- id: pip-tools-compile
alias: compile-3.10-test-requirements
name: Py3.10 Test Requirements
files: ^requirements/tests.in$
pass_filenames: false
args:
- -v
- --py-version=3.10
- --platform=linux
- requirements/tests.in
# <---- Static Test Requirements ---------------------------------------------------------------

# ----- Static Lint Requirements -------------------------------------------------------------->
Expand Down Expand Up @@ -220,6 +258,17 @@ repos:
- --py-version=3.9
- --platform=linux
- requirements/lint.in

- id: pip-tools-compile
alias: compile-3.10-test-requirements
name: Py3.10 Lint Requirements
files: ^requirements/lint.in$
pass_filenames: false
args:
- -v
- --py-version=3.10
- --platform=linux
- requirements/lint.in
# <---- Static Lint Requirements ---------------------------------------------------------------

# ----- Static Docs Requirements -------------------------------------------------------------->
Expand Down Expand Up @@ -255,4 +304,15 @@ repos:
- --py-version=3.9
- --platform=linux
- requirements/docs.in

- id: pip-tools-compile
alias: compile-3.10-test-requirements
name: Py3.10 Docs Requirements
files: ^requirements/docs.in$
pass_filenames: false
args:
- -v
- --py-version=3.10
- --platform=linux
- requirements/docs.in
# <---- Static Docs Requirements ---------------------------------------------------------------
1 change: 1 addition & 0 deletions changelog/350.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added support for vmotion_configured and its supporting functionality
27 changes: 23 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
noxfile
~~~~~~~

Nox configuration script
"""
# pylint: disable=missing-module-docstring,import-error,protected-access,missing-function-docstring
import datetime
import json
Expand All @@ -7,6 +13,15 @@
import sys
import tempfile

# fmt: off
if __name__ == "__main__":
sys.stderr.write(
"Do not execute this file directly. Use nox instead, it will know how to handle this file\n"
)
sys.stderr.flush()
exit(1)
# fmt: on

import nox
from nox.command import CommandFailed
from nox.virtualenv import VirtualEnv
Expand All @@ -24,11 +39,11 @@
os.environ.get("JENKINS_URL") or os.environ.get("CI") or os.environ.get("DRONE") is not None
)
PIP_INSTALL_SILENT = CI_RUN is False
SKIP_REQUIREMENTS_INSTALL = "SKIP_REQUIREMENTS_INSTALL" in os.environ
SKIP_REQUIREMENTS_INSTALL = os.environ.get("SKIP_REQUIREMENTS_INSTALL", "0") == "1"
EXTRA_REQUIREMENTS_INSTALL = os.environ.get("EXTRA_REQUIREMENTS_INSTALL")
COVERAGE_VERSION_REQUIREMENT = "coverage==6.5" # 7.x dropped support for Py 3.7

COVERAGE_VERSION_REQUIREMENT = "coverage==5.2"
SALT_REQUIREMENT = os.environ.get("SALT_REQUIREMENT") or "salt>=3005"
SALT_REQUIREMENT = os.environ.get("SALT_REQUIREMENT") or "salt>=3006"
if SALT_REQUIREMENT == "salt==master":
SALT_REQUIREMENT = "git+https://github.com/saltstack/salt.git@master"

Expand Down Expand Up @@ -355,7 +370,11 @@ def docs(session):
os.chdir("docs/")
session.run("make", "clean", external=True)
session.run("make", "linkcheck", "SPHINXOPTS=-Wn --keep-going", external=True)
session.run("make", "coverage", "SPHINXOPTS=-Wn --keep-going", external=True)

## Disabling till sphinx 7.3.0 is released with fix for divide by zero, i
## see Sphinx https://github.com/sphinx-doc/sphinx/commit/bb74aec2b6aa1179868d83134013450c9ff9d4d6
## session.run("make", "coverage", "SPHINXOPTS=-Wn --keep-going", external=True)

docs_coverage_file = os.path.join("_build", "html", "python.txt")
if os.path.exists(docs_coverage_file):
with open(docs_coverage_file) as rfh:
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Development Status :: 4 - Beta
Intended Audience :: Developers
License :: OSI Approved :: Apache Software License
Expand All @@ -38,7 +39,7 @@ setup_requires =
setuptools>=50.3.2
setuptools-declarative-requirements
install_requires =
salt>=3005
salt>=3006
pyvmomi==7.0.3
importlib_metadata; python_version < "3.8"
jinja2>=3.1.0
Expand All @@ -47,7 +48,7 @@ install_requires =
tests =
pytest>=6.1.0
pytest-cov
pytest-salt-factories>=0.121.1
pytest-salt-factories>=0.912.2
dmurphy18 marked this conversation as resolved.
Show resolved Hide resolved
dev =
nox
towncrier==21.9.0rc1
Expand Down
Loading