Skip to content

Commit

Permalink
Clarified that supported OS for development are only Linux/macOS
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Jul 19, 2024
1 parent fdd6f54 commit 370ca91
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ jobs:
echo "Installed Python packages:"
pip list
- name: Fail if version of xz tool is affected by CVE-2024-3094
if: ${{ ! startsWith(matrix.os, 'windows') }}
run: |
xz --version;
bash -c "! (xz --version | grep -E '5\.6\.(0|1)')"
Expand Down
37 changes: 13 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
#
# Basic prerequisites for running this Makefile, to be provided manually:
# One of these OS platforms:
# Windows with CygWin
# Linux (any)
# OS-X
# Linux
# macOS
# These commands on all OS platforms:
# make (GNU make)
# bash
# rm, find
# These commands on all OS platforms in the active Python environment:
# python (or python3 on OS-X)
# pip (or pip3 on OS-X)
# These commands on Linux and OS-X:
# uname
# rm, mkdir, cp, find, tar
# git
# python, pip
# ------------------------------------------------------------------------------

# Python / Pip commands
Expand Down Expand Up @@ -52,17 +49,9 @@ ifndef RUN_TYPE
endif

# Determine OS platform make runs on
ifeq ($(OS),Windows_NT)
PLATFORM := Windows
DEV_NULL := nul
else
# Values: Linux, Darwin
PLATFORM := $(shell uname -s)
DEV_NULL := /dev/null
endif
PLATFORM := $(shell uname -s)

# Namespace and name of this collection
# TODO: Check out whether this needs to match the 'name' attribute specified in setup.py.
collection_namespace := ibm
collection_name := ibm_zhmc
collection_full_name := $(collection_namespace).$(collection_name)
Expand All @@ -76,7 +65,7 @@ collection_version := $(shell $(PYTHON_CMD) tools/version.py)
min_ansible_core_version := 2.15.0

# Installed ansible-core version (empty if ansible is not installed)
ansible_core_version := $(shell $(PYTHON_CMD) -c "import sys,ansible; sys.stdout.write(ansible.__version__)" 2>$(DEV_NULL))
ansible_core_version := $(shell $(PYTHON_CMD) -c "import sys,ansible; sys.stdout.write(ansible.__version__)" 2>/dev/null)

# Python versions
python_version := $(shell $(PYTHON_CMD) -c "import sys; sys.stdout.write('{v[0]}.{v[1]}.{v[2]}'.format(v=sys.version_info))")
Expand Down Expand Up @@ -313,13 +302,13 @@ bandit: $(done_dir)/bandit_$(pymn)_$(PACKAGE_LEVEL).done
# The variable is empty if ansible is not installed.
# We run the sanity test only on officially supported Ansible versions, except for:
# * Python 3.10 with minimum package levels because sanity setup fails with PyYAML 5.4.1 install issue with Cython 3
run_sanity_current := $(shell PL=$(PACKAGE_LEVEL) MIN_AC=$(min_ansible_core_version) $(PYTHON_CMD) -c "import sys,os,ansible; py=sys.version_info[0:2]; ac=list(map(int,ansible.__version__.split('.'))); min_ac=list(map(int,os.getenv('MIN_AC').split('.'))); pl=os.getenv('PL'); sys.stdout.write('true' if ac>=min_ac and not (py==(3,10) and pl=='minimum') and not py>=(3,13) else 'false')" 2>$(DEV_NULL))
run_sanity_current := $(shell PL=$(PACKAGE_LEVEL) MIN_AC=$(min_ansible_core_version) $(PYTHON_CMD) -c "import sys,os,ansible; py=sys.version_info[0:2]; ac=list(map(int,ansible.__version__.split('.'))); min_ac=list(map(int,os.getenv('MIN_AC').split('.'))); pl=os.getenv('PL'); sys.stdout.write('true' if ac>=min_ac and not (py==(3,10) and pl=='minimum') and not py>=(3,13) else 'false')" 2>/dev/null)

