Skip to content

Commit

Permalink
Chore: Support prerelease versions in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
erichulburd authored and dbanty committed May 26, 2022
1 parent 7ce99b7 commit deed39a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ jobs:
# This is an exact match list, new dependencies will likely require their own entries
run: |
. scripts/ci_install_deps
poetry run pip-licenses --allow-only="MIT License;Apache Software License;BSD License;GNU Lesser General Public License v2 or later (LGPLv2+);Python Software Foundation License;Apache License 2.0;new BSD;Apache-2.0;ISCL;ISC License (ISCL);BSD;Mozilla Public License 2.0 (MPL 2.0)"
# poetry run pip-licenses --allow-only="MIT License;Apache Software License;BSD License;GNU Lesser General Public License v2 or later (LGPLv2+);Python Software Foundation License;Apache License 2.0;new BSD;Apache-2.0;ISCL;ISC License (ISCL);BSD;Mozilla Public License 2.0 (MPL 2.0)"
41 changes: 26 additions & 15 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,12 @@ cache:
- poetry run python -m ensurepip --upgrade
- poetry install -vv

.install-dephell: &install-dephell # Install dephell to auto-generate setup.py
- curl -L https://raw.githubusercontent.com/rigetti/dephell/master/install.py | python

.install-npm: &install-npm
- curl -sL https://deb.nodesource.com/setup_12.x | bash -
- apt-get update
- apt-get install -f -y nodejs
- npm i

.publish-pypi-public: &publish-pypi-public
- poetry config http-basic.pypi $PUBLIC_PYPI_USERNAME $PUBLIC_PYPI_PASSWORD
- poetry publish --build

Checks:
stage: test
script:
Expand Down Expand Up @@ -70,17 +63,35 @@ Test Unit (3.9):
extends: .unit-test
image: python:3.9

PyPi Publish Release:
.pypi-publish:
stage: deploy
script:
- *install-dependencies
- *install-dephell
before_script:
- . scripts/ci_install_deps
- *install-npm
script:
# This performs the semantic-release configured in package.json.
# Depending on the config, this may add a tag and then push a release to GitHub.
- npx semantic-release
# Depending on the config, this may add a tag and then publish a GitLab/GitHub release.
- npx semantic-release --debug
- poetry version -s >> version_tag
# This reads the tag chosen by semantic-release
- *publish-pypi-public
- poetry config http-basic.pypi $PUBLIC_PYPI_USERNAME $PUBLIC_PYPI_PASSWORD
- poetry publish --build
artifacts:
paths:
- version_tag
when: always

# PUBLISH RC
# -------------------------------

PyPI Publish (RC):
extends: .pypi-publish
rules:
- if: '$CI_COMMIT_BRANCH == "rc"'
when: manual

PyPI Publish (Final):
extends: .pypi-publish
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
when: on_success
when: manual
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"semantic-release": "^17.1.1"
},
"release": {
"branches": ["main"],
"branches": ["main", {"name": "rc", "prerelease": true}],
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "eslint",
Expand Down
4 changes: 2 additions & 2 deletions prepare_release.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
poetry version $1
dephell deps convert
echo "updating library version to $1"
poetry version "$1"
poetry run black setup.py
17 changes: 8 additions & 9 deletions tests/test_qcs_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,30 @@
##############################################################################
from pytest_httpx import HTTPXMock
import pytest
import os

from qiskit_rigetti import RigettiQCSProvider, GetQuantumProcessorException


def test_get_simulator(monkeypatch):
monkeypatch.delenv("QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL", raising=False)

backend = RigettiQCSProvider().get_simulator(num_qubits=42)

assert backend.name() == "42q-qvm"
assert backend.configuration().num_qubits == 42
assert backend.configuration().local is True
assert backend.configuration().simulator is True
assert (
"qvm:" not in os.getenv("QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL", "127.0.0.1")
) == backend.configuration().local
assert backend.configuration().simulator
assert backend.configuration().coupling_map


def test_get_simulator__noisy(monkeypatch):
monkeypatch.delenv("QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL", raising=False)

backend = RigettiQCSProvider().get_simulator(num_qubits=42, noisy=True)

assert backend.name() == "42q-noisy-qvm"
assert backend.configuration().num_qubits == 42
assert backend.configuration().local is True
assert backend.configuration().simulator is True

assert ("qvm:" not in os.getenv("QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL", "")) == backend.configuration().local
assert backend.configuration().simulator
assert backend.configuration().coupling_map


Expand Down

0 comments on commit deed39a

Please sign in to comment.