Skip to content

Commit

Permalink
Merge pull request #416 from mpsonntag/deptests
Browse files Browse the repository at this point in the history
Add dependent library release test scripts
  • Loading branch information
jgrewe committed Feb 10, 2023
2 parents 7591c07 + 62f99b6 commit a5e6f12
Show file tree
Hide file tree
Showing 31 changed files with 10,795 additions and 6 deletions.
105 changes: 100 additions & 5 deletions .github/workflows/run-tests.yml
Expand Up @@ -8,12 +8,86 @@ on:
branches:
- master
jobs:
tests:
linux_tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python setup.py install
pip install -r requirements-test.txt
- name: Run tests
run: pytest
# The default Linux Ubuntu 22+ does not support Python < 3.8 any longer
# To keep testing Python < 3.8, use Ubuntu 20
linux_legacy_tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ["3.6", "3.7"]
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python setup.py install
pip install -r requirements-test.txt
- name: Run tests
run: pytest
mac_tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
# github actions currently resolves the pyyaml pip install package
# for python 3.9 not to the required macos package, but to the
# default pyyaml 6.0.tar package, which is a linux distribution
# and fails on install. MacOS Python version 3.9 build will stay
# disabled until this is resolved.
#python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.6", "3.7", "3.8", "3.10"]
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python setup.py install
pip install -r requirements-test.txt
- name: Run tests
run: pytest
# The current rdflib dependency causes random issues on some of
# the github actions windows builds; since the appveyor builds
# are passing without any issue, keep most gh actions windows
# builds deactivated until the rdflib dependency has been
# been updated.
win_tests:
continue-on-error: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand All @@ -32,10 +106,10 @@ jobs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Setup Python 3.8
- name: Setup Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "3.10"
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
Expand All @@ -50,3 +124,24 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github
run-codecov:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Setup Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
python setup.py install
pip install -r requirements-test.txt
pip install pytest pytest-cov
- name: Create coverage
run: |
pytest --cov=./ --cov-report=xml
- uses: codecov/codecov-action@v1
with:
name: Submit Codecov coverage
files: ./coverage.xml
verbose: true # optional (default = false)
8 changes: 8 additions & 0 deletions appveyor.yml
Expand Up @@ -17,6 +17,10 @@ environment:
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYVER: 3
BITS: 32
- PYTHON: "C:\\Python310"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYVER: 3
BITS: 32
- PYTHON: "C:\\Python36-x64"
PYVER: 3
BITS: 64
Expand All @@ -30,6 +34,10 @@ environment:
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYVER: 3
BITS: 64
- PYTHON: "C:\\Python310-x64"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYVER: 3
BITS: 64