# Boolean variable indicating that the Ansible sanity test should be run in its own virtual Python environment.
# The variable is empty if ansible is not installed.
# We run the sanity test only on officially supported Ansible versions, except for:
# * Python 3.10 with minimum package levels because sanity setup fails with PyYAML 5.4.1 install issue with Cython 3
run_sanity_virtual := $(shell PL=$(PACKAGE_LEVEL) MIN_AC=$(min_ansible_core_version) $(PYTHON_CMD) -c "import sys,os,ansible; py=sys.version_info[0:2]; ac=list(map(int,ansible.__version__.split('.'))); min_ac=list(map(int,os.getenv('MIN_AC').split('.'))); pl=os.getenv('PL'); sys.stdout.write('true' if ac>=min_ac and not (py==(3,10) and pl=='minimum') and not py>=(3,13) else 'false')" 2>$(DEV_NULL))
run_sanity_virtual := $(shell PL=$(PACKAGE_LEVEL) MIN_AC=$(min_ansible_core_version) $(PYTHON_CMD) -c "import sys,os,ansible; py=sys.version_info[0:2]; ac=list(map(int,ansible.__version__.split('.'))); min_ac=list(map(int,os.getenv('MIN_AC').split('.'))); pl=os.getenv('PL'); sys.stdout.write('true' if ac>=min_ac and not (py==(3,10) and pl=='minimum') and not py>=(3,13) else 'false')" 2>/dev/null)

# The sanity check requires the .git directory to be present.
.PHONY: sanity
Expand All @@ -332,13 +321,13 @@ sanity: _check_version $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done $(dist_
tar -xf $(dist_file) --directory $(sanity_coll_dir)
ifeq ($(run_sanity_current),true)
echo "Running ansible sanity test in the current Python env (using ansible-core $(ansible_core_version) and Python $(python_version))"
sh -c "cd $(sanity_coll_dir); ansible-test sanity --verbose --truncate 0 --local"
bash -c "cd $(sanity_coll_dir); ansible-test sanity --verbose --truncate 0 --local"
else
echo "Skipping ansible sanity test in the current Python env (using ansible-core $(ansible_core_version) and Python $(python_version))"
endif
ifeq ($(run_sanity_virtual),true)
echo "Running ansible sanity test in its own virtual Python env (using ansible-core $(ansible_core_version) and Python $(python_version))"
sh -c "cd $(sanity_coll_dir); ansible-test sanity --verbose --truncate 0 --venv --requirements"
bash -c "cd $(sanity_coll_dir); ansible-test sanity --verbose --truncate 0 --venv --requirements"
else
echo "Skipping ansible sanity test in its own virtual Python env (using ansible-core $(ansible_core_version) and Python $(python_version))"
endif
Expand All @@ -348,7 +337,7 @@ endif
# The variable is empty if ansible is not installed.
# We run ansible-lint only on officially supported Ansible versions, except for:
# * Python 3.9 with minimum package levels because ansible-lint 6.14.0 requires ansible-core>=2.12 which is incompatible with ansible's requirement
run_ansible_lint := $(shell PL=$(PACKAGE_LEVEL) MIN_AC=$(min_ansible_core_version) $(PYTHON_CMD) -c "import sys,os,ansible; py=sys.version_info[0:2]; ac=ansible.__version__.split('.'); min_ac=os.getenv('MIN_AC').split('.'); pl=os.getenv('PL'); sys.stdout.write('true' if ac>=min_ac and py>=(3,10) else 'false')" 2>$(DEV_NULL))
run_ansible_lint := $(shell PL=$(PACKAGE_LEVEL) MIN_AC=$(min_ansible_core_version) $(PYTHON_CMD) -c "import sys,os,ansible; py=sys.version_info[0:2]; ac=ansible.__version__.split('.'); min_ac=os.getenv('MIN_AC').split('.'); pl=os.getenv('PL'); sys.stdout.write('true' if ac>=min_ac and py>=(3,10) else 'false')" 2>/dev/null)

.PHONY: ansible_lint
ansible_lint: _check_version $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done $(dist_file)
Expand All @@ -357,7 +346,7 @@ ifeq ($(run_ansible_lint),true)
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"
-bash -c "cd $(dist_dir)/tmp; ansible-lint --profile production -f pep8"
else
echo "Skipping ansible-lint (using ansible-core $(ansible_core_version) and Python $(python_version))"
endif
Expand Down
9 changes: 7 additions & 2 deletions docs/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ Setting up the development environment

The development environment is pretty easy to set up.

Besides having a supported operating system with a supported Python version
(see :ref:`Supported environments`), it is recommended that you set up a
The supported operating sytems for developing this project are:

* Linux
* macOS

You need to have a supported Python version installed
(see :ref:`Supported environments`), and it is recommended that you set up a
`virtual Python environment`_.

.. _virtual Python environment: https://docs.python-guide.org/dev/virtualenvs/
Expand Down

0 comments on commit 370ca91

Please sign in to comment.