Skip to content

DEV: added scripts for building and uploading docs #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7971334
Update .readthedocs.yaml
GavinHuttley Nov 24, 2024
585b105
Update .readthedocs.yaml
GavinHuttley Nov 24, 2024
3fa4594
Update .readthedocs.yaml
GavinHuttley Nov 24, 2024
544bd36
Update .readthedocs.yaml
GavinHuttley Nov 24, 2024
7e15658
Update .readthedocs.yaml
GavinHuttley Nov 24, 2024
3e254d0
Update .readthedocs.yaml
GavinHuttley Nov 24, 2024
31bb5ed
DEV: added GHA for building docs
GavinHuttley Nov 24, 2024
3bd9ed1
Update build_docs.yml
GavinHuttley Nov 24, 2024
a179f9e
Update build_docs.yml
GavinHuttley Nov 24, 2024
094c057
Update build_docs.yml
GavinHuttley Nov 24, 2024
af23a43
Update build_docs.yml
GavinHuttley Nov 24, 2024
ad9d6b8
Update build_docs.yml
GavinHuttley Nov 24, 2024
af9a660
Update build_docs.yml
GavinHuttley Nov 24, 2024
6ed273f
Update build_docs.yml
GavinHuttley Nov 24, 2024
bc51b6a
Update build_docs.yml
GavinHuttley Nov 24, 2024
9401d93
DEV: update doc yaml's
GavinHuttley Nov 27, 2024
7b50a71
DEV: more tweaks
GavinHuttley Nov 27, 2024
6663893
added python script for downloading docs
GavinHuttley Nov 27, 2024
f40f8eb
debug
GavinHuttley Nov 27, 2024
60b8237
debug
GavinHuttley Nov 27, 2024
d5f6a5a
fix url error
GavinHuttley Nov 27, 2024
bc65c06
Merge branch 'iqtree:main' into main
GavinHuttley Nov 27, 2024
c2a3fa6
MAINT: added a comment about usage of the python script
GavinHuttley Nov 27, 2024
991f6ee
STY: fix linting issues with doc script
GavinHuttley Nov 27, 2024
35c7ab0
DEV: use cached iqtree build when making docs
rmcar17 Nov 28, 2024
5693605
DEV: use iqtree/piqtree2 for api url
rmcar17 Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build docs

on: [workflow_dispatch]

jobs:
build-iqtree:
name: Fetch or Build IQ-TREE 2 Static Library
runs-on: ubuntu-latest
steps:
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
submodules: recursive

- name: Get IQ-TREE 2 SHA
run: |
cd iqtree2
IQ_TREE_2_SHA=$(git rev-parse HEAD)
echo "IQ_TREE_2_SHA=${IQ_TREE_2_SHA}" >> $GITHUB_ENV

- uses: actions/cache@v4
id: cache
with:
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
path: src/piqtree2/_libiqtree/libiqtree2.a
lookup-only: true

- name: Build IQ-TREE
if: steps.cache.outputs.cache-hit != 'true'
run: |
sudo ./build_tools/before_all_linux.sh

build-docs:
runs-on: ubuntu-latest
needs: build-iqtree
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- uses: actions/cache/restore@v4
with:
key: libiqtree-ubuntu-latest-${{ env.IQ_TREE_2_SHA }}
path: src/piqtree2/_libiqtree/libiqtree2.a
fail-on-cache-miss: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Docs Dependencies
run: |
pip install .[doc]

- name: Build documentation
run: |
echo `pwd`
mkdocs build
working-directory: ${{ github.workspace }}

- name: Upload documentation artifact
uses: actions/upload-artifact@v4
with:
name: piqtree-docs-html
path: site
21 changes: 10 additions & 11 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ build:
os: ubuntu-22.04
tools:
python: "3.12"
jobs:
post_checkout:
- git submodule update --init --recursive
commands:
# Install the required dependencies
- pip install requests
# Run the script to download and extract the pre-built docs
- python rtd_get_docs.py
- echo "Documentation downloaded and extracted"

mkdocs:
configuration: mkdocs.yml
# Disable the default build processes since we're using pre-built docs
sphinx:
configuration: null

# Optionally declare the Python requirements required to build your docs
python:
install:
- method: pip
path: .
extra_requirements:
- doc
install: []
39 changes: 39 additions & 0 deletions rtd_get_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# this file
# is directly used by .readthedocs.yaml
# it extracts the built docs from the github artefact
# created by the build_docs.yml github action
import os
import pathlib
import zipfile

import requests


def download_and_extract_docs() -> None:
token = os.environ.get("GITHUB_TOKEN")
headers = {"Authorization": f"token {token}"}
api_url = "https://api.github.com/repos/iqtree/piqtree2/actions/runs"
response = requests.get(api_url, headers=headers, timeout=10)
got = response.json()
runs = got["workflow_runs"]
latest_run = next(
run
for run in runs
if run["name"] == "Build docs" and run["conclusion"] == "success"
)
artifacts_url = latest_run["artifacts_url"]
response = requests.get(artifacts_url, headers=headers, timeout=10)
artifacts = response.json()["artifacts"]
docs_artifact = next(
artifact for artifact in artifacts if artifact["name"] == "piqtree-docs-html"
)
download_url = docs_artifact["archive_download_url"]
response = requests.get(download_url, headers=headers, timeout=10)
out = pathlib.Path("piqtree-docs-html.zip")
out.write_bytes(response.content)
with zipfile.ZipFile("piqtree-docs-html.zip", "r") as zip_ref:
zip_ref.extractall("_readthedocs/html/")


if __name__ == "__main__":
download_and_extract_docs()