Skip to content

Commit

Permalink
Fixed AutomationHub import warnings where possible; Added 'make lint'
Browse files Browse the repository at this point in the history
Details:

* Resolved a subset of the AutomationHub warnings reported in the
  import logs. These warnings are reported by ansible-lint.

* Added a new make target 'lint' for running ansible-lint, in order
  to get a preview of the AutomationHub warnings. Added ansible-lint
  to the development dependencies.
  Needed to increase some package dependencies.

* Added 'make lint' as a new step to the Githubb Actions test workflow.

Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Dec 17, 2023
1 parent 5aeb641 commit 9c388a2
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ jobs:
PACKAGE_LEVEL: ${{ matrix.package_level }}
run: |
make sanity
- name: Run ansible-lint
env:
PACKAGE_LEVEL: ${{ matrix.package_level }}
run: |
make lint
- name: Run unit/function test
env:
PACKAGE_LEVEL: ${{ matrix.package_level }}
Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ help:
@echo ' dist - Build the collection distribution archive in: $(dist_dir)'
@echo ' check - Run flake8'
@echo ' sanity - Run Ansible sanity tests (includes pep8, pylint, validate-modules)'
@echo ' lint - dist + run ansible-lint on distribution archive'
@echo ' safety - Run safety on sources'
@echo ' check_reqs - Perform missing dependency checks'
@echo ' docs - Build the documentation for all enabled (docs/source/conf.py) versions in: $(doc_build_dir) using remote repo'
Expand Down Expand Up @@ -249,7 +250,7 @@ help:
@echo ' ansible-playbook playbooks/....'

.PHONY: all
all: install develop dist safety check sanity check_reqs docs docslocal linkcheck test end2end_mocked
all: install develop dist safety check sanity lint check_reqs docs docslocal linkcheck test end2end_mocked
@echo '$@ done.'

.PHONY: install
Expand Down Expand Up @@ -318,6 +319,15 @@ else
endif
@echo '$@ done.'

.PHONY: lint
lint: _check_version $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done $(dist_file)
echo 'Running ansible-lint on distribution archive'
rm -rf $(dist_dir)/tmp
mkdir -p $(dist_dir)/tmp
tar -xf $(dist_file) --directory $(dist_dir)/tmp
-sh -c "cd $(dist_dir)/tmp; ansible-lint --profile production -f pep8"
@echo '$@ done.'

.PHONY: check_reqs
check_reqs: _check_version $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done minimum-constraints.txt requirements.txt
ifeq ($(python_major_version),2)
Expand Down
5 changes: 3 additions & 2 deletions ansible-constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ MarkupSafe>=2.0.0; python_version >= '3.9' # ansible >= 6
# Direct dependencies for development (must be consistent with dev-requirements.txt)

# ansible-test
yamllint==1.25.0
pathspec==0.8.0
yamllint==1.25.0; python_version == '2.7'
yamllint==1.26.3; python_version >= '3.5'
pathspec==0.9.0
rstcheck==3.3.1; python_version <= '3.9' # ansible <= 2.10 (on minimum package levels)
16 changes: 13 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,23 @@ coveralls>=3.3.0; python_version >= '3.5'
# PyYAML is specified in requirements.txt

# ansible-test
yamllint>=1.25.0
pathspec>=0.8.0
yamllint>=1.25.0; python_version == '2.7'
yamllint>=1.26.3; python_version >= '3.5'
pathspec>=0.9.0
# rstcheck 3.5.0 introduced a FutureWarning about Python 3.7 causing ansible sanity check "rstcheck" to fail.
# ansible sanity check "rstcheck" is used only in ansible <= 2.10.
rstcheck>=3.3.1,<3.5; python_version >= '3.5' and python_version <= '3.6' # ansible <= 2.10 (on minimum package levels)
rstcheck>=3.3.1,<4.0; python_version >= '3.7' and python_version <= '3.9' # ansible >= 4

