File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 29
29
python -m pip install --upgrade pip
30
30
python -m pip install requests==2.31.0
31
31
python -m pip install bandit==1.7.7
32
+ python -m pip install packaging
32
33
python -m pip install .[test]
33
34
35
+ - name : Check for prerelease dependencies
36
+ run : python scripts/check_for_prereleases.py
37
+
34
38
- name : Generate release notes
35
39
env :
36
40
GH_ACCESS_TOKEN : ${{ secrets.GH_ACCESS_TOKEN }}
Original file line number Diff line number Diff line change
1
+ """Script that checks project requirements for pre-release versions."""
2
+
3
+ from pathlib import Path
4
+
5
+ import tomllib
6
+ from packaging .requirements import Requirement
7
+
8
+
9
+ def get_dev_dependencies (dependency_list ):
10
+ """Return list of dependencies with prerelease specifiers."""
11
+ prereleases = []
12
+ for dependency in dependency_list :
13
+ requirement = Requirement (dependency )
14
+ if requirement .specifier .prereleases or requirement .url :
15
+ prereleases .append (dependency )
16
+
17
+ return prereleases
18
+
19
+
20
+ if __name__ == '__main__' :
21
+ folder = Path (__file__ ).parent
22
+ toml_path = folder .joinpath ('..' , 'pyproject.toml' )
23
+
24
+ with open (toml_path , 'rb' ) as f :
25
+ pyproject = tomllib .load (f )
26
+
27
+ dependencies = pyproject ['project' ]['dependencies' ]
28
+ optional_dependencies = pyproject ['project' ].get ('optional-dependencies' , {})
29
+ for dependency_list in optional_dependencies .values ():
30
+ dependencies .extend (dependency_list )
31
+ dev_deps = get_dev_dependencies (dependencies )
32
+
33
+ if dev_deps :
34
+ raise RuntimeError (f'Found dev dependencies: { ", " .join (dev_deps )} ' )
Original file line number Diff line number Diff line change
1
+ from scripts .check_for_prereleases import get_dev_dependencies
2
+
3
+
4
+ def test_get_dev_dependencies ():
5
+ """Test get_dev_dependencies ignores regular releases."""
6
+ # Setup
7
+ dependencies = ['rdt>=1.1.1' , 'sdv>=1.0.2' ]
8
+
9
+ # Run
10
+ dev_dependencies = get_dev_dependencies (dependency_list = dependencies )
11
+
12
+ # Assert
13
+ assert len (dev_dependencies ) == 0
14
+
15
+
16
+ def test_get_dev_dependencies_prereleases ():
17
+ """Test get_dev_dependencies detects prereleases."""
18
+ # Setup
19
+ dependencies = ['rdt>=1.1.1.dev0' , 'sdv>=1.0.2.rc1' ]
20
+
21
+ # Run
22
+ dev_dependencies = get_dev_dependencies (dependency_list = dependencies )
23
+
24
+ # Assert
25
+ assert dev_dependencies == dependencies
26
+
27
+
28
+ def test_get_dev_dependencies_url ():
29
+ """Test get_dev_dependencies detects url requirements."""
30
+ # Setup
31
+ dependencies = ['rdt>=1.1.1' , 'sdv @ git+https://github.com/sdv-dev/sdv.git@main' ]
32
+
33
+ # Run
34
+ dev_dependencies = get_dev_dependencies (dependency_list = dependencies )
35
+
36
+ # Assert
37
+ assert dev_dependencies == ['sdv @ git+https://github.com/sdv-dev/sdv.git@main' ]
You can’t perform that action at this time.
0 commit comments