Skip to content

Commit

Permalink
Merge pull request #134 from tcalmant/ci-test
Browse files Browse the repository at this point in the history
Added CI with GitHub actions
  • Loading branch information
tcalmant authored Aug 22, 2024
2 parents c55179d + d34d41d commit 688f820
Show file tree
Hide file tree
Showing 19 changed files with 250 additions and 161 deletions.
2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI Build

on:
push:
branches: [v1, v2, v3, ci-test]
pull_request:
branches: [v1, v2, v3]
workflow_dispatch:

jobs:
test:
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Use JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest coverage coverage_enable_subprocess coveralls
pip install -r requirements.txt
- name: Start test infrastructure
run: |
find tests-infra -name compose.yaml -exec docker compose -f {} up -d \;
- name: Run unit tests
run: |
coverage run -m pytest tests
coverage combine
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: python-${{ matrix.python-version }}
parallel: true

finish:
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
47 changes: 0 additions & 47 deletions .travis.yml

This file was deleted.

14 changes: 5 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
iPOPO: A Service-Oriented Component Model for Python
####################################################

.. image:: https://badges.gitter.im/Join%20Chat.svg
:alt: Join the chat at https://gitter.im/tcalmant/ipopo
:target: https://gitter.im/tcalmant/ipopo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

.. image:: https://img.shields.io/pypi/v/ipopo.svg
:target: https://pypi.python.org/pypi/ipopo/
:alt: Latest Version
Expand All @@ -19,12 +15,12 @@ iPOPO: A Service-Oriented Component Model for Python
:target: https://pypi.python.org/pypi/ipopo/
:alt: License

.. image:: https://travis-ci.org/tcalmant/ipopo.svg?branch=master
:target: https://travis-ci.org/tcalmant/ipopo
:alt: Travis-CI status
.. image:: https://github.com/tcalmant/ipopo/actions/workflows/ci-build.yml/badge.svg?branch=v3
:target: https://github.com/tcalmant/ipopo/actions/workflows/ci-build.yml
:alt: GitHub Actions CI status

.. image:: https://coveralls.io/repos/github/tcalmant/ipopo/badge.svg?branch=master
:target: https://coveralls.io/github/tcalmant/ipopo?branch=master
.. image:: https://coveralls.io/repos/github/tcalmant/ipopo/badge.svg?branch=v3
:target: https://coveralls.io/github/tcalmant/ipopo?branch=v3
:alt: Coveralls status

`iPOPO <https://ipopo.readthedocs.io/>`_ is a Python-based Service-Oriented
Expand Down
4 changes: 2 additions & 2 deletions pelix/rsa/remoteserviceadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import sys
import threading
from datetime import datetime
from distutils.util import strtobool
from traceback import print_exception
from typing import IO, Any, Dict, List, Optional, Protocol, Set, Tuple, Union, cast

Expand Down Expand Up @@ -88,6 +87,7 @@
ImportContainer,
ImportDistributionProvider,
)
from pelix.utilities import str2bool

# ------------------------------------------------------------------------------
# Module version
Expand Down Expand Up @@ -134,7 +134,7 @@ def start(self, context: BundleContext) -> None:
if not debug_str:
debug_str = DEBUG_PROPERTY_DEFAULT

