From 870539dd58228fd6f7cbeb46528ac863cf1bcc68 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 6 May 2021 12:52:42 -0400 Subject: [PATCH] Add CI configuration (#8) * Add CI configuration This commit adds a basic CI configuration for the qiskit-runtime repository. It adds 3 jobs, a unittest job that runs the repository's sole unit test on all supported platforms, a docs build job that verifies the docs build, and a doc publishing job that will build the documentation on tags and upload the built html to https://qiskit.org/documentation/partners/qiskit_runtime . We should add some lint/style jobs but that can be done in a follow up commit because it's likely that we'll need to update the code to conform to whichever tooling we decide on. * Add missing docs artifact upload to docs PR/Push ci job * Fix typo in deploy_documentation.sh The output path for the built documentation is `docs/_build/html` not `docs/build/html`. --- .github/workflows/docs.yml | 29 +++++++ .github/workflows/main.yml | 60 ++++++++++++++ .gitignore | 149 +++++++++++++++++++++++++++++++++- requirements-dev.txt | 1 + requirements.txt | 2 +- tools/deploy_documentation.sh | 33 ++++++++ tools/rclone.conf.enc | Bin 0 -> 304 bytes tox.ini | 24 ++++++ 8 files changed, 294 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/main.yml 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 000000000..540f1b10e --- /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/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..2aab882c5 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,60 @@ +name: Tests +on: + push: + branches: [ main, 'stable/*' ] + pull_request: + branches: [ main, 'stable/*' ] + +jobs: + tests: + name: tests-python${{ matrix.python-version }}-${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] + os: ["ubuntu-latest", "macOS-latest", "windows-latest"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version }}-pip-tests-${{ hashFiles('requirements.txt','requirements-dev.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version }}-pip-tests- + ${{ runner.os }}-${{ matrix.python-version }}-pip- + ${{ runner.os }}-${{ matrix.python-version }} + - name: Install Deps + run: | + python -m pip install -U tox setuptools virtualenv wheel + - name: Install and Run Tests + run: tox -e py + docs: + name: docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: setup-python-3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: install-requirements + run: | + sudo apt-get install -y graphviz pandoc + python -m pip install --upgrade pip tox + python -m pip install -e . + - name: docs + run: tox -e docs + - name: Compress Artifacts + run: | + mkdir artifacts + tar -zcvf html_docs.tar.gz docs/_build/html + mv html_docs.tar.gz artifacts/. + - uses: actions/upload-artifact@v2 + with: + name: html_docs + path: artifacts diff --git a/.gitignore b/.gitignore index 9f1b84946..baa01778d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,150 @@ +# SDK config file +Qconfig.py + +# ply outputs +qiskit/qasm/parser.out + +# editor files +.vscode/ +.idea/ + +#standard python ignores follow + +# Byte-compiled / optimized / DLL files +__pycache__/ +.pytest_cache/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +test/python/*.log +test/python/*.pdf +test/python/*.prof +.stestr/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject .DS_Store -docs/_build/* -docs/api/* +dummyscripts/* + +token.json + +tutorial/rst/_build/* + +test/python/test_qasm_python_simulator.pdf + +doc/_build/* + +doc/**/_autodoc + +qiskit/bin/* + +test/python/test_save.json + +test/python/*.tex + +out/* + +# CMake generates this file on the fly +qiskit/providers/local/qasm_simulator_cpp +qiskit/providers/legacysimulators/qasm_simulator_cpp + +src/qasm-simulator-cpp/test/qubit_vector_tests + +*.o + +# Cython pass +qiskit/transpiler/passes/**/cython/**/*.cpp +qiskit/quantum_info/states/cython/*.cpp + docs/stubs/* -docs/**/_autodoc + +# Notebook testing images +test/ipynb/mpl/*.png +test/ipynb/mpl/*.zip +test/ipynb/mpl/result_test.json diff --git a/requirements-dev.txt b/requirements-dev.txt index cd352acc6..669357920 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,3 @@ jupyter qiskit-aer +pytest diff --git a/requirements.txt b/requirements.txt index 536d29636..f0f0d90ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ qiskit-terra>=0.17 -qiskit-ibmq-provider>=0.13 \ No newline at end of file +qiskit-ibmq-provider diff --git a/tools/deploy_documentation.sh b/tools/deploy_documentation.sh new file mode 100755 index 000000000..d725492ea --- /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 ./_build/html IBMCOS:qiskit-org-web-resources/documentation/partners/qiskit_runtime 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 000000000..3f5583af8 --- /dev/null +++ b/tox.ini @@ -0,0 +1,24 @@ +[tox] +minversion = 2.1 +envlist = py36, py37, py38, py39, lint, docs + +[testenv] +deps = + -r requirements.txt + -r requirements-dev.txt + git+https://github.com/Qiskit/qiskit-ibmq-provider +usedevelop = true +setenv = + VIRTUAL_ENV={envdir} + LANGUAGE=en_US + LC_ALL=en_US.utf-8 +commands = + pytest + +[testenv:docs] +allowlist_externals = make +envdir = .tox/docs +deps = + -r requirements-docs.txt +commands = + sphinx-build -b html -W {posargs} docs/ docs/_build/html