Skip to content

Commit a5e6f12

Browse files
authored
Merge pull request #416 from mpsonntag/deptests
Add dependent library release test scripts
2 parents 7591c07 + 62f99b6 commit a5e6f12

31 files changed

+10795
-6
lines changed

.github/workflows/run-tests.yml

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,86 @@ on:
88
branches:
99
- master
1010
jobs:
11-
tests:
11+
linux_tests:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
os: [ubuntu-latest, macos-latest, windows-latest]
16-
python-version: [3.6, 3.7, 3.8, 3.9]
15+
os: [ubuntu-latest]
16+
python-version: ["3.8", "3.9", "3.10"]
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Setup Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Display Python version
24+
run: python -c "import sys; print(sys.version)"
25+
- name: Install dependencies
26+
run: |
27+
python setup.py install
28+
pip install -r requirements-test.txt
29+
- name: Run tests
30+
run: pytest
31+
# The default Linux Ubuntu 22+ does not support Python < 3.8 any longer
32+
# To keep testing Python < 3.8, use Ubuntu 20
33+
linux_legacy_tests:
34+
runs-on: ${{ matrix.os }}
35+
strategy:
36+
matrix:
37+
os: [ubuntu-20.04]
38+
python-version: ["3.6", "3.7"]
39+
steps:
40+
- uses: actions/checkout@v2
41+
- name: Setup Python ${{ matrix.python-version }}
42+
uses: actions/setup-python@v2
43+
with:
44+
python-version: ${{ matrix.python-version }}
45+
- name: Display Python version
46+
run: python -c "import sys; print(sys.version)"
47+
- name: Install dependencies
48+
run: |
49+
python setup.py install
50+
pip install -r requirements-test.txt
51+
- name: Run tests
52+
run: pytest
53+
mac_tests:
54+
runs-on: ${{ matrix.os }}
55+
strategy:
56+
matrix:
57+
os: [macos-latest]
58+
# github actions currently resolves the pyyaml pip install package
59+
# for python 3.9 not to the required macos package, but to the
60+
# default pyyaml 6.0.tar package, which is a linux distribution
61+
# and fails on install. MacOS Python version 3.9 build will stay
62+
# disabled until this is resolved.
63+
#python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
64+
python-version: ["3.6", "3.7", "3.8", "3.10"]
65+
steps:
66+
- uses: actions/checkout@v2
67+
- name: Setup Python ${{ matrix.python-version }}
68+
uses: actions/setup-python@v2
69+
with:
70+
python-version: ${{ matrix.python-version }}
71+
- name: Display Python version
72+
run: python -c "import sys; print(sys.version)"
73+
- name: Install dependencies
74+
run: |
75+
python setup.py install
76+
pip install -r requirements-test.txt
77+
- name: Run tests
78+
run: pytest
79+
# The current rdflib dependency causes random issues on some of
80+
# the github actions windows builds; since the appveyor builds
81+
# are passing without any issue, keep most gh actions windows
82+
# builds deactivated until the rdflib dependency has been
83+
# been updated.
84+
win_tests:
85+
continue-on-error: true
86+
runs-on: ${{ matrix.os }}
87+
strategy:
88+
matrix:
89+
os: [windows-latest]
90+
python-version: ["3.10"]
1791
steps:
1892
- uses: actions/checkout@v2
1993
- name: Setup Python ${{ matrix.python-version }}
@@ -32,10 +106,10 @@ jobs:
32106
runs-on: [ubuntu-latest]
33107
steps:
34108
- uses: actions/checkout@v2
35-
- name: Setup Python 3.8
109+
- name: Setup Python 3.10
36110
uses: actions/setup-python@v2
37111
with:
38-
python-version: "3.8"
112+
python-version: "3.10"
39113
- name: Display Python version
40114
run: python -c "import sys; print(sys.version)"
41115
- name: Install dependencies
@@ -50,3 +124,24 @@ jobs:
50124
env:
51125
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52126
run: coveralls --service=github
127+
run-codecov:
128+
runs-on: [ubuntu-latest]
129+
steps:
130+
- uses: actions/checkout@v2
131+
- name: Setup Python 3.10
132+
uses: actions/setup-python@v2
133+
with:
134+
python-version: "3.10"
135+
- name: Install dependencies
136+
run: |
137+
python setup.py install
138+
pip install -r requirements-test.txt
139+
pip install pytest pytest-cov
140+
- name: Create coverage
141+
run: |
142+
pytest --cov=./ --cov-report=xml
143+
- uses: codecov/codecov-action@v1
144+
with:
145+
name: Submit Codecov coverage
146+
files: ./coverage.xml
147+
verbose: true # optional (default = false)

appveyor.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ environment:
1717
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
1818
PYVER: 3
1919
BITS: 32
20+
- PYTHON: "C:\\Python310"
21+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
22+
PYVER: 3
23+
BITS: 32
2024
- PYTHON: "C:\\Python36-x64"
2125
PYVER: 3
2226
BITS: 64
@@ -30,6 +34,10 @@ environment:
3034
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
3135
PYVER: 3
3236
BITS: 64
37+
- PYTHON: "C:\\Python310-x64"
38+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
39+
PYVER: 3
40+
BITS: 64
3341

3442
init:
3543
- "ECHO %PYTHON% %vcvars% (%bits%)"

