diff --git a/.azure/azure-ci-build-pipeline.yaml b/.azure/azure-ci-build-pipeline.yaml index aea94807..01111290 100644 --- a/.azure/azure-ci-build-pipeline.yaml +++ b/.azure/azure-ci-build-pipeline.yaml @@ -107,11 +107,39 @@ stages: coverage html -d htmlcov -i displayName: 'Run tests and code coverage' + # Run the notebooks + - script: | + pytest --nbmake -n=auto src/primaite/notebooks --junit-xml=./notebook-tests/notebooks.xml + notebooks_exit_code=$? + pytest --nbmake -n=auto src/primaite/simulator/_package_data --junit-xml=./notebook-tests/package-notebooks.xml + package_notebooks_exit_code=$? + # Fail step if either of these do not have exit code 0 + if [ $notebooks_exit_code -ne 0 ] || [ $package_notebooks_exit_code -ne 0 ]; then + exit 1 + fi + displayName: 'Run notebooks on Linux and macOS' + condition: or(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.OS'], 'Darwin')) + + # Run notebooks + - script: | + pytest --nbmake -n=auto src/primaite/notebooks --junit-xml=./notebook-tests/notebooks.xml + set notebooks_exit_code=%ERRORLEVEL% + pytest --nbmake -n=auto src/primaite/simulator/_package_data --junit-xml=./notebook-tests/package-notebooks.xml + set package_notebooks_exit_code=%ERRORLEVEL% + rem Fail step if either of these do not have exit code 0 + if %notebooks_exit_code% NEQ 0 exit /b 1 + if %package_notebooks_exit_code% NEQ 0 exit /b 1 + displayName: 'Run notebooks on Windows' + condition: eq(variables['Agent.OS'], 'Windows_NT') + - task: PublishTestResults@2 condition: succeededOrFailed() + displayName: 'Publish Test Results' inputs: testRunner: JUnit - testResultsFiles: 'junit/**.xml' + testResultsFiles: | + 'junit/**.xml' + 'notebook-tests/**.xml' testRunTitle: 'Publish test results' failTaskOnFailedTests: true diff --git a/.gitignore b/.gitignore index e48dc5dc..140a3d0b 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,7 @@ cover/ tests/assets/**/*.png tests/assets/**/tensorboard_logs/ tests/assets/**/checkpoints/ +notebook-tests/*.xml # Translations *.mo diff --git a/pyproject.toml b/pyproject.toml index 9d53e961..a0c2e3eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,9 @@ dev = [ "Sphinx==7.1.2", "sphinx-copybutton==0.5.2", "wheel==0.38.4", - "nbsphinx==0.9.4" + "nbsphinx==0.9.4", + "nbmake==1.5.4", + "pytest-xdist==3.3.1" ] [project.scripts] diff --git a/src/primaite/notebooks/multi-processing.ipynb b/src/primaite/notebooks/multi-processing.ipynb index 86b549a7..305cfd70 100644 --- a/src/primaite/notebooks/multi-processing.ipynb +++ b/src/primaite/notebooks/multi-processing.ipynb @@ -143,7 +143,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.10.11" } }, "nbformat": 4,