Skip to content

Commit

Permalink
Merge pull request #67 from fusion-energy/examples_with_ga
Browse files Browse the repository at this point in the history
Added new workflow to test examples
  • Loading branch information
shimwell committed Aug 25, 2021
2 parents 6037dec + 8bcbe7b commit 6dc9ef2
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 56 deletions.
15 changes: 0 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,6 @@ jobs:
command:
pytest tests/test_parametric_reactors/ -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml

- run:
name: run example shape tests
command:
pytest tests/test_example_shapes.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml

- run:
name: run example component tests
command:
pytest tests/test_example_components.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml

- run:
name: run example reactor tests
command:
pytest --capture=tee-sys tests/test_example_reactors.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml

- store_test_results:
path: test-reports

Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/test_demos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test demos

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container:
image: ghcr.io/fusion-energy/paramak:dependencies
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup paramak
run: |
python3 setup.py develop
- name: Run the notebooks shapes
run: |
python3 tests/test_example_shapes.py
- name: Run the notebooks components
run: |
python3 tests/test_example_components.py
- name: Run the notebooks reactors
run: |
python3 tests/test_example_reactors.py
6 changes: 3 additions & 3 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ pytest tests/test_h5m_export.py -v --cov=paramak --cov-append --cov-report term
pytest tests/test_parametric_shapes/ -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests/test_parametric_components/ -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests/test_parametric_reactors/ -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests/test_example_shapes.py -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests/test_example_components.py -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests/test_example_reactors.py -v --cov=paramak --cov-append --cov-report term --cov-report xml
python tests/test_example_shapes.py
python tests/test_example_components.py
python tests/test_example_reactors.py
17 changes: 7 additions & 10 deletions tests/test_example_components.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@

import os
import sys
import unittest
from pathlib import Path

from .notebook_testing import notebook_run
from notebook_testing import notebook_run

sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'examples'))


class TestExampleComponents(unittest.TestCase):

def test_jupyter_notebooks_example_parametric_components(self):
for notebook in Path().rglob("examples/example_parametric_components/*.ipynb"):
print(notebook)
errors = notebook_run(notebook)
assert errors == []
def main():
for notebook in Path().rglob("examples/example_parametric_components/*.ipynb"):
print(notebook)
errors = notebook_run(notebook)
assert errors == []


if __name__ == "__main__":
unittest.main()
main()
33 changes: 15 additions & 18 deletions tests/test_example_reactors.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@

import os
import sys
import unittest
from pathlib import Path
import time
from .notebook_testing import notebook_run
from notebook_testing import notebook_run

sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'examples'))


class TestExampleReactors(unittest.TestCase):
def main():
timings = []
for notebook in Path().rglob("examples/example_parametric_reactors/*.ipynb"):
start = time.time()

def test_jupyter_notebooks_example_parametric_reactors(self):
timings = []
for notebook in Path().rglob("examples/example_parametric_reactors/*.ipynb"):
start = time.time()
print(notebook)
errors = notebook_run(notebook)
assert errors == []

print(notebook)
errors = notebook_run(notebook)
assert errors == []
stop = time.time()
duration = stop - start

stop = time.time()
duration = stop - start
print((notebook, duration))
timings.append((notebook, duration))

print((notebook, duration))
timings.append((notebook, duration))

# to see timings run with pytest --capture=tee-sys
print(timings)
# to see timings run with pytest --capture=tee-sys
print(timings)


if __name__ == "__main__":
unittest.main()
main()
17 changes: 7 additions & 10 deletions tests/test_example_shapes.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@

import os
import sys
import unittest
from pathlib import Path

from .notebook_testing import notebook_run
from notebook_testing import notebook_run

sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'examples'))


class TestExampleShapes(unittest.TestCase):

def test_jupyter_notebooks_example_parametric_shapes(self):
for notebook in Path().rglob("examples/example_parametric_shapes/*.ipynb"):
print(notebook)
errors = notebook_run(notebook)
assert errors == []
def main():
for notebook in Path().rglob("examples/example_parametric_shapes/*.ipynb"):
print(notebook)
errors = notebook_run(notebook)
assert errors == []


if __name__ == "__main__":
unittest.main()
main()

0 comments on commit 6dc9ef2

Please sign in to comment.