From 4a531fbaacdaf6df055041997ede04de8076f810 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Wed, 25 Aug 2021 11:21:18 -0400 Subject: [PATCH] Add tox config and docs publishing CI workflow This commit adds a new CI workflow for publishing documentation to: https://qiskit.org/documentation/partners/mthree/. This workflow is tag triggered, meaning it will run on new releases. This job will run sphinx-build at release time and upload the output to the IBM Cloud Object Storage instance used for qiskit.org. To simplify the job setup and unify the CI config with something local developers can run, a tox.ini is added, Tox enables a single entrypoint that combines venv management with running test commands. The new CI workflow uses it to build a virtual environment to run sphinx from. Local users can leverage the same tox command as CI to run docs builds in the same way as CI. --- .github/workflows/docs.yml | 29 +++++++++++++++++++++++++++++ constraints.txt | 0 tools/deploy_documentation.sh | 33 +++++++++++++++++++++++++++++++++ tools/rclone.conf.enc | Bin 0 -> 304 bytes tox.ini | 26 ++++++++++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 .github/workflows/docs.yml create mode 100644 constraints.txt create mode 100755 tools/deploy_documentation.sh create mode 100644 tools/rclone.conf.enc create mode 100644 tox.ini diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..540f1b10 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,29 @@ +--- +name: Docs Publish +on: + push: + tags: + - "*" + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.7.8' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U virtualenv setuptools wheel tox + sudo apt-get install -y graphviz pandoc + - name: Build and publish + env: + encrypted_rclone_key: ${{ secrets.encrypted_rclone_key }} + encrypted_rclone_iv: ${{ secrets.encrypted_rclone_iv }} + run: | + tools/deploy_documentation.sh diff --git a/constraints.txt b/constraints.txt new file mode 100644 index 00000000..e69de29b diff --git a/tools/deploy_documentation.sh b/tools/deploy_documentation.sh new file mode 100755 index 00000000..a24a34f8 --- /dev/null +++ b/tools/deploy_documentation.sh @@ -0,0 +1,33 @@ + +#!/bin/bash + +# This code is part of Qiskit. +# +# (C) Copyright IBM 2017, 2021. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +# Script for pushing the documentation to the qiskit.org repository. +set -e + +curl https://downloads.rclone.org/rclone-current-linux-amd64.deb -o rclone.deb +sudo apt-get install -y ./rclone.deb + +RCLONE_CONFIG_PATH=$(rclone config file | tail -1) + +# Build the documentation. +tox -edocs + +echo "show current dir: " +pwd + +# Push to qiskit.org website +openssl aes-256-cbc -K $encrypted_rclone_key -iv $encrypted_rclone_iv -in tools/rclone.conf.enc -out $RCLONE_CONFIG_PATH -d +echo "Pushing built docs to website" +rclone sync --progress ./docs/_build/html IBMCOS:qiskit-org-web-resources/documentation/partners/mthree diff --git a/tools/rclone.conf.enc b/tools/rclone.conf.enc new file mode 100644 index 0000000000000000000000000000000000000000..985bd728abc0a83d8ea98cd4d9561b7fa124842f GIT binary patch literal 304 zcmV-00nh$7&RTYTNLa46ND6UrOuMoPNp}L^N21;+KWICI2ddxLf?x*g*GAzexAhvW z5rTO-?xi4$c>vaY~!DfD~lI0H5)o5;H>qj7M~)ZT{14Fvc91%J)Ycl~B`S zR;dTAK}Qz7!C#ExhwZKgVKh_&DPch2pvl7`Df`TB7^fDm2w+?}@Ltb_s9A^-JfyD- zcV@+wP8bfhSO=k!OfNS+tVO*B2xkEIky>2YRz;z0Ar#-=dP|4$ar~If5$=F}D=bc3 C!HCcR literal 0 HcmV?d00001 diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..d983b20a --- /dev/null +++ b/tox.ini @@ -0,0 +1,26 @@ +[tox] +minversion = 2.1 +envlist = py36, py37, py38, py39, lint, docs + +[testenv] +usedevelop = true +install_command = pip install -c{toxinidir}/constraints.txt -U {opts} {packages} +setenv = + VIRTUAL_ENV={envdir} + LANGUAGE=en_US + LC_ALL=en_US.utf-8 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/requirements-dev.txt +commands = + pytest -p no:warnings --pyargs mthree/test + +[testenv:lint] +commands = + pycodestyle --max-line-length=100 mthree + pylint -rn mthree + +[testenv:docs] +changedir = {toxinidir}/docs +allowlist_externals = make +envdir = .tox/docs +commands = make html