odml/info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"VERSION": "1.5.2",
33
"FORMAT_VERSION": "1.1",
44
"AUTHOR": "Hagen Fritsch, Jan Grewe, Christian Kellner, Achilleas Koutsou, Michael Sonntag, Lyuba Zehl",
5-
"COPYRIGHT": "(c) 2011-2021, German Neuroinformatics Node",
5+
"COPYRIGHT": "(c) 2011-2023, German Neuroinformatics Node",
66
"CONTACT": "[email protected]",
77
"HOMEPAGE": "https://github.com/G-Node/python-odml",
88
"CLASSIFIERS": [

scripts/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## python-odml convenience scripts
2+
3+
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.
4+
5+
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.
6+
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.

scripts/release_tests/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# odml and odml dependent libraries installation tests
2+
3+
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.
4+
5+
## Automated odml and dependent library tests
6+
7+
The tests include
8+
- basic odml import and file loading and saving
9+
- `odml` command line script execution using realistic example files
10+
- odmlview
11+
- odmltordf
12+
- odmlconversion
13+
- `odmltools` command line script execution
14+
- odmlimportdatacite
15+
- basic odml-ui installation
16+
17+
### Local installation tests
18+
19+
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.
20+
21+
### odml PyPI TEST installation tests
22+
23+
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.
24+
The package `odml-ui` will be installed as well and all installable odml command line scripts will be tested after the odml installation.
25+
26+
### odmltools PyPI server installation tests
27+
28+
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.
29+
30+
### nixodmlconverter PyPI TEST installation tests
31+
32+
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.
33+
34+
### odml PyPI LIVE installation tests
35+
36+
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.
37+
The package `odml-ui` will be installed as well and all installable odml command line scripts will be tested after the odml installation.
38+
39+
## Manual odml-ui tests
40+
41+
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.
42+
Once set up, the conda environments can be used to manually test `odml-ui` as well.
43+
44+
Activate python installation environment
45+
46+
CONDA_ENV_SETUP=pyinst
47+
CONDA_ENV_PIP=pipinst
48+
ROOT_DIR=$(pwd)
49+
cd $ROOT_DIR/resources/test_load
50+
conda activate ${CONDA_ENV_SETUP}
51+
odmlui
52+
53+
Run the following most tests:
54+
- open `test_load\load_v1.odml.xml`
55+
- check fail message
56+
- import `test_load\load_v1.odml.xml`
57+
- save as `pyi_conv.xml`
58+
- save as `pyi_conv.yaml`
59+
- save as `pyi_conv.json`
60+
- open `pyi_conv.xml`
61+
- open `pyi_conv.yaml`
62+
- open `pyi_conv.json`
63+
- check importing a terminology using the document wizard
64+
65+
Exit and switch to pip environment
66+
67+
conda deactivate
68+
conda activate ${CONDA_ENV_PIP}
69+
odmlui
70+
71+
Run manual tests again
72+
73+
Test odmltables plugin
74+
75+
pip install odmltables
76+
pip install odmltables[gui]
77+
odmlui
78+
79+
Run the following minimal tests
80+
- open `pyi_conv.xml`
81+
- use odmltables `convert` button, save as csv file
82+
- use odmltables `filter` button
83+
84+
Exit, move back to the root and cleanup
85+
86+
cd $ROOT_DIR
87+
conda deactivate
88+
rm $ROOT_DIR/resources/test_load/load_v1.odml_converted.xml
89+
rm $ROOT_DIR/resources/test_load/pyi_conv.json
90+
rm $ROOT_DIR/resources/test_load/pyi_conv.xml
91+
rm $ROOT_DIR/resources/test_load/pyi_conv.yaml
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import sys
2+
import unittest
3+
4+
try:
5+
# Test possible imports of all parsers without importing the full odML package
6+
from odml.tools import ODMLReader, ODMLWriter, RDFReader, RDFWriter
7+
from odml.tools.converters import FormatConverter, VersionConverter
8+
from odml.tools import XMLReader, XMLWriter, DictReader, DictWriter
9+
10+
import odml
11+
except Exception as exc:
12+
print("-- Failed on an import: %s" % exc)
13+
sys.exit(-1)
14+
15+
16+
class TestODMLBasics(unittest.TestCase):
17+
18+
def test_load(self):
19+
print("-- Load odml xml file")
20+
xdoc = odml.load('./load.odml.xml')
21+
print(xdoc.pprint())
22+
23+
print("-- Load odml json file")
24+
jdoc = odml.load('./load.odml.json', 'JSON')
25+
self.assertEqual(xdoc, jdoc)
26+
27+
print("-- Load odml yaml file")
28+
ydoc = odml.load('./load.odml.yaml', 'YAML')
29+
self.assertEqual(xdoc, ydoc)
30+
31+
print("-- Document loading tests success")
32+
33+
def test_version_load(self):
34+
print("-- Test invalid version exception xml file load")
35+
with self.assertRaises(odml.tools.parser_utils.InvalidVersionException):
36+
_ = odml.load('./load_v1.odml.xml')
37+
print("-- Invalid version loading test success")
38+
39+
def test_tools_init(self):
40+
_ = ODMLReader()
41+
_ = ODMLWriter()
42+
_ = RDFReader()
43+
_ = RDFWriter([odml.Document()])
44+
_ = FormatConverter()
45+
_ = VersionConverter("/I/do/not/exist.txt")
46+
_ = XMLReader()
47+
_ = XMLWriter(odml.Document())
48+
_ = DictReader()
49+
_ = DictWriter()
50+
51+
52+
if __name__ == "__main__":
53+
try:
54+
svi = sys.version_info
55+
print("-- Using Python '%s.%s.%s'" % (svi.major, svi.minor, svi.micro))
56+
print("-- Testing odml Version: '%s'" % odml.VERSION)
57+
58+
unittest.main()
59+
60+
except Exception as exc:
61+
print("-- Failed on a test: %s" % exc)
62+
sys.exit(-1)

0 commit comments

Comments
 (0)