Skip to content

Commit

Permalink
Add CI configuration (Qiskit#8)
Browse files Browse the repository at this point in the history
* 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`.
  • Loading branch information
mtreinish authored May 6, 2021
1 parent 16244b4 commit 870539d
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 4 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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
149 changes: 146 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
jupyter
qiskit-aer
pytest
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
qiskit-terra>=0.17
qiskit-ibmq-provider>=0.13
qiskit-ibmq-provider
33 changes: 33 additions & 0 deletions tools/deploy_documentation.sh
Original file line number Diff line number Diff line change
@@ -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
Binary file added tools/rclone.conf.enc
Binary file not shown.
24 changes: 24 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 870539d

Please sign in to comment.