Skip to main content

Using the Makefile

Intro

This document explains how to use the Makefile in the root directory of the ansible-power-aix repository. It will cover the various targets defined in the Makefile and their purposes.


Utility Targets

The utility targets section defines general-purpose commands that can be used for various tasks.

######################################################################################
# utility targets
######################################################################################


The help target provides usage information for the Makefile. Running make help will display a list of available targets and their descriptions.

.PHONY: help
help:
@echo "usage: make <target>"
@echo ""
@echo "target:"
@echo "install-requirements ANSIBLE_VERSION=<version> install all requirements"
@echo "install-ansible ANSIBLE_VERSION=<version> install ansible: 2.9, 3, or 4"
@echo "install-ansible-devel-branch install ansible development branch"
@echo "install-sanity-test-requirements install python modules needed to \
run sanity testing"
@echo "install-unit-test-requirements install python modules needed \
run unit testing"
@echo "lint lint ansible module and roles"
@echo "module-lint MODULE=<module path> lint ansible module"
@echo "role-lint ROLE=<role path> lint ansible role"
@echo "porting MODULE=<module path> check if module is python3 ported"
@echo "sanity-test MODULE=<module path> run sanity test on the collections"
@echo "unit-test TEST=<test path> run unit test suite for the collection"
@echo "clean clean junk files"



The clean target removes temporary and cache files generated during the build and test processes. This includes Python cache files and collections.

.PHONY: clean
clean:
@rm -rf tests/unit/plugins/modules/__pycache__
@rm -rf tests/unit/plugins/modules/common/__pycache__
@rm -rf collections/ansible_collections
@rm -rf plugins/modules/__pycache__



The uninstall-pylint target uninstalls the pylint package using pip. This can be useful if you need to reinstall or upgrade pylint.

.PHONY: uninstall-pylint
uninstall-pylint:
python -m pip uninstall --yes pylint



Installation Targets

The installation targets section defines commands for installing various dependencies required for the project.

# installation targets
######################################################################################


The install-requirements target installs all necessary requirements, including Ansible and Python modules needed for sanity and unit testing. It also upgrades pip.

.PHONY: install-requirements
install-requirements: install-ansible install-sanity-test-requirements \
install-unit-test-requirements
python -m pip install --upgrade pip



The install-ansible target installs a specific version of Ansible if the ANSIBLE_VERSION variable is set. If not, it installs the latest version of Ansible.

.PHONY: install-ansible
install-ansible:
python -m pip install --upgrade pip
ifdef ANSIBLE_VERSION
python -m pip install ansible==$(ANSIBLE_VERSION).*
else
python -m pip install ansible
endif


The install-ansible-devel-branch target installs the development branch of Ansible from the GitHub repository.

.PHONY: install-ansible-devel-branch
install-ansible-devel-branch:
python -m pip install --upgrade pip
python -m pip install https://github.com/ansible/ansible/archive/devel.tar.gz \
--disable-pip-version-check



The install-sanity-test-requirements target installs Python modules needed to run sanity tests, as specified in the tests/sanity/sanity.requirements file.

.PHONY: install-sanity-test-requirements
install-sanity-test-requirements:
python -m pip install -r tests/sanity/sanity.requirements



The install-unit-test-requirements target installs Python modules needed to run unit tests, as specified in the tests/unit/unit.requirements file.

.PHONY: install-unit-test-requirements
install-unit-test-requirements:
python -m pip install -r tests/unit/unit.requirements



The install-pylint-py3k target uninstalls the current version of pylint and installs a specific version compatible with Python 3.

.PHONY: install-pylint-py3k
install-pylint-py3k: uninstall-pylint
python -m pip install --upgrade pip
python -m pip install pylint==2.10.*



Testing Targets

The testing targets section defines commands for running various tests on the project.

# testing targets
######################################################################################


The lint target runs both module and role linting to ensure code quality and adherence to coding standards.

.PHONY: lint
lint: module-lint role-lint



The module-lint target runs sanity tests and linting on Ansible modules using ansible-test, flake8, and pycodestyle.

.PHONY: module-lint
module-lint:
ansible-test sanity -v --color yes --truncate 0 --python $(PYTHON_VERSION) \
--exclude $(DEPRECATED) --test pylint $(MODULE)
flake8 --ignore=E402,W503 --max-line-length=160 --exclude $(DEPRECATED) $(MODULE)
python -m pycodestyle --ignore=E402,W503 --max-line-length=160 --exclude $(DEPRECATED) \
$(MODULE)



The role-lint target runs linting on Ansible roles using ansible-lint.

.PHONY: role-lint
role-lint:
ansible-lint --force-color -f pep8 $(ROLE)



The porting target checks if the modules are compatible with Python 3 using pylint --py3k.

.PHONY: porting
porting:
python -m pylint --py3k --output-format=colorized $(MODULE) $(VIOSHC_SCRIPT)



The compile target runs sanity tests to compile the modules and check for syntax errors.

.PHONY: compile
compile:
ansible-test sanity --test compile --python $(PYTHON_VERSION) $(MODULE)



The sanity-test target runs sanity tests on the collection using ansible-test.

.PHONY: sanity-test
sanity-test:
ansible-test sanity -v --color yes --truncate 0 --python $(PYTHON_VERSION) \
--exclude $(DEPRECATED) $(MODULE)



The unit-test target runs unit tests on the collection using ansible-test and generates a coverage report.

.PHONY: unit-test
unit-test:
@if [ -d "tests/output/coverage" ]; then \
ansible-test coverage erase; \
fi
ansible-test units -v --color yes --python $(PYTHON_VERSION) \
--coverage $(TEST)

ansible-test coverage report --omit $(TEST_OMIT) --include "$(MODULE)" --show-missing


 

This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human