Fix ensure_provider_tests.py so that the tests are correctly generated.
Because the generated tests have not been checked in a while, there was
some drift between the actual tests and what should have been generated,
so the new generated tests have also been included.
When `ensure_provider_tests.py` detects differences, it will now show
the diffs using a unified diff format.
Added a new tox testenv `ensure_provider_tests` - use
`tox -e ensure_provider_tests` to run - to pass arguments, use
`tox -e ensure_provider_tests -- generate`
Added `ensure_provider_tests` as one of the tox testenvs to run for
github tox CI.
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
Automation Hub, and possibly Galaxy in the future, require the
collection to be screened with `ansible-test sanity` among other
checks. The role had a number of issues:
* Use `AssertionError` instead of `assert`
* Use of `logging` module not in accordance with standards, but these
are ok and the errors were suppressed
* Several import errors which are ok because they are checked
elsewhere
* __init__.py in the module_utils directories must be empty, so a
new file myerror.py was added to move the code from __init__.py
* NOTE: network_lsr/nm/__init__.py is not empty
* The documentation block in the module was not properly constructed
or formatted.
* shellcheck issues, including removing unused files
* use `unused` instead of `_` (underscore) for variables that are
unused
add WARNING to module docs - collection users should not use directly
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
Use tox-lsr instead of the scripts in the `.travis/` directory and the
asssociated config files. Yes, `.travis/custom.sh` is still there,
but once you are familiar with the way that tox-lsr works, you can
remove it and use your own custom tox.ini action. The goal of this
commit was to make as few changes as possible, to keep feature parity
with the old `.travis/` script way of running CI. Also note that
linting has moved into tox, so we needed to disable molecule linting.
The new version of ansible-lint adds a lot of checks, so these are
disabled for now, and should be fixed later. Also, shellcheck is
turned off until the network team can address the issues.
The `.travis/custom.sh` script is not run in the CI environment, so
this was changed slightly to remove the check for `$TRAVIS`, and it is
no longer run as a tox testenv in CI.
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
adds a github actions tox workflow for CI testing, since
travis is discontinuing support for open source projects
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
Source commit in the template repo: e9f2c3a 4f3c96a
Merge pull request #48 from nhosoi/collections
runcollection.sh - stop passing an argument list
This change allows to eliminate the test argument list as well as the
branch name to retrieve the lsr_role2collection.py script for the
collection test.
Signed-off-by: Noriko Hosoi <nhosoi@redhat.com>
The task 56586 is for adding tests against the collection converted
format to the tox/travis CI to capture a problem before merging the
pr, if any. It'd be helpful to find out bugs in the conversion tool
lsr_role2collection.py, as well. The source of this commit is located
in linux-system-roles/template. They are synced by auto-maintenance/
sync-template.sh, then manually adjusted to the network role.
.travis/runcollection.sh is the test script. tox.ini is modified to run
it in the tox/travis CI. The script downloads lsr_role2collection.py,
then converts the network role into the conversion format in the working
directory .tox. In the collection, it runs a set of tests black, flake8,
yamllint, py38 to check the converted result.
Travis CI is using a version of Docker server that supports API version
1.38. However, the Python PYPI package `docker` version 4.3 was
recently released which uses Docker server API version 1.39, and there
is apparently no way to tell molecule to configure the `docker` Python
API to use a different API. The solution is to install the latest 4.2.x
version of the `docker` Python PYPI package.
As reported in https://github.com/tox-dev/tox-travis/issues/147, the
python factor in tox-travis needs to match the Travis python environment
and not the python version. Therefore, add a separate line.
tox supports a `[flake8]` section, so move the default
settings there rather than having them passed in on the
command line. Projects can still override flake8 arguments
by using `RUN_FLAKE8_EXTRA_ARGS` in `.travis/config.sh`
Signed-off-by: Till Maas <opensource@till.name>
Removed `mock` from the `testenv` `deps`.
Added `mock` to the template pytest_extra_requirements.txt,
commented out. Projects such as network that need it can uncomment it.
These changes don't directly affect network, or don't actually
change the behavior of existing code that network uses (coveralls),
but are intended to sync with the latest template code.
Adds `LSR_PUBLISH_COVERAGE=normal` to `.travis/config.sh` because
network wants to publish coverage normally (as opposed to `strict`
or not at all).
This does not directly affect network because network has its own
solution for dealing with testing/linting module_utils code, but
it gets network to feature/code parity with the template and
other repos.
Defines a shell function in utils.sh - lsr_setup_module_utils -
that allows configuring a tox venv installed ansible to have
the repo module_utils code in the default pythonpath for the
venv, which allows testing and linting the module_utils code
without having to otherwise munge or mock the pythonpath.
Projects needing this functionality can set in `.travis/config.sh`
the variable `RUN_PYTEST_SETUP_MODULE_UTILS` to setup
module_utils/ for pytest, and `RUN_PYLINT_SETUP_MODULE_UTILS`
to setup module_utils/ for pylint.
Many of the tests and tasks invoked from `tox` would try to use
the path to the `python` executable in the tox virtualenv, and
in some cases, would try to follow the symlink if the `python`
command were a symlink, in some cases, following the symlink to
the system python, and trying to use the absolute path. This
would fail in some cases because when using the system python
with the absolute path, the python modules installed in the
tox venv could not be found. So instead, just use the `python`
command from the venv with no path.
also enable travis 3.8-dev testing, since this fix allows that
platform to work correctly.
Molecule version 3 and later needs a different configuration file for
linters. This breaks the CI. Pin molecule to version 2 for now to
fix the CI until we have a proper fix.
Support running the molecule tests against more versions of Ansible.
By typing
LSR_ANSIBLE_DEP=<ansible> LSR_MSCENARIO=<scenario> tox -e molecule
one can run molecule inside tox with <ansible> version installed
under <scenario> scenario. For example
LSR_ANSIBLE_DEP='ansible==2.7.*' LSR_MSCENARIO=foo tox -e molecule
will run molecule under scenario 'foo' and the recent Ansible 2.7
installed. `tox -e molecule` run molecule under default scenario
with the latest Ansible (from pypi) installed.
Travis runs molecule tests for Ansible 2.6, 2.7, and 2.8 installed
and under default scenario (can be overriden by user in config.sh).
Additional changes: Remove useless comment from custom.sh.
runsyspycmd.sh script runs a given command only if venv Python
matches the system Python (this prevents failing when some command
depends on binary libraries).
Also put `molecule --version` and `ansible --version` to a standalone
testenv ([testenv:molecule_version]) so a user can display molecule
and ansible version by typing `tox -e molecule_version` without
running `molecule lint`.
Pass extra molecule dependencies via file and not via environment
variable. Also add selinux as a permanent molecule dependency
(molecule needs it on selinux enabled systems to setup containers).
Prior this change, RUN_PYLINT_* environment variables set by config.sh
have effect only while running in Travis (because runtox script sets
them by including config.sh). By wrapping pylint runner with shell
script, RUN_PYLINT_* environment variables have effect also while
running tox locally.
Some system roles want not to run black on their code. This wrapper
decides whether to run black or not depending on content of config.sh.
This wrapper also allows to set patterns of files and directories via
config.sh to be processed or skipped by black.
Not every system role contains parts written in Python, which
confuses pytest. With a shell wrapper around pytest, pytest
can be skipped or run with adjusted parameters depending on the
content or presence of system role's specific directories.
Virtual environments names are now based on the version of Python
interpreter that is used. This prevents creation of redundant
environments, that is there will be only one[1] virtual environment
per Python interpreter, which saves the time by preventing the
installation of the same packages more than once.
[1] In Travis CI, this is easy to implement by using the
TRAVIS_PYTHON_VERSION environment variable. Locally, as there
is no information about what version of Python interpreter is
used when creating a virtual environment in tox, there may be
more virtual environments per interpreter (for example, env-3.6
and env-molecule may be both based on Python 3.6).
Add run_pylint.py that probe working directory for python source files
and pass them to pylint. This is needed because pylint expects module
or package, so passing a directory with no __init__.py in it makes
pylint angry. With this change, LSR_PYLINT_DIRS is no longer needed.
Additionally, we no longer need:
- init-hook in pylintrc
- [pylintrc] section in tox.ini, because the configuration from this
section is now the part of pylintrc
- [pycodestyle] section in tox.ini, because pycodestyle linter is not
used
- use `./.travis/runtox [ARG1 [ARG2 [...[ARGn]]]]` to run tox locally
- use LSR_USE_PYTHON to decide whether to run jobs with pylinters and
pytesters or not
This commit introduces the refactored Travis CI setup and tox.ini
to fullfil the need to have common CI setup across all roles.
The current proposal and discussion can be found at:
https://github.com/linux-system-roles/template/issues/4
Fedora 30 uses tox 3 which does not work with Python 2.6 out of the box.
Setting the install and list_dependencies commands to run `pip` instead
of `python -m pip` seems to fix this for now.
- Amend and add files to run integration tests against the provider that
was not autodetected, too.
- Add check to ensure that all integration tests run against both
providers
- Run black check for all python scripts