This is an automated email from the ASF dual-hosted git repository.

paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5ca27bc  chore(ci): Add documentation build script and docker-compose 
builder (#184)
5ca27bc is described below

commit 5ca27bc578882aa7985d3757b1e190ca6b74d724
Author: Dewey Dunnington <[email protected]>
AuthorDate: Fri Apr 21 14:48:15 2023 -0400

    chore(ci): Add documentation build script and docker-compose builder (#184)
---
 .env                             |  3 ++
 .github/workflows/docs.yaml      | 48 ++++---------------------
 .github/workflows/packaging.yaml | 47 ++++---------------------
 ci/scripts/build-docs.sh         | 76 ++++++++++++++++++++++++++++++++++++++++
 docker-compose.yml               | 17 ++++++++-
 5 files changed, 109 insertions(+), 82 deletions(-)

diff --git a/.env b/.env
index e96ac04..bc07cb5 100644
--- a/.env
+++ b/.env
@@ -24,3 +24,6 @@ REPO=ghcr.io/apache/arrow-nanoarrow
 # Linux platform (i.e., the dockerfile to use from ci/docker)
 NANOARROW_PLATFORM=alpine
 NANOARROW_ARCH=amd64
+
+# Source directory (so that the docker compose app can be used on another 
checkout)
+NANOARROW_SOURCE_DIR="."
diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml
index 81e5595..6728f60 100644
--- a/.github/workflows/docs.yaml
+++ b/.github/workflows/docs.yaml
@@ -36,49 +36,15 @@ jobs:
 
     steps:
       - uses: actions/checkout@v2
-      # Probably a better way to do this, but for now do the vendor step 
manually
-      - name: Vendor nanoarrow into the R package
-        run: |
-          cd r
-          ./configure
-      
-      - uses: r-lib/actions/setup-pandoc@v2
-      - uses: r-lib/actions/setup-r@v2
-        with:
-          use-public-rspm: true
-      - uses: r-lib/actions/setup-r-dependencies@v2
-        with:
-          extra-packages: any::pkgdown, local::.
-          needs: website
-          working-directory: r
-      - uses: actions/setup-python@v2
-        with:
-          python-version: 3.9
-      
-      - name: Install dependencies
-        run: |
-          sudo apt-get install doxygen
-          python -m pip install --upgrade pip
-          pip install -r docs/requirements.txt
-      
-      - name: Run doxygen
-        run: |
-          cd src/apidoc
-          doxygen
-      
-      - name: Regenerate index content from README
+
+      - name: Build documentation
         run: |
-          cd docs
-          pandoc ../README.md --from markdown --to rst -s -o 
source/README_generated.rst
-      
-      - name: Run sphinx
+          docker compose run --rm docs
+
+      - name: Documentation build logs
+        if: always()
         run: |
-          cd docs
-          sphinx-build source _build/html
-      
-      - name: Run pkgdown
-        run: pkgdown::build_site_github_pages("r", dest_dir = 
"../docs/_build/html/r", new_process = FALSE, install = FALSE)
-        shell: Rscript {0}
+          cat docs/_build/build-docs.log
 
       - name: Upload built documentation
         uses: actions/upload-artifact@main
diff --git a/.github/workflows/packaging.yaml b/.github/workflows/packaging.yaml
index b461416..85a30ed 100644
--- a/.github/workflows/packaging.yaml
+++ b/.github/workflows/packaging.yaml
@@ -121,49 +121,16 @@ jobs:
           echo "schedule: ${{ github.event.schedule }}"
           echo "ref: ${{ github.ref }}"
 
-      # Probably a better way to do this, but for now do the vendor step 
manually
-      - name: Vendor nanoarrow into the R package
+      - name: Build documentation
         run: |
-          cd nanoarrow/r
-          ./configure
-
-      - uses: r-lib/actions/setup-pandoc@v2
-      - uses: r-lib/actions/setup-r@v2
-        with:
-          use-public-rspm: true
-      - uses: r-lib/actions/setup-r-dependencies@v2
-        with:
-          extra-packages: any::pkgdown, local::.
-          needs: website
-          working-directory: nanoarrow/r
-      - uses: actions/setup-python@v2
-        with:
-          python-version: 3.9
-
-      - name: Install dependencies
-        run: |
-          sudo apt-get install doxygen
-          python -m pip install --upgrade pip
-          pip install -r nanoarrow/docs/requirements.txt
-
-      - name: Run doxygen
-        run: |
-          cd nanoarrow/src/apidoc
-          doxygen
-
-      - name: Regenerate index content from README
-        run: |
-          cd nanoarrow/docs
-          pandoc ../README.md --from markdown --to rst -s -o 
source/README_generated.rst
+          pushd nanoarrow
+          docker compose run --rm docs
+          popd
 
-      - name: Run sphinx
+      - name: Documentation build logs
+        if: always()
         run: |
-          cd nanoarrow/docs
-          sphinx-build source _build/html
-
-      - name: Run pkgdown
-        run: pkgdown::build_site_github_pages("nanoarrow/r", dest_dir = 
"../docs/_build/html/r", new_process = FALSE, install = FALSE)
-        shell: Rscript {0}
+          cat nanoarrow/docs/_build/build-docs.log
 
       - name: Compress docs
         shell: bash
diff --git a/ci/scripts/build-docs.sh b/ci/scripts/build-docs.sh
new file mode 100755
index 0000000..b978adb
--- /dev/null
+++ b/ci/scripts/build-docs.sh
@@ -0,0 +1,76 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+set -o pipefail
+
+if [ ${VERBOSE:-0} -gt 0 ]; then
+  set -x
+fi
+
+SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
+NANOARROW_DIR="$(cd "${SOURCE_DIR}/../.." && pwd)"
+
+case $# in
+  0) TARGET_NANOARROW_DIR="${NANOARROW_DIR}"
+     ;;
+  1) TARGET_NANOARROW_DIR="$1"
+     ;;
+  *) echo "Usage:"
+     echo "  Build documentation based on a source checkout elsewhere:"
+     echo "    $0 path/to/arrow-nanoarrow"
+     echo "  Build documentation for this nanoarrow checkout:"
+     echo "    $0"
+     exit 1
+     ;;
+esac
+
+main() {
+    pushd "${TARGET_NANOARROW_DIR}"
+
+    # Run doxygen
+    pushd src/apidoc
+    doxygen
+    popd
+
+    pushd docs
+
+    # Use the README as the docs homepage
+    pandoc ../README.md --from markdown --to rst -s -o 
source/README_generated.rst
+
+    # Build sphinx project
+    sphinx-build source _build/html
+
+    # Install the R package from source
+    R CMD INSTALL ../r --preclean
+
+    # Build R documentation
+    Rscript -e 'pkgdown::build_site_github_pages("../r", dest_dir = 
"../docs/_build/html/r", new_process = FALSE, install = FALSE)'
+
+    popd
+
+    popd
+}
+
+# Clean the previous build
+rm -rf "${TARGET_NANOARROW_DIR}/docs/_build"
+mkdir -p "${TARGET_NANOARROW_DIR}/docs/_build"
+
+main >> "${TARGET_NANOARROW_DIR}/docs/_build/build-docs.log" 2>&1
+echo "${TARGET_NANOARROW_DIR}/docs/_build/html"
diff --git a/docker-compose.yml b/docker-compose.yml
index 0b7dd7b..2bdaad2 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -28,5 +28,20 @@ services:
       args:
         NANOARROW_ARCH: ${NANOARROW_ARCH}
     volumes:
-      - .:/nanoarrow
+      - ${NANOARROW_SOURCE_DIR}:/nanoarrow
     command: "/bin/bash /nanoarrow/dev/release/verify-release-candidate.sh"
+
+  docs:
+    image: ${REPO}:ubuntu-${NANOARROW_ARCH}
+    build:
+      context: .
+      cache_from:
+        - ${REPO}:ubuntu-${NANOARROW_ARCH}
+      dockerfile: ci/docker/ubuntu.dockerfile
+      args:
+        NANOARROW_ARCH: ${NANOARROW_ARCH}
+    volumes:
+      # Don't mix the "dev tools" and "source" checkouts
+      - ./ci/scripts/build-docs.sh:/build-docs.sh
+      - ${NANOARROW_SOURCE_DIR}:/nanoarrow
+    command: "/bin/bash /build-docs.sh /nanoarrow"

Reply via email to