# ansible-lint
# ansible-lint requires yamllint, black
# ansible-lint 6.14.0 depends on ansible-core>=2.12.0
ansible-lint>=4.2.0; python_version == '2.7'
ansible-lint>=4.2.0; python_version == '3.5'
ansible-lint>=5.4.0; python_version >= '3.6' and python_version <= '3.9'
ansible-lint>=6.14.0; python_version >= '3.10'
black>=22.8.0; python_version >= '3.6'

# Safety CI by pyup.io
# Safety is run only on Python >=3.6
# Safety 2.3.5 (running only on Python >=3.6) requires packaging<22.0,>=21.0, but safety 2.3.4 does not
Expand Down Expand Up @@ -138,7 +148,7 @@ astroid>=2.4.0,<2.5; python_version >= '3.5' and python_version <= '3.7' # astr
astroid>=2.4.0,<2.7; python_version >= '3.8' and python_version <= '3.9' # astroid 2.6
astroid>=2.4.0,<2.13; python_version >= '3.10' and python_version <= '3.11' # astroid 2.12
astroid>=3.0.1; python_version >= '3.12' # astroid 3.x
typed-ast>=1.4.0,<1.5.0; python_version >= '3.5' and python_version <= '3.7' and implementation_name=='cpython'
typed-ast>=1.4.2,<1.5.0; python_version >= '3.5' and python_version <= '3.7' and implementation_name=='cpython'
# used by pylint 2.14 which requires python_version >= '3.7' and is used by us only on py>=3.10
dill>=0.2; python_version == '3.11'
dill>=0.3.7; python_version >= '3.12'
Expand Down
2 changes: 1 addition & 1 deletion docs/source/modules/zhmc_cpc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Examples
state: set
properties:
acceptable_status:
- active
- active
description: "This is CPC {{ my_cpc_name }}"
register: cpc1

Expand Down
3 changes: 2 additions & 1 deletion docs/source/modules/zhmc_lpar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ Examples
state: inactive
register: lpar1

- name: Ensure the LPAR is active (using the default image profile when it needs to be activated), and then set the CP sharing weight to 20
- name: "Ensure the LPAR is active (using the default image profile when it needs to be activated),
and then set the CP sharing weight to 20"
zhmc_lpar:
hmc_host: "{{ my_hmc_host }}"
hmc_auth: "{{ my_hmc_auth }}"
Expand Down
15 changes: 10 additions & 5 deletions docs/source/modules/zhmc_user_role.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,18 @@ Examples
properties:
description: "Example user role 1"
permissions:
- task: "configure-storage-storageadmin" # Task permission to "configure-storage-storageadmin"
- task: "hardware-messages" # Task permission to the view-only version of "hardware-messages"
# Task permission to "configure-storage-storageadmin":
- task: "configure-storage-storageadmin"
# Task permission to the view-only version of "hardware-messages":
- task: "hardware-messages"
view_only: true
- class: cpc # Object permission to all CPCs
- partition: part1 # Object permission to part1 in cpc1
# Object permission to all CPCs:
- class: cpc
# Object permission to part1 in cpc1:
- partition: part1
cpc: cpc1
- partition: part2 # Object permission to part2 in cpc2
# Object permission to part2 in cpc2:
- partition: part2
cpc: cpc2
register: rule1

Expand Down
11 changes: 11 additions & 0 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ Availability: `AutomationHub`_, `Galaxy`_, `GitHub`_
that retrieve and return console messages from the operating system running
in an LPAR or DPM partition. (issue #565)

* Added a new make target 'make lint' which invokes ansible-lint.
Fixed some of the warnings reported by ansible-lint.
(related to issue #784)

* Increased the minimum versions of the following packages used for installing
the collection:

- packaging to 21.3 (on Python >= 3.6)
- PyYAML to 6.0.1 (on Python >= 3.6)
- jsonschema to 4.10.0 (on Python >= 3.7)

**Cleanup:**

* Removed documentation and test files (except sanity test ignore files) from
Expand Down
3 changes: 3 additions & 0 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,16 @@ build_ignore:
- .coveragerc
- .flake8 # only in older branches
- .travis.yml
- .whitesource
- .safety-policy.yml
- CODE_OF_CONDUCT.md
- CONTRIBUTING.rst # only in older branches
- DCO1.1.txt # only in older branches
- LICENSE
- Makefile
# requirements.txt is intentionally included for dependent install
- dev-requirements.txt
- ansible-constraints.txt
- minimum-constraints.txt
- tools
- docs_local
Expand Down
2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Keep in sync with lowest ansible version in requirements.txt and minimum-constraints.txt

Check failure on line 1 in meta/runtime.yml

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 3.11, latest)

meta-runtime[unsupported-version]

requires_ansible key must be set to a supported version.

Check failure on line 1 in meta/runtime.yml

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 3.12, latest)

