diff --git a/.github/workflows/advanced-on-demand.yml b/.github/workflows/advanced-on-demand.yml index 5e9f22baf..cf22210d8 100644 --- a/.github/workflows/advanced-on-demand.yml +++ b/.github/workflows/advanced-on-demand.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: python-version: [3.8, 3.9] - poetry-version: [1.2.1] + poetry-version: [1.2.2] test-group: [1, 2, 3, 4] if: ${{ github.event.comment.body == 'test advanced'}} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25fe92627..b39f88f20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,11 +28,11 @@ jobs: strategy: matrix: python-version: [3.8, 3.9] - poetry-version: [1.2.1] + poetry-version: [1.2.2] test-group: [1, 2, 3, 4, 5, 6] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 diff --git a/.github/workflows/docs-ci.yml b/.github/workflows/docs-ci.yml new file mode 100644 index 000000000..f72f80ee1 --- /dev/null +++ b/.github/workflows/docs-ci.yml @@ -0,0 +1,29 @@ +name: Build Docs (CI) + +on: + pull_request: + branches: [main] + paths: + - ".github/workflows/docs-ci.yml" + - "dowhy/**" + - "docs/**" + - "pyproject.toml" + - "poetry.lock" + +jobs: + docs: + runs-on: ubuntu-latest + container: + image: "ghcr.io/${{ github.repository_owner }}/dowhy-docs-generation:latest" + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Python Dependencies + run: poetry install -E plotting -E causalml -E econml -E pydot --with docs + + - run: git config --global --add safe.directory /__w/dowhy/dowhy + + - name: Build + run: ./docs/generate_docs.sh \ No newline at end of file diff --git a/.github/workflows/docs-on-demand.yml b/.github/workflows/docs-on-demand.yml deleted file mode 100644 index e8fb60454..000000000 --- a/.github/workflows/docs-on-demand.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Build Docs (on demand) - -on: - issue_comment: - types: [created, edited] - -jobs: - docs: - runs-on: ubuntu-latest - container: - image: "ghcr.io/${{ github.repository_owner }}/dowhy-docs-generation:latest" - - if: ${{ github.event.comment.body == 'build docs'}} - steps: - - name: Message Initiating - uses: actions/github-script@v4 - with: - script: | - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Launching documentation build 🚀', - }); - - - name: Get PR SHA - id: sha - uses: actions/github-script@v4 - with: - result-encoding: string - script: | - const { owner, repo, number } = context.issue; - const pr = await github.pulls.get({ - owner, - repo, - pull_number: number, - }); - return pr.data.head.sha - - - uses: actions/checkout@v2 - with: - ref: ${{ steps.sha.outputs.result }} - fetch-depth: 0 - - - name: Install Python Dependencies - run: poetry install -E plotting -E causalml -E econml -E pydot --with docs - - - name: Build - run: | - # sphinx-multiversion invokes git internally. Its call to "git rev-parse --show-toplevel" throws the - # following error: "fatal: detected dubious ownership in repository at '/__w/dowhy/dowhy'" - # The following command avoids this. - git config --global --add safe.directory /__w/dowhy/dowhy - ./docs/generate_docs.sh - - - name: Message success - if: ${{ success() }} - uses: actions/github-script@v4 - with: - script: | - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Documentation build succeeded! ✅', - }); - - - name: Message failure - if: ${{ failure() }} - uses: actions/github-script@v4 - with: - script: | - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Documentation build failed! ❌', - }); diff --git a/.github/workflows/docs-release.yml b/.github/workflows/docs-release.yml new file mode 100644 index 000000000..55917f2b7 --- /dev/null +++ b/.github/workflows/docs-release.yml @@ -0,0 +1,31 @@ +name: Build & Deploy Docs (For Release) + +on: + release: + types: [created] + +jobs: + docs: + runs-on: ubuntu-latest + container: + image: "ghcr.io/${{ github.repository_owner }}/dowhy-docs-generation:latest" + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Python Dependencies + run: poetry install -E plotting -E causalml -E econml -E pydot --with docs + + - run: git config --global --add safe.directory /__w/dowhy/dowhy + + - name: Build + run: ./docs/generate_docs.sh + env: + DOCS_VERSION: ${{ github.event.release.tag_name }} + + - name: Commit and push to gh-pages branch + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dowhy-docs diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c74f309ae..3c8e360cb 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,8 +1,14 @@ -name: Build Docs +name: Build & Deploy Docs on: push: branches: - main + paths: + - ".github/workflows/docs.yml" + - "dowhy/**" + - "docs/**" + - "pyproject.toml" + - "poetry.lock" workflow_run: workflows: [ "Build Docker image (docs)" ] types: @@ -14,20 +20,17 @@ jobs: container: image: "ghcr.io/${{ github.repository_owner }}/dowhy-docs-generation:latest" steps: - - uses: actions/checkout@main + - uses: actions/checkout@v3 with: - fetch-depth: 0 # otherwise, you will failed to push refs to dest repo + fetch-depth: 0 - name: Install Python Dependencies run: poetry install -E plotting -E causalml -E econml -E pydot --with docs + - run: git config --global --add safe.directory /__w/dowhy/dowhy + - name: Build - run: | - # sphinx-multiversion invokes git internally. Its call to "git rev-parse --show-toplevel" throws the - # following error: "fatal: detected dubious ownership in repository at '/__w/dowhy/dowhy'" - # The following command avoids this. - git config --global --add safe.directory /__w/dowhy/dowhy - ./docs/generate_docs.sh + run: ./docs/generate_docs.sh - name: Commit and push to gh-pages branch uses: peaceiris/actions-gh-pages@v3 diff --git a/.github/workflows/nightly-tests.yml b/.github/workflows/nightly-tests.yml index c2e676aa9..f4c7f44c3 100644 --- a/.github/workflows/nightly-tests.yml +++ b/.github/workflows/nightly-tests.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: python-version: [3.8, 3.9] - poetry-version: [1.2.1] + poetry-version: [1.2.2] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 3083d6268..6b6d1e508 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -20,10 +20,10 @@ jobs: with: python-version: '3.8' - - name: Install Poetry 1.2.1 + - name: Install Poetry 1.2.2 uses: abatilo/actions-poetry@v2.0.0 with: - poetry-version: '1.2.1' + poetry-version: '1.2.2' - name: Install Poetry Dynamic Versioning Plugin run: pip install poetry-dynamic-versioning diff --git a/.gitignore b/.gitignore index fcdd90409..4b53e81ac 100644 --- a/.gitignore +++ b/.gitignore @@ -107,6 +107,5 @@ venv.bak/ # custom values docs/source/example_notebooks/*.png docs/source/example_notebooks/lalonde.csv -docs/source/_templates/versions.html docs/source/example_notebooks/lalonde.csv dowhy-docs diff --git a/docs/Dockerfile b/docs/Dockerfile index 8e1385543..5c45c81c5 100644 --- a/docs/Dockerfile +++ b/docs/Dockerfile @@ -6,5 +6,5 @@ FROM ghcr.io/py-why/dowhy-example-notebooks-deps RUN apt update RUN DEBIAN_FRONTEND=noninteractive apt install --yes --quiet curl -RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.2.1 +RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.2.2 ENV PATH=$PATH:/root/.local/share/pypoetry/venv/bin diff --git a/docs/generate_docs.sh b/docs/generate_docs.sh index 05a389eaa..9d15e84b6 100755 --- a/docs/generate_docs.sh +++ b/docs/generate_docs.sh @@ -1,26 +1,32 @@ -#!/bin/bash -ex - +#!/bin/bash -e cd $( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - -OUTPUT_DIR='../dowhy-docs' - -mv source/conf.py source/conf.py.orig -cp source/conf-rtd.py source/conf.py -cp source/_templates/versions-rtd.html source/_templates/versions.html - -poetry run sphinx-multiversion --dump-metadata source ${OUTPUT_DIR} -poetry run sphinx-multiversion source ${OUTPUT_DIR} - -mv source/conf.py.orig source/conf.py -cp source/_templates/versions-pydata.html source/_templates/versions.html - -poetry run sphinx-multiversion --dump-metadata source ${OUTPUT_DIR} -poetry run sphinx-multiversion source ${OUTPUT_DIR} - +DOCS_ROOT='../dowhy-docs' +# To change the build target, specify the DOCS_VERSION environment variable. (e.g. DOCS_VERSION=v0.8) +TARGET_BUILD=${DOCS_VERSION:-main} +OUTPUT_DIR="${DOCS_ROOT}/${TARGET_BUILD}" STABLE_VERSION=$(git describe --tags --abbrev=0 --match='v*') +echo "Building docs for version ${TARGET_BUILD} into ${OUTPUT_DIR}, stable version is ${STABLE_VERSION}" + +# +# Cache existing docs +# +if [ ! -f "${DOCS_ROOT}/index.html" ]; then + git clone --quiet --branch gh-pages https://github.com/py-why/dowhy.git ${DOCS_ROOT} + rm -rf ${DOCS_ROOT}/.git +fi + +# +# Build docs +echo "Executing sphinx-build" +poetry run sphinx-build -j auto source ${OUTPUT_DIR} + +# +# Create the top-level index.html +# + echo "
-" > ${OUTPUT_DIR}/index.html +