-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
190 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: 'Tests' | ||
|
||
on: [push] | ||
|
||
jobs: | ||
call_workflow: | ||
uses: ./.github/workflows/Testbase.yml | ||
with: | ||
python: '3.10' | ||
qt5: 'pyqt5' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Base | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
python: | ||
required: true | ||
type: string | ||
qt5: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
DISPLAY: ':99.0' | ||
QT_DEBUG_PLUGINS: 1 | ||
steps: | ||
- name: Set up Python ${{ inputs.python }} | ||
uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ inputs.python }} | ||
- name: Install package | ||
run: | | ||
sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils | ||
python -m pip install --upgrade pip | ||
export QT_DEBUG_PLUGINS=1 | ||
pip install flake8 pytest pytest-cov pytest-qt pytest-xdist pytest-xvfb setuptools wheel numpy h5py ${{ inputs.qt5 }} toml | ||
pip install -e . | ||
pip install pymodaq | ||
- name: create local pymodaq folder and setting permissions | ||
run: | | ||
sudo mkdir /etc/.pymodaq | ||
sudo chmod uo+rw /etc/.pymodaq | ||
- name: Linting with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=src/pymodaq/resources/QtDesigner_Ressources,docs | ||
- name: Test with pytest | ||
run: | | ||
pytest --cov=pymodaq_plugins_mock --cov-report=xml -n auto | ||
- name: Upload coverage to codecov.io | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow will upload a Python Package using Twine when a release is created | ||
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | ||
|
||
name: Upload Python Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
deploy: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine toml | ||
- name: Build and publish | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
twine upload dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ author-email = '[email protected]' | |
|
||
[plugin-install] | ||
#packages required for your plugin: | ||
packages-required = [] #list of required packages within quotes, eg: ["pyvisa", "numpy==1.19.3"] ... | ||
packages-required = ['pymodaq>4.0.0'] #list of required packages within quotes, eg: ["pyvisa", "numpy==1.19.3"] ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created the 17/10/2023 | ||
@author: Sebastien Weber | ||
""" | ||
import pytest | ||
from pathlib import Path | ||
import importlib | ||
import pkgutil | ||
|
||
|
||
MANDATORY_MOVE_METHODS = ['ini_attributes', 'get_actuator_value', 'close', 'commit_settings', | ||
'ini_stage', 'move_abs', 'move_home', 'move_rel', 'stop_motion'] | ||
MANDATORY_VIEWER_METHODS = ['ini_attributes', 'grab_data', 'close', 'commit_settings', | ||
'ini_detector', ] | ||
|
||
|
||
def get_package_name(): | ||
here = Path(__file__).parent | ||
package_name = here.parent.stem | ||
return package_name | ||
|
||
|
||
def get_move_plugins(): | ||
pkg_name = get_package_name() | ||
move_mod = importlib.import_module(f'{pkg_name}.daq_move_plugins') | ||
|
||
plugin_list = [mod for mod in [mod[1] for mod in | ||
pkgutil.iter_modules([str(move_mod.path.parent)])] | ||
if 'daq_move_' in mod] | ||
return plugin_list, move_mod | ||
|
||
|
||
def get_viewer_plugins(dim='0D'): | ||
pkg_name = get_package_name() | ||
viewer_mod = importlib.import_module(f'{pkg_name}.daq_viewer_plugins.plugins_{dim}') | ||
|
||
plugin_list = [mod for mod in [mod[1] for mod in | ||
pkgutil.iter_modules([str(viewer_mod.path.parent)])] | ||
if f'daq_{dim}viewer_' in mod] | ||
return plugin_list, viewer_mod | ||
|
||
|
||
def test_package_name_ok(): | ||
assert 'pymodaq_plugins_' in get_package_name()[0:16] | ||
|
||
|
||
def test_imports(): | ||
pkg_name = get_package_name() | ||
mod = importlib.import_module(pkg_name) | ||
assert hasattr(mod, 'config') | ||
assert hasattr(mod, '__version__') | ||
move_mod = importlib.import_module(f'{pkg_name}', 'daq_move_plugins') | ||
importlib.import_module(f'{pkg_name}', 'daq_viewer_plugins') | ||
importlib.import_module(f'{pkg_name}', 'extensions') | ||
importlib.import_module(f'{pkg_name}', 'models') | ||
importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_0D') | ||
importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_1D') | ||
importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_2D') | ||
importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_ND') | ||
|
||
|
||
def test_move_inst_plugins_name(): | ||
plugin_list, move_mod = get_move_plugins() | ||
for plug in plugin_list: | ||
name = plug.split('daq_move_')[1] | ||
assert hasattr(getattr(move_mod, plug), f'DAQ_Move_{name}') | ||
|
||
|
||
@pytest.mark.parametrize('dim', ('0D', '1D', '2D', 'ND')) | ||
def test_viewer_inst_plugins_name(dim): | ||
plugin_list, viewer_mod = get_viewer_plugins(dim) | ||
for plug in plugin_list: | ||
name = plug.split(f'daq_{dim}viewer_')[1] | ||
assert hasattr(getattr(viewer_mod, plug), f'DAQ_{dim}Viewer_{name}') | ||
|
||
|
||
def test_move_has_mandatory_methods(): | ||
plugin_list, move_mod = get_move_plugins() | ||
for plug in plugin_list: | ||
name = plug.split('daq_move_')[1] | ||
klass = getattr(getattr(move_mod, plug), f'DAQ_Move_{name}') | ||
for meth in MANDATORY_MOVE_METHODS: | ||
assert hasattr(klass, meth) | ||
|
||
|
||
@pytest.mark.parametrize('dim', ('0D', '1D', '2D', 'ND')) | ||
def test_viewer_has_mandatory_methods(dim): | ||
plugin_list, mod = get_viewer_plugins(dim) | ||
for plug in plugin_list: | ||
name = plug.split(f'daq_{dim}viewer_')[1] | ||
klass = getattr(getattr(mod, plug), f'DAQ_{dim}Viewer_{name}') | ||
for meth in MANDATORY_VIEWER_METHODS: | ||
assert hasattr(klass, meth) |