]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Github Actions workflow to generate and upload documentation
authorFred Morcos <fred.morcos@open-xchange.com>
Tue, 17 Jan 2023 23:03:56 +0000 (00:03 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Thu, 19 Jan 2023 18:12:33 +0000 (19:12 +0100)
.github/workflows/documentation.yml [new file with mode: 0644]
build-scripts/gh-actions-setup-inv-no-dist-upgrade [new file with mode: 0755]
tasks.py

diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml
new file mode 100644 (file)
index 0000000..cf497eb
--- /dev/null
@@ -0,0 +1,115 @@
+---
+name: 'Documentation'
+
+on:
+  push:
+    branches: [master]
+  pull_request:
+    branches: [master]
+
+permissions:
+  contents: read
+
+jobs:
+  build-upload-docs:
+    name: Build and upload docs
+    runs-on: ubuntu-20.04
+    steps:
+      - uses: PowerDNS/pdns/set-ubuntu-mirror@meta
+      - uses: actions/checkout@v3.1.0
+      - run: build-scripts/gh-actions-setup-inv-no-dist-upgrade  # this runs apt update
+      - run: inv install-doc-deps
+      - run: inv install-doc-deps-pdf
+        if: ${{github.ref_name == 'master'}}
+
+      - id: setup-ssh
+        run: |-
+          inv ci-docs-add-ssh --ssh-key="$SSH_KEY" --host-key="$HOST_KEY"
+          echo "have_ssh_key=yes" >> $GITHUB_OUTPUT
+        env:
+          SSH_KEY: ${{secrets.WEB1_DOCS_SECRET}}
+          HOST_KEY: ${{vars.WEB1_HOSTKEY}}
+        if: ${{github.ref_name == 'master' && env.SSH_KEY != ''}}
+
+      # Auth
+      - run: inv ci-docs-build
+      - run: mv html html-docs
+        working-directory: ./docs/_build
+      - run: tar cf html-docs.tar html-docs
+        working-directory: ./docs/_build
+      - uses: actions/upload-artifact@v3
+        with:
+          name: authoritative-html-docs
+          path: ./docs/_build/html-docs.tar
+      - run: bzip2 html-docs.tar
+        if: ${{github.ref_name == 'master'}}
+        working-directory: ./docs/_build
+      - run: inv ci-docs-build-pdf
+        if: ${{github.ref_name == 'master'}}
+      - uses: actions/upload-artifact@v3
+        with:
+          name: PowerDNS-Authoritative.pdf
+          path: ./docs/_build/latex/PowerDNS-Authoritative.pdf
+        if: ${{github.ref_name == 'master'}}
+      - run: inv ci-docs-upload-master --docs-host="${DOCS_HOST}" --pdf="PowerDNS-Authoritative.pdf" --username="docs_powerdns_com" --directory="/${AUTH_DOCS_DIR}/"
+        env:
+          DOCS_HOST: ${{vars.DOCS_HOST}}
+          AUTH_DOCS_DIR: ${{vars.AUTH_DOCS_DIR}}
+        if: ${{github.ref_name == 'master' && steps.setup-ssh.outputs.have_ssh_key != ''}}
+
+      # Rec
+      - run: inv ci-docs-build
+        working-directory: ./pdns/recursordist
+      - run: mv html html-docs
+        working-directory: ./pdns/recursordist/docs/_build
+      - run: tar cf html-docs.tar html-docs
+        working-directory: ./pdns/recursordist/docs/_build
+      - uses: actions/upload-artifact@v3
+        with:
+          name: recursor-html-docs
+          path: ./pdns/recursordist/docs/_build/html-docs.tar
+      - run: bzip2 html-docs.tar
+        if: ${{github.ref_name == 'master'}}
+        working-directory: ./pdns/recursordist/docs/_build
+      - run: inv ci-docs-build-pdf
+        if: ${{github.ref_name == 'master'}}
+        working-directory: ./pdns/recursordist
+      - uses: actions/upload-artifact@v3
+        with:
+          name: PowerDNS-Recursor.pdf
+          path: ./pdns/recursordist/docs/_build/latex/PowerDNS-Recursor.pdf
+        if: ${{github.ref_name == 'master'}}
+      - run: inv ci-docs-upload-master --docs-host="${DOCS_HOST}" --pdf="PowerDNS-Recursor.pdf" --username="docs_powerdns_com" --directory="/${REC_DOCS_DIR}/"
+        env:
+          DOCS_HOST: ${{vars.DOCS_HOST}}
+          REC_DOCS_DIR: ${{vars.REC_DOCS_DIR}}
+        if: ${{github.ref_name == 'master' && steps.setup-ssh.outputs.have_ssh_key != ''}}
+        working-directory: ./pdns/recursordist
+
+      # DNSdist
+      - run: inv ci-docs-build
+        working-directory: ./pdns/dnsdistdist
+      - run: mv html html-docs
+        working-directory: ./pdns/dnsdistdist/docs/_build
+      - run: tar cf html-docs.tar html-docs
+        working-directory: ./pdns/dnsdistdist/docs/_build
+      - uses: actions/upload-artifact@v3
+        with:
+          name: dnsdist-html-docs
+          path: ./pdns/dnsdistdist/docs/_build/html-docs.tar
+      - run: bzip2 html-docs.tar
+        if: ${{github.ref_name == 'master'}}
+        working-directory: ./pdns/dnsdistdist/docs/_build
+      - run: inv ci-docs-build-pdf
+        if: ${{github.ref_name == 'master'}}
+        working-directory: ./pdns/dnsdistdist
+      - uses: actions/upload-artifact@v3
+        with:
+          name: dnsdist.pdf
+          path: ./pdns/dnsdistdist/docs/_build/latex/dnsdist.pdf
+        if: ${{github.ref_name == 'master'}}
+      - run: inv ci-docs-upload-master --docs-host="${DOCS_HOST}" --pdf="dnsdist.pdf" --username="dnsdist_org"
+        env:
+          DOCS_HOST: ${{vars.DOCS_HOST}}
+        if: ${{github.ref_name == 'master' && steps.setup-ssh.outputs.have_ssh_key != ''}}
+        working-directory: ./pdns/dnsdistdist
diff --git a/build-scripts/gh-actions-setup-inv-no-dist-upgrade b/build-scripts/gh-actions-setup-inv-no-dist-upgrade
new file mode 100755 (executable)
index 0000000..be3eb52
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash -x
+sudo sh -c "cat > /usr/sbin/policy-rc.d << EOF
+#!/bin/sh
+exit 101
+EOF
+"
+sudo chmod 755 /usr/sbin/policy-rc.d
+sudo apt-get update
+sudo apt-get -qq -y --no-install-recommends install python3-pip
+sudo pip3 install git+https://github.com/pyinvoke/invoke@faa5728a6f76199a3da1750ed952e7efee17c1da
index 273022371b0a552c505086ce9118e1254fae2619..3abecdcf255722a8c23a2611918df7033fb3d6c1 100644 (file)
--- a/tasks.py
+++ b/tasks.py
@@ -116,6 +116,30 @@ auth_test_deps = [   # FIXME: we should be generating some of these from shlibde
     'unixodbc',
     'wget',
 ]
+doc_deps = [
+    'autoconf',
+    'automake',
+    'bison',
+    'curl',
+    'flex',
+    'g++',
+    'git',
+    'latexmk',
+    'libboost-all-dev',
+    'libedit-dev',
+    'libluajit-5.1-dev',
+    'libssl-dev',
+    'make',
+    'pkg-config',
+    'python3-venv',
+    'ragel',
+    'rsync',
+]
+doc_deps_pdf = [
+    'texlive-binaries',
+    'texlive-formats-extra',
+    'texlive-latex-extra',
+]
 
 @task
 def apt_fresh(c):
@@ -150,6 +174,14 @@ def install_libdecaf(c, product):
     c.sudo(f'mkdir -p /opt/{product}/libdecaf')
     c.sudo(f'cp /usr/local/lib/libdecaf.so* /opt/{product}/libdecaf/.')
 
+@task
+def install_doc_deps(c):
+    c.sudo('apt-get install -qq -y ' + ' '.join(doc_deps))
+
+@task
+def install_doc_deps_pdf(c):
+    c.sudo('apt-get install -qq -y ' + ' '.join(doc_deps_pdf))
+
 @task
 def install_auth_build_deps(c):
     c.sudo('apt-get install -qq -y --no-install-recommends ' + ' '.join(all_build_deps + git_build_deps + auth_build_deps))
@@ -254,6 +286,27 @@ def install_dnsdist_build_deps(c):
 def ci_autoconf(c):
     c.run('BUILDER_VERSION=0.0.0-git1 autoreconf -vfi')
 
+@task
+def ci_docs_build(c):
+    c.run('make -f Makefile.sphinx -C docs html')
+
+@task
+def ci_docs_build_pdf(c):
+    c.run('make -f Makefile.sphinx -C docs latexpdf')
+
+@task
+def ci_docs_upload_master(c, docs_host, pdf, username, directory=""):
+    c.run(f"rsync -crv --delete --no-p --chmod=g=rwX --exclude '*~' ./docs/_build/html-docs/ {username}@{docs_host}:{directory}")
+    c.run(f"rsync -crv --no-p --chmod=g=rwX --exclude '*~' ./docs/_build/html-docs.tar.bz2 {username}@{docs_host}:{directory}")
+    c.run(f"rsync -crv --no-p --chmod=g=rwX --exclude '*~' ./docs/_build/latex/{pdf} {username}@{docs_host}:{directory}")
+
+@task
+def ci_docs_add_ssh(c, ssh_key, host_key):
+    c.run('mkdir -m 700 -p ~/.ssh')
+    c.run(f'echo "{ssh_key}" > ~/.ssh/id_ed25519')
+    c.run('chmod 600 ~/.ssh/id_ed25519')
+    c.run(f'echo "{host_key}" > ~/.ssh/known_hosts')
+
 @task
 def ci_auth_configure(c):
     res = c.run('''CFLAGS="-O1 -Werror=vla -Werror=shadow -Wformat=2 -Werror=format-security -Werror=string-plus-int" \