From ead482ca4e08258c41a9ef2e7cc0cbd4c6933b63 Mon Sep 17 00:00:00 2001 From: Santhosh Sundaram Date: Tue, 9 Jul 2024 23:56:22 +0530 Subject: [PATCH] added doc test for build --- .github/workflows/test_on_push.yml | 27 +++++++++++++++++++++++++++ noxfile.py | 15 ++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 76d8ec1..65faef8 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -6,6 +6,7 @@ on: push: branches: - main + - cidoc jobs: style: runs-on: ubuntu-latest @@ -52,3 +53,29 @@ jobs: - name: Test Template Generation run: | nox -s test-generation + + run_doctests: + needs: style + runs-on: ubuntu-latest + strategy: + fail-fast: false + name: Doctests (ubuntu-latest / Python 3.11) + + steps: + - name: Check out pybamm-cookiecutter repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + id: setup-python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + cache: 'pip' + + - name: Install nox + run: python -m pip install nox + + - name: Check if the documentation can be built for GNU/Linux + run: python -m nox -s docs diff --git a/noxfile.py b/noxfile.py index f4cb85c..0943365 100644 --- a/noxfile.py +++ b/noxfile.py @@ -13,7 +13,9 @@ def build_docs(session: nox.Session) -> None: """Build the documentation and load it in a browser tab, rebuilding on changes.""" envbindir = session.bin session.install("-e", ".[docs]") - with session.chdir("docs/"): + session.chdir("docs/") + # For local development + if session.interactive: session.run( "sphinx-autobuild", "-j", @@ -23,6 +25,17 @@ def build_docs(session: nox.Session) -> None: ".", f"{envbindir}/../tmp/html", ) + # For CI testing if documentation builds + else: + session.run( + "sphinx-build", + "-b", + "html", + "-W", + "--keep-going", + ".", + f"{envbindir}/../tmp/html", + ) @nox.session(name="test-generation") def run_template_generation(session):