File tree 5 files changed +84
-13
lines changed
5 files changed +84
-13
lines changed Original file line number Diff line number Diff line change
1
+ name : PR core dep module imports
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ pull_request :
8
+ branches :
9
+ - main
10
+ paths :
11
+ - " aeon/**"
12
+ - " .github/workflows/**"
13
+ - " pyproject.toml"
14
+
15
+ concurrency :
16
+ group : ${{ github.workflow }}-${{ github.head_ref || github.ref }}
17
+ cancel-in-progress : true
18
+
19
+ jobs :
20
+ test-core-imports :
21
+ runs-on : ubuntu-22.04
22
+
23
+ steps :
24
+ - name : Checkout
25
+ uses : actions/checkout@v4
26
+
27
+ - name : Setup Python 3.10
28
+ uses : actions/setup-python@v5
29
+ with :
30
+ python-version : " 3.10"
31
+
32
+ - name : Install aeon and dependencies
33
+ uses : nick-fields/retry@v3
34
+ with :
35
+ timeout_minutes : 30
36
+ max_attempts : 3
37
+ command : python -m pip install .
38
+
39
+ - name : Show dependencies
40
+ run : python -m pip list
41
+
42
+ - name : Run import test
43
+ run : python aeon/testing/tests/test_core_imports.py
Original file line number Diff line number Diff line change 9
9
path : .
10
10
extra_requirements :
11
11
- docs
12
- - dev
13
12
14
13
build :
15
14
os : ubuntu-22.04
Original file line number Diff line number Diff line change 1
- """Tests for the aeon package and testing module utiltiies."""
1
+ """Tests for the aeon package and testing module utilties."""
2
+
3
+ import pkgutil
4
+
5
+ import aeon
6
+
7
+ # collect all modules
8
+ ALL_AEON_MODULES = pkgutil .walk_packages (aeon .__path__ , aeon .__name__ + "." )
9
+ ALL_AEON_MODULES = [x [1 ] for x in ALL_AEON_MODULES ]
10
+
11
+ ALL_AEON_MODULES_NO_TESTS = [
12
+ x for x in ALL_AEON_MODULES if not any (part == "tests" for part in x .split ("." ))
13
+ ]
Original file line number Diff line number Diff line change
1
+ """Tests that non-core dependencies are handled correctly in modules."""
2
+
3
+ import re
4
+ from importlib import import_module
5
+
6
+ from aeon .testing .tests import ALL_AEON_MODULES_NO_TESTS
7
+
8
+ if __name__ == "__main__" :
9
+ """Test imports in aeon modules with core dependencies only.
10
+
11
+ Imports all modules and catch exceptions due to missing dependencies.
12
+ """
13
+ for module in ALL_AEON_MODULES_NO_TESTS :
14
+ try :
15
+ import_module (module )
16
+ except ModuleNotFoundError as e : # pragma: no cover
17
+ dependency = "unknown"
18
+ match = re .search (r"\'(.+?)\'" , str (e ))
19
+ if match :
20
+ dependency = match .group (1 )
21
+
22
+ raise ModuleNotFoundError (
23
+ f"The module: { module } should not require any non-core dependencies, "
24
+ f"but tried importing: '{ dependency } '. Make sure non-core dependencies "
25
+ f"are properly isolated outside of tests/ directories."
26
+ ) from e
Original file line number Diff line number Diff line change 1
1
"""Tests that soft dependencies are handled correctly in modules."""
2
2
3
- __maintainer__ = []
4
-
5
- import pkgutil
6
3
import re
7
4
from importlib import import_module
8
5
9
6
import pytest
10
7
11
- import aeon
12
8
from aeon .testing .testing_config import PR_TESTING
9
+ from aeon .testing .tests import ALL_AEON_MODULES , ALL_AEON_MODULES_NO_TESTS
13
10
14
- # collect all modules
15
- modules = pkgutil .walk_packages (aeon .__path__ , aeon .__name__ + "." )
16
- modules = [x [1 ] for x in modules ]
17
-
18
- if PR_TESTING : # pragma: no cover
19
- # exclude test modules
20
- modules = [x for x in modules if not any (part == "tests" for part in x .split ("." ))]
11
+ modules = ALL_AEON_MODULES_NO_TESTS if PR_TESTING else ALL_AEON_MODULES
21
12
22
13
23
14
def test_module_crawl ():
You can’t perform that action at this time.
0 commit comments