-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from qutip/feature/add-build-workflows
Add build and documentation build workflows.
- Loading branch information
Showing
45 changed files
with
365 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
name: Build wheels, optionally deploy to PyPI | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
confirm_ref: | ||
description: "Confirm chosen branch name to deploy to PyPI (optional):" | ||
default: "" | ||
override_version: | ||
description: "Override version number (optional):" | ||
default: "" | ||
|
||
|
||
jobs: | ||
# The deploy_test job is part of the test of whether we should deploy to PyPI. | ||
# The job will succeed if either the confirmation reference is empty or if the | ||
# confirmation is the selected branch or tag name. It will fail if it is | ||
# nonempty and does not match. All later jobs depend on this job, so that | ||
# they will be immediately cancelled if the confirmation is bad. The | ||
# dependency is currently necessary (2021-03) because GitHub Actions does not | ||
# have a simpler method of cancelling an entire workflow---the normal use-case | ||
# expects to try and run as much as possible despite one or two failures. | ||
deploy_test: | ||
name: Verify PyPI deployment confirmation | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_REF: ${{ github.ref }} | ||
CONFIRM_REF: ${{ github.event.inputs.confirm_ref }} | ||
steps: | ||
- name: Compare confirmation to current reference | ||
shell: bash | ||
run: | | ||
[[ -z $CONFIRM_REF || $GITHUB_REF =~ ^refs/(heads|tags)/$CONFIRM_REF$ ]] | ||
if [[ -z $CONFIRM_REF ]]; then | ||
echo "Build only. Nothing will be uploaded to PyPI." | ||
else | ||
echo "Full build and deploy. Wheels and source will be uploaded to PyPI." | ||
fi | ||
build_sdist: | ||
name: Build sdist on Ubuntu | ||
needs: deploy_test | ||
runs-on: ubuntu-latest | ||
env: | ||
OVERRIDE_VERSION: ${{ github.event.inputs.override_version }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-python@v2 | ||
name: Install Python | ||
with: | ||
# For the sdist we should be as conservative as possible with our | ||
# Python version. This should be the lowest supported version. This | ||
# means that no unsupported syntax can sneak through. | ||
python-version: '3.6' | ||
|
||
- name: Install pip build | ||
run: | | ||
python -m pip install 'build' | ||
- name: Build sdist tarball | ||
shell: bash | ||
run: | | ||
if [[ ! -z "$OVERRIDE_VERSION" ]]; then echo "$OVERRIDE_VERSION" > VERSION; fi | ||
# The build package is the reference PEP 517 package builder. All | ||
# dependencies are specified by our setup code. | ||
python -m build --sdist . | ||
# Zip files are not part of PEP 517, so we need to make our own. | ||
- name: Create zipfile from tarball | ||
shell: bash | ||
working-directory: dist | ||
run: | | ||
# First assert that there is exactly one tarball, and find its name. | ||
shopt -s failglob | ||
tarball_pattern="*.tar.gz" | ||
tarballs=($tarball_pattern) | ||
[[ ${#tarballs[@]} == 1 ]] | ||
tarball="${tarballs[0]}" | ||
# Get the stem and make the zipfile name. | ||
stem="${tarball%.tar.gz}" | ||
zipfile="${stem}.zip" | ||
# Extract the tarball and rezip it. | ||
tar -xzf "$tarball" | ||
zip "$zipfile" -r "$stem" | ||
rm -r "$stem" | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: sdist | ||
path: | | ||
dist/*.tar.gz | ||
dist/*.zip | ||
if-no-files-found: error | ||
|
||
|
||
build_wheels: | ||
name: Build wheels | ||
needs: deploy_test | ||
runs-on: ubuntu-latest | ||
env: | ||
OVERRIDE_VERSION: ${{ github.event.inputs.override_version }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-python@v2 | ||
name: Install Python | ||
with: | ||
# This is about the build environment, not the released wheel version. | ||
python-version: '3.7' | ||
|
||
- name: Install pip build | ||
run: | | ||
python -m pip install 'build' | ||
- name: Build wheels | ||
shell: bash | ||
run: | | ||
# If the version override was specified, then write it the VERSION | ||
# file with it. | ||
if [[ ! -z "$OVERRIDE_VERSION" ]]; then echo "$OVERRIDE_VERSION" > VERSION; fi | ||
# The build package is the reference PEP 517 package builder. All | ||
# dependencies are specified by our setup code. | ||
python -m build --wheel --outdir wheelhouse . | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: wheels | ||
path: ./wheelhouse/*.whl | ||
|
||
|
||
deploy: | ||
name: "Deploy to PyPI if desired" | ||
# The confirmation is tested explicitly in `deploy_test`, so we know it is | ||
# either a missing confirmation (so we shouldn't run this job) or a valid | ||
# confirmation. We don't need to retest the value of the confirmation, | ||
# beyond checking that one existed. | ||
if: ${{ github.event.inputs.confirm_ref != '' }} | ||
needs: [deploy_test, build_sdist, build_wheels] | ||
runs-on: ubuntu-latest | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | ||
TWINE_NON_INTERACTIVE: 1 | ||
TWINE_REPOSITORY: pypi | ||
|
||
steps: | ||
- name: Download build artifacts to local runner | ||
uses: actions/download-artifact@v2 | ||
|
||
- uses: actions/setup-python@v2 | ||
name: Install Python | ||
with: | ||
python-version: '3.7' | ||
|
||
- name: Verify this is not a dev version | ||
shell: bash | ||
run: | | ||
python -m pip install wheels/*.whl | ||
python -c 'import qutip_qip; print(qutip_qip.__version__); assert "dev" not in qutip_qip.__version__; assert "+" not in qutip_qip.__version__' | ||
# We built the zipfile for convenience distributing to Windows users on | ||
# our end, but PyPI only needs the tarball. | ||
- name: Upload sdist and wheels to PyPI | ||
run: | | ||
python -m pip install "twine" | ||
python -m twine upload --verbose wheels/*.whl sdist/*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Build HTML documentation | ||
|
||
on: | ||
[push, pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Build documentation | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-python@v2 | ||
name: Install Python | ||
with: | ||
python-version: '3.8' | ||
|
||
- name: Install documentation dependencies | ||
run: | | ||
python -mpip install -r doc/requirements.txt | ||
- name: Install qutip-qip from GitHub | ||
run: | | ||
python -mpip install -e .[full] | ||
# Install in editable mode so it doesn't matter if we import from | ||
# inside the installation directory, otherwise we can get some errors | ||
# because we're importing from the wrong location. | ||
python -c 'import qutip_qip; print("QuTiP QIP Version: %s" % qutip_qip.__version__)' | ||
python -c 'import qutip; qutip.about()' | ||
- name: Build documentation | ||
working-directory: doc | ||
run: | | ||
make html SPHINXOPTS="-W --keep-going -T" | ||
# Above flags are: | ||
# -W : turn warnings into errors | ||
# --keep-going : do not stop after the first error | ||
# -T : display a full traceback if a Python exception occurs | ||
- name: Upload built files | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: qutip_qip_html_docs | ||
path: doc/_build/html/* | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ instance/ | |
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
doc/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.2.0.dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ sphinx_rtd_theme==0.5.1 | |
readthedocs-sphinx-search==0.1.0rc3 | ||
numpydoc==1.1.0 | ||
matplotlib==3.3.4 | ||
docutils==0.16 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.