init:
- "ECHO %PYTHON% %vcvars% (%bits%)"
Expand Down
2 changes: 1 addition & 1 deletion odml/info.json
Expand Up @@ -2,7 +2,7 @@
"VERSION": "1.5.2",
"FORMAT_VERSION": "1.1",
"AUTHOR": "Hagen Fritsch, Jan Grewe, Christian Kellner, Achilleas Koutsou, Michael Sonntag, Lyuba Zehl",
"COPYRIGHT": "(c) 2011-2021, German Neuroinformatics Node",
"COPYRIGHT": "(c) 2011-2023, German Neuroinformatics Node",
"CONTACT": "dev@g-node.org",
"HOMEPAGE": "https://github.com/G-Node/python-odml",
"CLASSIFIERS": [
Expand Down
6 changes: 6 additions & 0 deletions scripts/README.md
@@ -0,0 +1,6 @@
## python-odml convenience scripts

This folder contains convenience scripts for build and deployment tests and should not be part of any release. Check the README files in the specific folders for details.

The `release_tests` folder contains scripts and resources to test the odML library and all its dependent libraries like odmltools, odmlui, odmlconverter and nix-odml-converter from a local odML installation, from Test-PyPI and PyPI packages.
The local version tests the installation via `pip install .` and `python setup.py install`. The Test-PyPI and PyPI package tests use conda environments to test the installation with all Python versions >= 3.5.
91 changes: 91 additions & 0 deletions scripts/release_tests/README.md
@@ -0,0 +1,91 @@
# odml and odml dependent libraries installation tests

Used to document the minimal automated tests for `python-odml` and `odmltools` and not fully automated tests of `odml-ui` installations with a special focus on the execution of command line scripts and gui with different local installation methods.

## Automated odml and dependent library tests

The tests include
- basic odml import and file loading and saving
- `odml` command line script execution using realistic example files
- odmlview
- odmltordf
- odmlconversion
- `odmltools` command line script execution
- odmlimportdatacite
- basic odml-ui installation

### Local installation tests

To test the various local installations of odml, execute `run_test_matrix.sh` with option 'A'. odml will be installed into fresh conda environments using `pip install .` and `python setup.py install` and all Python versions >= 3.5.

### odml PyPI TEST installation tests

To test the installation of the odml package from the PyPI TEST repository, execute `run_test_matrix.sh` with option 'B'. odml will be installed into fresh conda environments using `pip install odml` and all Python versions >= 3.5.
The package `odml-ui` will be installed as well and all installable odml command line scripts will be tested after the odml installation.

### odmltools PyPI server installation tests

When executing `run_test_matrix.sh` with option 'C', the odml dependent package `odmltools` will be pip installed into fresh conda environments for all Python versions >= 3.6 from the PyPI TEST repository and appropriate conversion tests will be run using the installed command line tool.

### nixodmlconverter PyPI TEST installation tests

When executing `run_test_matrix.sh` with option 'D' the odml dependent package `nixodmlconverter` will be pip installed into fresh conda environments for all Python versions >= 3.6 from the PyPI TEST repository and appropriate conversion tests will be run using the installed command line tool.

### odml PyPI LIVE installation tests

To test the installation of the odml package from PyPI proper, execute `run_test_matrix.sh` with option 'E'. odml will be installed into fresh conda environments using `pip install odml` and all Python versions >= 3.5.
The package `odml-ui` will be installed as well and all installable odml command line scripts will be tested after the odml installation.

## Manual odml-ui tests

To set up conda environments and run local or PyPI TEST installations run the script `run_test_matrix.sh` with option `B` from the current directory.
Once set up, the conda environments can be used to manually test `odml-ui` as well.

Activate python installation environment

CONDA_ENV_SETUP=pyinst
CONDA_ENV_PIP=pipinst
ROOT_DIR=$(pwd)
cd $ROOT_DIR/resources/test_load
conda activate ${CONDA_ENV_SETUP}
odmlui

Run the following most tests:
- open `test_load\load_v1.odml.xml`
- check fail message
- import `test_load\load_v1.odml.xml`
- save as `pyi_conv.xml`
- save as `pyi_conv.yaml`
- save as `pyi_conv.json`
- open `pyi_conv.xml`
- open `pyi_conv.yaml`
- open `pyi_conv.json`
- check importing a terminology using the document wizard

Exit and switch to pip environment

conda deactivate
conda activate ${CONDA_ENV_PIP}
odmlui

Run manual tests again

Test odmltables plugin

pip install odmltables
pip install odmltables[gui]
odmlui

Run the following minimal tests
- open `pyi_conv.xml`
- use odmltables `convert` button, save as csv file
- use odmltables `filter` button

Exit, move back to the root and cleanup

cd $ROOT_DIR
conda deactivate
rm $ROOT_DIR/resources/test_load/load_v1.odml_converted.xml
rm $ROOT_DIR/resources/test_load/pyi_conv.json
rm $ROOT_DIR/resources/test_load/pyi_conv.xml
rm $ROOT_DIR/resources/test_load/pyi_conv.yaml
62 changes: 62 additions & 0 deletions scripts/release_tests/resources/scripts/odml_basics.py
@@ -0,0 +1,62 @@
import sys
import unittest

try:
# Test possible imports of all parsers without importing the full odML package
from odml.tools import ODMLReader, ODMLWriter, RDFReader, RDFWriter
from odml.tools.converters import FormatConverter, VersionConverter
from odml.tools import XMLReader, XMLWriter, DictReader, DictWriter

import odml
except Exception as exc:
print("-- Failed on an import: %s" % exc)
sys.exit(-1)


class TestODMLBasics(unittest.TestCase):

def test_load(self):
print("-- Load odml xml file")
xdoc = odml.load('./load.odml.xml')
print(xdoc.pprint())

print("-- Load odml json file")
jdoc = odml.load('./load.odml.json', 'JSON')
self.assertEqual(xdoc, jdoc)

print("-- Load odml yaml file")
ydoc = odml.load('./load.odml.yaml', 'YAML')
self.assertEqual(xdoc, ydoc)

print("-- Document loading tests success")

def test_version_load(self):
print("-- Test invalid version exception xml file load")
with self.assertRaises(odml.tools.parser_utils.InvalidVersionException):
_ = odml.load('./load_v1.odml.xml')
print("-- Invalid version loading test success")

def test_tools_init(self):
_ = ODMLReader()
_ = ODMLWriter()
_ = RDFReader()
_ = RDFWriter([odml.Document()])
_ = FormatConverter()
_ = VersionConverter("/I/do/not/exist.txt")
_ = XMLReader()
_ = XMLWriter(odml.Document())
_ = DictReader()
_ = DictWriter()


if __name__ == "__main__":
try:
svi = sys.version_info
print("-- Using Python '%s.%s.%s'" % (svi.major, svi.minor, svi.micro))
print("-- Testing odml Version: '%s'" % odml.VERSION)

unittest.main()

except Exception as exc:
print("-- Failed on a test: %s" % exc)
sys.exit(-1)

0 comments on commit a5e6f12

Please sign in to comment.