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

ci: generic make test #1173

Merged
merged 3 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 2 additions & 6 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,13 @@ jobs:
steps:
- run: sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- run: sudo make nox session=linux-python3.6
- run: sudo make nox session=linux-python3.8
- run: sudo make nox session=linux-python3.10
- run: sudo make nox session=linux-python3.12
- run: sudo make nox session=linux
linux-ubuntu-22:
runs-on: linux-ubuntu-22
steps:
- run: sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- run: sudo make nox session=linux-python3.6
- run: sudo make nox session=linux-python3.10
- run: sudo make nox session=linux
openbsd:
runs-on: OpenBSD
steps:
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
#
python ?= $(shell util/find_python.sh)
platform := $(shell uname -s)

define nox
{\
Expand Down Expand Up @@ -68,7 +69,13 @@ format:

.PHONY: test
test:
ifeq ($(platform), Linux)
$(call nox,)
else ifeq ($(platform), OpenBSD)
$(call nox,-e openbsd)
else
$(info >> Platform not supported)
endif

.PHONY: test-platform
test-platform:
Expand Down
63 changes: 25 additions & 38 deletions README.contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,55 +16,45 @@ Linux
# git
# python
# GNU make, sed, awk
#
# then clone the repo

# clone the repo
git clone ${pyroute2_git_url}
cd pyroute2

# create and activate virtualenv
python -m venv venv
. venv/bin/activate

# update pip and install nox
pip install --upgrade pip
pip install nox

# run the test cycle
nox
# run the test suite
make test

OpenBSD
+++++++

.. code-block:: sh

# install required tools
pkg_add bash git gmake gsed python
pkg_add bash git gmake gsed python rust

# clone the repo
git clone ${pyroute_git_url}
cd pyroute2

# create and activate virtualenv
python3.10 -m venv venv
. venv/bin/activate

# update pip and install nox
pip install --upgrade pip
pip install nox
# run the test suite
gmake test

# run the platform specific environment
nox -e openbsd
Step 2: plan and implement the change
-------------------------------------

Step 2: make a change
---------------------
The best practice is that any change should be covered by tests.
The test suite is in the `/tests/` folder and is run by `nox`. You
can add your tests to an existing tests module, or create your
own module, if it requires some specific environment that is not
covered yet. In the latter case add a new session to `noxfile.py`.

The project is designed to work on the bare standard library.
But some embedded environments strip even the stdlib, removing
modules like sqlite3.

So to run pyroute2 even in such environments, the project provdes
So to run pyroute2 even in such environments, the project provides
two packages, `pyroute2` and `pyroute2.minimal`, with the latter
providing a minimal distribution, but using no sqlite3 or pickle.
providing a minimal distribution, with no sqlite3 or pickle.

Modules `pyroute2` and `pyroute2.minimal` are mutually exclusive.

Expand All @@ -74,18 +64,15 @@ More details: https://github.com/svinota/pyroute2/discussions/786
Step 3: test the change
-----------------------

Assume the environment is already set up on the step 1. Thus:
Assume the environment is already set up on the step 1:

.. code-block:: sh

# run code checks
nox -e linter

# run unit tests
nox -e unit
# run code linter
make format

# run functional test, some require root
nox -e linux-3.10
# run test suite, some tests may require root
make test

Step 4: submit a PR
-------------------
Expand All @@ -98,7 +85,7 @@ Requirements to a PR

The code must comply some requirements:

* the library must work on Python >= 3.6.
* the code must pass `nox -e linter`
* the code must not break existing unit and functional tests
* the `ctypes` usage must not break the library on SELinux
* the library **must** work on Python >= 3.9
* the code **must** pass `make format`
* the code **must** not break existing unit and functional tests (`make test`)
* the `ctypes` usage **must not** break the library on SELinux
7 changes: 5 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
'lab',
'neutron',
'integration',
'linux-python3.6',
'linux-python3.8',
'linux-python3.9',
'linux-python3.10',
'linux-python3.11',
'linux-python3.12',
'minimal',
]
Expand Down Expand Up @@ -245,7 +246,9 @@ def integration(session, config):
session.run(*options('test_integration', config))


@nox.session(python=['python3.6', 'python3.8', 'python3.10', 'python3.12'])
@nox.session(
python=['python3.8', 'python3.9', 'python3.10', 'python3.11', 'python3.12']
)
@add_session_config
def linux(session, config):
'''Run Linux functional tests. Requires root to run all the tests.'''
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ classifiers =
Intended Audience :: System Administrators
Intended Audience :: Telecommunications Industry
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Expand Down