From d02d987de2653a930f3d82ed5cdbf8f53b8b51a0 Mon Sep 17 00:00:00 2001 From: Atharva Arya Date: Tue, 12 Nov 2024 17:35:13 +0530 Subject: [PATCH 1/5] Add setup for jupyterbook --- .github/workflows/jupyterbook.yml | 59 +++++++++++++++++++++++++++++++ docs/_config.yml | 47 ++++++++++++++++++++++++ docs/_toc.yml | 38 ++++++++++++++++++++ docs/api.rst | 8 +++++ 4 files changed, 152 insertions(+) create mode 100644 .github/workflows/jupyterbook.yml create mode 100644 docs/_config.yml create mode 100644 docs/_toc.yml create mode 100644 docs/api.rst diff --git a/.github/workflows/jupyterbook.yml b/.github/workflows/jupyterbook.yml new file mode 100644 index 00000000000..5f6788a5d52 --- /dev/null +++ b/.github/workflows/jupyterbook.yml @@ -0,0 +1,59 @@ +name: Build Jupyterbook + +on: + workflow_dispatch: + push: + branches: + - '*' + pull_request: + branches: + - master + +defaults: + run: + shell: bash -l {0} + +jobs: + deploy-book: + runs-on: ubuntu-latest + environment: + name: github-pages + permissions: + pages: write + id-token: write + steps: + - uses: actions/checkout@v4 + + - uses: actions/checkout@v4 + with: + repository: tardis-sn/tardis-regression-data + path: tardis-regression-data + lfs: true + sparse-checkout: | + atom_data/kurucz_cd23_chianti_H_He.h5 + + - name: Setup environment + uses: ./.github/actions/setup_env + with: + os-label: linux-64 + + - run: | + micromamba install jupyter-book sphinx-autoapi + pip install -e . --user + + - name: Copy atom_data + run: | + mkdir -p ~/Downloads/tardis-data && cp -a ./tardis-regression-data/atom_data/. ~/Downloads/tardis-data + + - name: Build the book + run: | + jupyter-book build --all docs + + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: "docs_new/_build/html" + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v3 diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 00000000000..a9c70d8302a --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1,47 @@ +# Book settings +# Learn more at https://jupyterbook.org/customize/config.html + +title: TARDIS Documentation +author: TARDIS RT Collaboration +logo: graphics/tardis_banner.svg + +# Force re-execution of notebooks on each build. +# See https://jupyterbook.org/content/execute.html +execute: + execute_notebooks: force + timeout: 1000 + +# Define the name of the latex output file for PDF builds +latex: + latex_documents: + targetname: book.tex + +# Add a bibtex file so that we can create citations +bibtex_bibfiles: + - references.bib + +# Information about where the book exists on the web +repository: + url: https://github.com/executablebooks/jupyter-book # Online location of your book + path_to_book: docs # Optional path to your book, relative to the repository root + branch: master # Which branch of the repository should be used when creating links (optional) + +# Add GitHub buttons to your book +# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository +html: + use_issues_button: true + use_repository_button: true + + +sphinx: + extra_extensions: + - 'sphinx.ext.autodoc' + - 'sphinx.ext.autosummary' + - 'sphinx.ext.viewcode' + - 'autoapi.extension' + config: + html_extra_path: ['screenshots'] + autodoc_member_order: 'bysource' + autosummary_generate: True + autoapi_dirs: ['../tardis'] + autoapi_options: [ 'members', 'undoc-members', 'private-members', 'show-inheritance', 'show-module-summary', 'special-members', ] \ No newline at end of file diff --git a/docs/_toc.yml b/docs/_toc.yml new file mode 100644 index 00000000000..bf50db14470 --- /dev/null +++ b/docs/_toc.yml @@ -0,0 +1,38 @@ +format: jb-book +root: index +parts: + - caption: Getting Started + chapters: + - file: installation + - file: quickstart + - file: tutorials + - caption: Input/Output + chapters: + - file: io/hdf/index + - file: io/configuration/index + - file: io/model/index + - file: io/optional/index + - file: io/visualization/index + - file: io/output/index + - file: io/grid/TardisGridTutorial + - caption: Physics Walkthrough + chapters: + - file: physics/intro/index + - file: physics/setup/index + - file: physics/montecarlo/index + - file: physics/update_and_conv/update_and_conv + - file: physics/spectrum/index + - file: physics/tardisgamma/index + - caption: Contributing to TARDIS + chapters: + - file: contributing/CONTRIBUTING + - file: contributing/development/index + - file: contributing/tools/index + - file: contributing/CHANGELOG + - file: contributing/in_progress/index + - caption: Other Resources + chapters: + - file: resources/credits + - file: resources/research_done_using_TARDIS/research_papers + - file: resources/code_comparison/index + - file: resources/zreferences \ No newline at end of file diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 00000000000..025f1f58c05 --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,8 @@ +API documentation +================= + +.. autosummary:: + :toctree: _autosummary + :recursive: + + tardis From fc944c4201a644b2607f7e5a74d8ab92828ee31a Mon Sep 17 00:00:00 2001 From: Atharva Arya Date: Tue, 12 Nov 2024 17:42:45 +0530 Subject: [PATCH 2/5] Add concurrency --- .github/workflows/jupyterbook.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jupyterbook.yml b/.github/workflows/jupyterbook.yml index 5f6788a5d52..34e528aaa71 100644 --- a/.github/workflows/jupyterbook.yml +++ b/.github/workflows/jupyterbook.yml @@ -1,4 +1,4 @@ -name: Build Jupyterbook +name: Build Jupyter Book on: workflow_dispatch: @@ -13,8 +13,13 @@ defaults: run: shell: bash -l {0} +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + + jobs: - deploy-book: + build: runs-on: ubuntu-latest environment: name: github-pages From ebd73b8e4e018526414a6405ce777bb762255ad8 Mon Sep 17 00:00:00 2001 From: Atharva Arya Date: Fri, 15 Nov 2024 13:51:14 +0530 Subject: [PATCH 3/5] Modify path for build html --- .github/workflows/jupyterbook.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jupyterbook.yml b/.github/workflows/jupyterbook.yml index 34e528aaa71..106319701ae 100644 --- a/.github/workflows/jupyterbook.yml +++ b/.github/workflows/jupyterbook.yml @@ -57,7 +57,7 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: - path: "docs_new/_build/html" + path: "docs/_build/html" - name: Deploy to GitHub Pages id: deployment From dc0764a920e83161f63ec7e90114f260ec88ed83 Mon Sep 17 00:00:00 2001 From: Atharva Arya Date: Fri, 15 Nov 2024 18:55:46 +0530 Subject: [PATCH 4/5] Deploy using tardis bot --- .github/workflows/jupyterbook.yml | 100 +++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jupyterbook.yml b/.github/workflows/jupyterbook.yml index 106319701ae..5a273fe0dc6 100644 --- a/.github/workflows/jupyterbook.yml +++ b/.github/workflows/jupyterbook.yml @@ -59,6 +59,100 @@ jobs: with: path: "docs/_build/html" - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v3 + - name: Set destination directory + run: | + BRANCH=$(echo ${GITHUB_REF#refs/heads/}) + if [[ $EVENT == push ]] || [[ $EVENT == workflow_dispatch ]]; then + + if [[ $BRANCH == $DEFAULT ]]; then + echo "DEST_DIR=" >> $GITHUB_ENV + else + echo "DEST_DIR=branch/$BRANCH" >> $GITHUB_ENV + fi + + elif [[ $EVENT == pull_request_target ]]; then + echo "DEST_DIR=pull/$PR" >> $GITHUB_ENV + + else + echo "Unexpected event trigger $EVENT" + exit 1 + + fi + + cat $GITHUB_ENV + env: + DEFAULT: ${{ github.event.repository.default_branch }} + EVENT: ${{ github.event_name }} + PR: ${{ github.event.number }} + + - name: Set clean branch option + run: | + if [[ $EVENT == workflow_dispatch ]]; then + echo "CLEAN_BRANCH=true" >> $GITHUB_ENV + + else + echo "CLEAN_BRANCH=false" >> $GITHUB_ENV + + fi + + cat $GITHUB_ENV + env: + EVENT: ${{ github.event_name }} + + - name: Deploy ${{ env.DEST_DIR }} + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.BOT_TOKEN }} + publish_branch: ${{ env.DEPLOY_BRANCH }} + publish_dir: ./docs/_build/html + destination_dir: ${{ env.DEST_DIR }} + keep_files: true + force_orphan: ${{ env.CLEAN_BRANCH }} + user_name: "TARDIS Bot" + user_email: "tardis.sn.bot@gmail.com" + + - name: Find comment + uses: peter-evans/find-comment@v1 + id: fc + with: + issue-number: ${{ github.event.number }} + body-includes: Hi, human. + if: always() && github.event_name == 'pull_request_target' + + - name: Post comment (success) + uses: peter-evans/create-or-update-comment@v1 + with: + token: ${{ secrets.BOT_TOKEN }} + issue-number: ${{ github.event.number }} + comment-id: ${{ steps.fc.outputs.comment-id }} + edit-mode: replace + body: | + *\*beep\* \*bop\** + + Hi, human. + + The **`${{ github.workflow }}`** workflow has **succeeded** :heavy_check_mark: + + [**Click here**](${{ env.URL }}) to see your results. + env: + URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pull/${{ github.event.number }}/index.html + if: success() && github.event_name == 'pull_request_target' + + - name: Post comment (failure) + uses: peter-evans/create-or-update-comment@v1 + with: + token: ${{ secrets.BOT_TOKEN }} + issue-number: ${{ github.event.number }} + comment-id: ${{ steps.fc.outputs.comment-id }} + edit-mode: replace + body: | + *\*beep\* \*bop\** + + Hi, human. + + The **`${{ github.workflow }}`** workflow has **failed** :x: + + [**Click here**](${{ env.URL }}) to see the build log. + env: + URL: https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }}?check_suite_focus=true + if: failure() && github.event_name == 'pull_request_target' From fde1f99cb7e4332eb168592206eeacc3aaf6b471 Mon Sep 17 00:00:00 2001 From: Atharva Arya Date: Fri, 15 Nov 2024 19:01:38 +0530 Subject: [PATCH 5/5] Remove environment --- .github/workflows/jupyterbook.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jupyterbook.yml b/.github/workflows/jupyterbook.yml index 5a273fe0dc6..49010c16135 100644 --- a/.github/workflows/jupyterbook.yml +++ b/.github/workflows/jupyterbook.yml @@ -21,8 +21,8 @@ concurrency: jobs: build: runs-on: ubuntu-latest - environment: - name: github-pages + # environment: + # name: github-pages permissions: pages: write id-token: write