meta-runtime[unsupported-version]

requires_ansible key must be set to a supported version.

Check failure on line 1 in meta/runtime.yml

View workflow job for this annotation

GitHub Actions / test (macos-latest, 3.11, latest)

meta-runtime[unsupported-version]

requires_ansible key must be set to a supported version.
requires_ansible: ">=2.9"
requires_ansible: ">=2.9.27"
28 changes: 20 additions & 8 deletions minimum-constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ importlib-metadata==1.1.0; python_version >= '3.8' and python_version <= '3.11'
importlib-metadata==4.8.3; python_version >= '3.12'

packaging==20.5; python_version <= '3.5'
packaging==21.0; python_version >= '3.6'
PyYAML==5.3.1
packaging==21.3; python_version >= '3.6'
PyYAML==5.3.1; python_version <= '3.5'
PyYAML==6.0.1; python_version >= '3.6'

python-dateutil==2.8.2
jsonschema==3.0.1
jsonschema==3.0.1; python_version <= '3.6'
jsonschema==4.10.0; python_version >= '3.7'
urllib3==1.26.18; python_version == '2.7'
urllib3==1.26.9; python_version == '3.5'
urllib3==1.26.18; python_version >= '3.6'
Expand Down Expand Up @@ -144,10 +146,18 @@ pytest-cov==2.7.0
coveralls==3.3.0; python_version >= '3.5'

# ansible-test
yamllint==1.25.0
pathspec==0.8.0
yamllint==1.25.0; python_version == '2.7'
yamllint==1.26.3; python_version >= '3.5'
pathspec==0.9.0
rstcheck==3.3.1; python_version <= '3.9' # ansible <= 2.10 (on minimum package levels)

# ansible-lint
ansible-lint==4.2.0; python_version == '2.7'
ansible-lint==4.2.0; python_version == '3.5'
ansible-lint==5.4.0; python_version >= '3.6' and python_version <= '3.9'
ansible-lint==6.14.0; python_version >= '3.10'
black==22.8.0; python_version >= '3.6'

