-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(versioning): Fixed how versioning is done in all cases, and made …
…tests more robust. Made test for versioning system.
- Loading branch information
Showing
5 changed files
with
49 additions
and
7 deletions.
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 |
---|---|---|
|
@@ -54,30 +54,33 @@ jobs: | |
with: | ||
python-version: ${{ matrix.python-version }} | ||
- run: pip install --user . montepy[test] | ||
- run: pip install --user . montepy[build] | ||
- run: coverage run -m pytest --junitxml=test_report.xml | ||
- run: coverage report | ||
if: ${{ success() || failure() }} | ||
- run: coverage xml | ||
if: ${{ success() || failure() }} | ||
- name: Upload test report | ||
if: ${{ matrix.python-version == '3.9' }} | ||
if: ${{ matrix.python-version == '3.9' && (success() || failure() )}} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test | ||
path: test_report.xml | ||
- name: Upload coverage report | ||
if: ${{ matrix.python-version == '3.9' }} | ||
if: ${{ matrix.python-version == '3.9' && (success() || failure() )}} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage | ||
path: coverage.xml | ||
- name: Test Reporter | ||
if: ${{ matrix.python-version == '3.9' }} | ||
if: ${{ matrix.python-version == '3.9' && (success() || failure() )}} | ||
uses: dorny/[email protected] | ||
with: | ||
name: CI-test-report | ||
path: test_report.xml | ||
reporter: java-junit | ||
- name: Coveralls GitHub Action | ||
if: ${{ matrix.python-version == '3.9' }} | ||
if: ${{ matrix.python-version == '3.9' && (success() || failure() )}} | ||
uses: coverallsapp/[email protected] | ||
with: | ||
file: coverage.xml | ||
|
@@ -92,7 +95,7 @@ jobs: | |
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- run: pip install . montepy[doc] | ||
- run: pip install . montepy[doc,build] | ||
- run: sphinx-build doc/source/ doc/build/ -W --keep-going -E | ||
- run: sphinx-build -b html doc/source/ doc/build/html | ||
- uses: actions/upload-artifact@v3 | ||
|
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 @@ | ||
exclude tests/test_version.py |
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
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,38 @@ | ||
import importlib | ||
import os | ||
import sys | ||
from unittest import TestCase | ||
|
||
|
||
class TestVersion(TestCase): | ||
def test_version(self): | ||
self.assertTrue(os.path.exists(os.path.join("montepy", "_version.py"))) | ||
# Test without version.py | ||
try: | ||
# try without setuptools_scm | ||
old_file = os.path.join("montepy", "_version.py") | ||
new_file = os.path.join("montepy", "_version.bak") | ||
os.rename(old_file, new_file) | ||
# clear out previous imports | ||
to_delete = set() | ||
for mod in sys.modules: | ||
for bad_mod in ["setuptools_scm", "montepy"]: | ||
if bad_mod in mod: | ||
to_delete.add(mod) | ||
for mod in to_delete: | ||
del sys.modules[mod] | ||
sys.modules["setuptools_scm"] = None | ||
import montepy | ||
|
||
self.assertEqual(montepy.__version__, "Undefined") | ||
# try with setuptools_scm | ||
del sys.modules["setuptools_scm"] | ||
importlib.reload(montepy) | ||
print(f"From setuptools_scm: {montepy.__version__}") | ||
self.assertTrue(len(montepy.__version__.split(".")) >= 3) | ||
finally: | ||
os.rename(new_file, old_file) | ||
# do base with _version | ||
importlib.reload(montepy) | ||
print(f"From _version.py: {montepy.__version__}") | ||
self.assertTrue(len(montepy.__version__.split(".")) >= 3) |