if strtobool(debug_str):
if str2bool(debug_str):
self._debug_reg = self._context.register_service(
RemoteServiceAdminListener,
DebugRemoteServiceAdminListener(),
Expand Down
15 changes: 15 additions & 0 deletions pelix/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,3 +620,18 @@ def wait(self, timeout: Optional[float] = None) -> bool:
:return: True if the event as been set, else False
"""
return self.__event.wait(timeout)


def str2bool(value: Optional[str]) -> bool:
"""
Translates a string to a boolean.
Inspired from distutils.strtobool, removed from Python 3.12
True values are "true", "yes", "y", "on" and not "1".
All other values are false.
"""
if not value:
return False

return value.lower().strip() in ("true", "yes", "y", "on", "1")
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ paho-mqtt>=2
zeroconf==0.19.1
osgiservicebridge>=1.5.6
pyyaml>=6.0
etcd3-fc>=0.12.0
etcd3>=0.12.0
30 changes: 11 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
iPOPO installation script
:author: Thomas Calmant
:copyright: Copyright 2023, Thomas Calmant
:copyright: Copyright 2024, Thomas Calmant
:license: Apache License 2.0
:version: 1.0.2
:version: 3.0.0
..
Expand All @@ -27,15 +27,12 @@

import os

try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from setuptools import setup

# ------------------------------------------------------------------------------

# Module version
__version_info__ = (1, 0, 2)
__version_info__ = (3, 0, 0)
__version__ = ".".join(str(x) for x in __version_info__)

# Documentation strings format
Expand Down Expand Up @@ -87,23 +84,18 @@ def read(fname):
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"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",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Application Frameworks",
],
install_requires=["jsonrpclib-pelix>=0.3.1"],
install_requires=["jsonrpclib-pelix>=0.4.3"],
extras_require={
"Redis": ["redis>=2.10"],
"ZooKeeper": ["kazoo>=2.4"],
"ZooKeeper": ["kazoo==2.8.0"],
"MQTT": ["paho-mqtt>=2.1"],
"XMPP": ["sleekxmpp>=1.3.1"],
"XMPP": ["slixmpp>=1.8.4"],
"zeroconf": ["zeroconf==0.19"],
"RSA": ["python-etcd>=0.4.5", "osgiservicebridge>=1.5.1"],
"RSA": ["etcd3>=0.12.0", "osgiservicebridge>=1.5.1"],
},
)
14 changes: 12 additions & 2 deletions tests/remote/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@

try:
# Try to import modules
import multiprocessing
from multiprocessing import Process, Queue

# IronPython fails when creating a queue
Queue()

# Trick to avoid pytest hanging
multiprocessing.set_start_method("spawn", force=True)
except ImportError:
# Some interpreters don't have support for multiprocessing
raise unittest.SkipTest("Interpreter doesn't support multiprocessing")
Expand Down Expand Up @@ -177,6 +181,7 @@ def export_framework(
# Stopping
state_queue.put("stopping")
framework.stop()
framework.delete()
except Exception as ex:
state_queue.put(f"Error: {ex}\n{traceback.format_exc()}")

Expand Down Expand Up @@ -277,8 +282,13 @@ def _run_test(
FrameworkFactory.delete_framework()
except:
pass
peer.terminate()
status_queue.close()

try:
peer.kill()
peer.join(5)
peer.close()
finally:
status_queue.close()

def test_multicast(self) -> None:
"""
Expand Down
13 changes: 11 additions & 2 deletions tests/remote/test_transports_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@

try:
# Try to import modules
import multiprocessing
from multiprocessing import Process, Queue

# IronPython fails when creating a queue
Queue()

# Trick to avoid pytest hanging
multiprocessing.set_start_method("spawn", force=True)
except ImportError:
# Some interpreters don't have support for multiprocessing
raise unittest.SkipTest("Interpreter doesn't support multiprocessing")
Expand Down Expand Up @@ -183,6 +187,7 @@ def export_framework(state_queue: Queue, transport: str, components: Iterable[Tu
# Stopping
state_queue.put("stopping")
framework.stop()
framework.delete()
except Exception as ex:
state_queue.put(f"Error: {ex}")

Expand Down Expand Up @@ -320,8 +325,12 @@ def _run_test(
finally:
# Stop everything (and delete the framework in any case
FrameworkFactory.delete_framework()
peer.terminate()
status_queue.close()
try:
peer.kill()
peer.join(5)
peer.close()
finally:
status_queue.close()

def test_xmlrpc(self) -> None:
"""
Expand Down
6 changes: 5 additions & 1 deletion tests/remote/test_transports_https.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@

try:
# Try to import modules
import multiprocessing
from multiprocessing import Process, Queue

# IronPython fails when creating a queue
Queue()

# Trick to avoid pytest hanging
multiprocessing.set_start_method("spawn", force=True)
except ImportError:
# Some interpreters don't have support for multiprocessing
raise unittest.SkipTest("Interpreter doesn't support multiprocessing")
Expand Down Expand Up @@ -149,7 +153,7 @@ def export_framework(state_queue: Queue, transport: str, components: Iterable[Tu
# Stopping
state_queue.put("stopping")
framework.stop()

framework.delete()
except Exception as ex:
state_queue.put("Error: {0}".format(ex))
finally:
Expand Down
13 changes: 11 additions & 2 deletions tests/remote/test_transports_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@

try:
# Try to import modules
import multiprocessing
from multiprocessing import Process, Queue

# IronPython fails when creating a queue
Queue()

# Trick to avoid pytest hanging
multiprocessing.set_start_method("spawn", force=True)
except ImportError:
# Some interpreters don't have support for multiprocessing
raise unittest.SkipTest("Interpreter doesn't support multiprocessing")
Expand Down Expand Up @@ -188,6 +192,7 @@ def export_framework(
# Stopping
state_queue.put("stopping")
framework.stop()
framework.delete()
except Exception as ex:
state_queue.put(f"Error: {ex}")

Expand Down Expand Up @@ -320,8 +325,12 @@ def __run_test(
finally:
# Stop everything (and delete the framework in any case
FrameworkFactory.delete_framework()
peer.terminate()
status_queue.close()
try:
peer.kill()
peer.join(5)
peer.close()
finally:
status_queue.close()

def test_mqttrpc(self) -> None:
"""
Expand Down
Loading

0 comments on commit 688f820

Please sign in to comment.