# Safety CI by pyup.io
# Safety is run only on Python >=3.6
safety==2.2.0; python_version >= '3.6'
Expand Down Expand Up @@ -191,7 +201,7 @@ astroid==2.4.0; python_version >= '3.5' and python_version <= '3.11'
# astroid==2.6.1; python_version >= '3.8' and python_version <= '3.9'
# astroid==2.12.4; python_version >= '3.10' and python_version <= '3.11'
astroid==3.0.1; python_version >= '3.12'
typed-ast==1.4.0; python_version >= '3.5' and python_version <= '3.7' and implementation_name=='cpython'
typed-ast==1.4.2; python_version >= '3.5' and python_version <= '3.7' and implementation_name=='cpython'
# used by pylint 2.14 which requires python_version >= '3.7' and is used by us only on py>=3.10
dill==0.2; python_version == '3.11'
dill==0.3.7; python_version >= '3.12'
Expand Down Expand Up @@ -241,7 +251,9 @@ contextlib2==0.6.0
custom-inherit==2.2.2
docopt==0.6.2
enum34==1.1.6; python_version == '2.7' # technically: python_version <= '3.3'
filelock==3.2.0; python_version <= '3.11'
filelock==3.2.0; python_version == '2.7'
filelock==3.2.0; python_version == '3.5'
filelock==3.3.0; python_version >= '3.6' and python_version <= '3.11'
filelock==3.11.0; python_version >= '3.12'
future==0.18.3
futures==3.3.0; python_version == '2.7' # technically: python_version <= '3.1'
Expand Down Expand Up @@ -287,7 +299,7 @@ toml==0.10.0
traceback2==1.4.0
traitlets==4.3.1
typing==3.6.1; python_version == '2.7' # technically: python_version <= '3.4'
typing-extensions==3.7.4.3 # Used in some combinations of Python version and package level
typing-extensions==3.10.0.0 # Used in some combinations of Python version and package level
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==1.2.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zhmc_cpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
state: set
properties:
acceptable_status:
- active
- active
description: "This is CPC {{ my_cpc_name }}"
register: cpc1
Expand Down
3 changes: 2 additions & 1 deletion plugins/modules/zhmc_lpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@
state: inactive
register: lpar1
- name: Ensure the LPAR is active (using the default image profile when it needs to be activated), and then set the CP sharing weight to 20
- name: "Ensure the LPAR is active (using the default image profile when it needs to be activated),
and then set the CP sharing weight to 20"
zhmc_lpar:
hmc_host: "{{ my_hmc_host }}"
hmc_auth: "{{ my_hmc_auth }}"
Expand Down
15 changes: 10 additions & 5 deletions plugins/modules/zhmc_user_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,18 @@
properties:
description: "Example user role 1"
permissions:
- task: "configure-storage-storageadmin" # Task permission to "configure-storage-storageadmin"
- task: "hardware-messages" # Task permission to the view-only version of "hardware-messages"
# Task permission to "configure-storage-storageadmin":
- task: "configure-storage-storageadmin"
# Task permission to the view-only version of "hardware-messages":
- task: "hardware-messages"
view_only: true
- class: cpc # Object permission to all CPCs
- partition: part1 # Object permission to part1 in cpc1
# Object permission to all CPCs:
- class: cpc
# Object permission to part1 in cpc1:
- partition: part1
cpc: cpc1
- partition: part2 # Object permission to part2 in cpc2
# Object permission to part2 in cpc2:
- partition: part2
cpc: cpc2
register: rule1
"""
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ importlib-metadata>=4.8.3; python_version >= '3.12'
# packaging>=20.5 is needed by pip-check-reqs 2.4.3 but it requires only packaging>=16.0
# packaging 21.0 removed support for Python <3.6
packaging>=20.5; python_version <= '3.5'
packaging>=21.0; python_version >= '3.6'
packaging>=21.3; python_version >= '3.6'

# PyYAML 5.3 fixed narrow build error on Python 2.7
# PyYAML 5.3 has wheel archives for Python 2.7, 3.5 - 3.9
Expand All @@ -92,11 +92,11 @@ packaging>=21.0; python_version >= '3.6'
# PyYAML 5.4 and 6.0.0 fails install since Cython 3 was released, see issue
# https://github.com/yaml/pyyaml/issues/724.
PyYAML>=5.3.1; python_version <= '3.5'
PyYAML>=5.3.1,!=5.4.0,!=5.4.1; python_version >= '3.6' and python_version <= '3.11'
PyYAML>=5.3.1,!=5.4.0,!=5.4.1,!=6.0.0; python_version >= '3.12'
PyYAML>=6.0.1; python_version >= '3.6'

python-dateutil>=2.8.2
jsonschema>=3.0.1,!=4.0.0,!=4.18.1
jsonschema>=3.0.1,!=4.0.0,!=4.18.1; python_version <= '3.6'
jsonschema>=4.10.0,!=4.18.1; python_version >= '3.7'
# urllib3 1.26.10 removed support for py35
urllib3>=1.26.18; python_version == '2.7'
urllib3>=1.26.9; python_version == '3.5'
Expand Down

0 comments on commit 9c388a2

Please sign in to comment.