Skip to content

Commit

Permalink
Configure CI for RC releases
Browse files Browse the repository at this point in the history
  • Loading branch information
ameyer-rigetti committed Mar 20, 2021
1 parent 7255b41 commit 2387a76
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 119 deletions.
212 changes: 96 additions & 116 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,6 @@ cache:
- poetry config http-basic.testpypi rigetti $TEST_PYPI_PASSWORD
- poetry publish --build -r testpypi

.docker:
image: docker:git
stage: docker
tags:
- dockerd
script:
- export VERSION_TAG=$(cat version_tag)
- docker -v
- echo ${IMAGE}
- echo ${DOCKERHUB_PASSWORD} | docker login -u ${DOCKERHUB_USERNAME} --password-stdin
- docker build --build-arg pyquil_version=${VERSION_TAG} --build-arg primary_index_url=${PRIMARY_INDEX_URL} -t ${IMAGE}:${VERSION_TAG} -t ${IMAGE}:${EXTRA_TAG} .
- docker push ${IMAGE}:${VERSION_TAG} && docker push ${IMAGE}:${EXTRA_TAG}
after_script:
- docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' | grep ${IMAGE})
- docker run --rm ${IMAGE}:${VERSION_TAG} python -c "from pyquil import get_qc; qvm = get_qc('9q-qvm')" # simple image verification
- docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' | grep ${IMAGE})
# sometimes pyquil isn't ready on PyPI right away, so add a retry if docker build fails
retry:
max: 2
when: script_failure

# global build variables
variables:
IMAGE: rigetti/forest
Expand All @@ -83,143 +62,144 @@ services:
# EVERY-COMMIT JOBS
####################################################################################################

Test Docs:
stage: test
script:
- *install-dependencies
- apt-get update && apt-get install -y pandoc
- poetry run make docs

Style:
stage: test
script:
- *install-dependencies
- poetry run make check-all
rules:
# Skip this job if it was triggered by a tag
- if: "$CI_COMMIT_TAG"
when: never
- when: always

Test (3.7):
stage: test
image: python:3.7
coverage: '/TOTAL.*?(\d+)\%/'
script:
- *install-dependencies
- poetry run make test

Test (3.8):
stage: test
image: python:3.8
coverage: '/TOTAL.*?(\d+)\%/'
script:
- *install-dependencies
- poetry run make test

Coverage:
stage: test
script:
- *install-dependencies
- poetry run make coverage
allow_failure: true
#Test Docs:
# stage: test
# script:
# - *install-dependencies
# - apt-get update && apt-get install -y pandoc
# - poetry run make docs
#
#Style:
# stage: test
# script:
# - *install-dependencies
# - poetry run make check-all
# rules:
# # Skip this job if it was triggered by a tag
# - if: "$CI_COMMIT_TAG"
# when: never
# - when: always
#
#Test (3.7):
# stage: test
# image: python:3.7
# coverage: '/TOTAL.*?(\d+)\%/'
# script:
# - *install-dependencies
# - poetry run make test
#
#Test (3.8):
# stage: test
# image: python:3.8
# coverage: '/TOTAL.*?(\d+)\%/'
# script:
# - *install-dependencies
# - poetry run make test
#
#Coverage:
# stage: test
# script:
# - *install-dependencies
# - poetry run make coverage
# allow_failure: true


####################################################################################################
# MASTER-ONLY JOBS
# BRANCH-ONLY JOBS
####################################################################################################

PyPI Publish (Edge):
PyPI Publish Branch (TestPyPI):
stage: deploy
script:
- *install-dependencies
- *install-dephell
- *install-npm
- npx semantic-release --branches master --dry-run
- npx semantic-release --branches $CI_COMMIT_BRANCH --dry-run
- export MOST_RECENT_VERSION=$(git describe --abbrev=0 --tags | sed 's/v//')
- export VERSION_TAG="${MOST_RECENT_VERSION}.dev${CI_JOB_ID}"
- poetry version "$VERSION_TAG"
- dephell deps convert
- *publish-pypi-test
- poetry version -s >> version_tag
artifacts:
paths:
- version_tag
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
when: always

Docker Publish (Edge):
extends: .docker
needs: ["PyPI Publish (Edge)"]
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
variables:
PRIMARY_INDEX_URL: https://test.pypi.org/simple/
EXTRA_TAG: edge
# Skip this job if running on master or rc
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH != "rc"'
when: manual


####################################################################################################
# BRANCH-ONLY JOBS
# RELEASE-ONLY JOBS
####################################################################################################

PyPI Publish (Branch):
.pypi-publish:
stage: deploy
script:
- *install-dependencies
- *install-dephell
- *install-npm
- npx semantic-release --branches $CI_COMMIT_BRANCH --dry-run
- export MOST_RECENT_VERSION=$(git describe --abbrev=0 --tags | sed 's/v//')
- export VERSION_TAG="${MOST_RECENT_VERSION}.dev${CI_JOB_ID}"
- poetry version "$VERSION_TAG"
- dephell deps convert
- *publish-pypi-test
# This performs the semantic-release configured in package.json.
# Depending on the config, this may add a tag and then publish a GitLab/GitHub release.
- npx semantic-release
# This reads the tag chosen by semantic-release
- *publish-pypi-public
- poetry version -s >> version_tag
artifacts:
paths:
- version_tag

.docker-publish:
image: docker:git
stage: docker
tags:
- dockerd
script:
- export VERSION_TAG=$(cat version_tag)
- echo "Publishing images:"
- echo " ${IMAGE}:${VERSION_TAG}"
- echo " ${IMAGE}:${EXTRA_TAG}"
- docker -v
- echo ${DOCKERHUB_PASSWORD} | docker login -u ${DOCKERHUB_USERNAME} --password-stdin
- docker build --build-arg pyquil_version=${VERSION_TAG} -t ${IMAGE}:${VERSION_TAG} -t ${IMAGE}:${EXTRA_TAG} .
- docker push ${IMAGE}:${VERSION_TAG} && docker push ${IMAGE}:${EXTRA_TAG}
after_script:
- docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' | grep ${IMAGE})
- docker run --rm ${IMAGE}:${VERSION_TAG} python -c "from pyquil import get_qc; qvm = get_qc('9q-qvm')" # simple image verification
- docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' | grep ${IMAGE})
# sometimes pyquil isn't ready on PyPI right away, so add a retry if docker build fails
retry:
max: 2
when: script_failure


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

PyPI Publish (RC):
extends: .pypi-publish
rules:
# Skip this job if running on master
- if: "$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH"
- if: '$CI_COMMIT_BRANCH == "rc"'
when: manual

Docker Publish (Branch):
extends: .docker
needs: ["PyPI Publish (Branch)"]
Docker Publish (RC):
extends: .docker-publish
needs: ["PyPI Publish (RC)"]
rules:
- if: "$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH"
- if: '$CI_COMMIT_BRANCH == "rc"'
variables:
PRIMARY_INDEX_URL: https://test.pypi.org/simple/
EXTRA_TAG: ${CI_COMMIT_SHORT_SHA}
EXTRA_TAG: rc


####################################################################################################
# RELEASE-ONLY JOBS
####################################################################################################
# PUBLISH FINAL RELEASE
# -------------------------------

PyPI Publish (Release):
stage: deploy
script:
- *install-dependencies
- *install-dephell
- *install-npm
# This performs the semantic-release configured in package.json.
# Depending on the config, this may add a tag and then push a release to Gitlab.
- npx semantic-release --branches master
# This reads the tag chosen by semantic-release
- *publish-pypi-public
- poetry version -s >> version_tag
artifacts:
paths:
- version_tag
PyPI Publish (Final):
extends: .pypi-publish
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
when: manual

Docker Publish (Release):
extends: .docker
needs: ["PyPI Publish (Release)"]
Docker Publish (Final):
extends: .docker-publish
needs: ["PyPI Publish (Final)"]
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
variables:
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ FROM rigetti/qvm:$qvm_version as qvm
FROM python:$python_version

ARG pyquil_version
ARG primary_index_url

# copy over the pre-built quilc binary from the first build stage
COPY --from=quilc /src/quilc/quilc /src/quilc/quilc
Expand All @@ -27,7 +26,7 @@ RUN apt-get update && apt-get -yq dist-upgrade && \
RUN pip install --no-cache-dir ipython

# install pyquil
RUN pip install --index-url $primary_index_url --extra-index-url https://pypi.org/simple pyquil==$pyquil_version
RUN pip install pyquil==$pyquil_version

# use an entrypoint script to add startup commands (qvm & quilc server spinup)
COPY ./entrypoint.sh /src/pyquil/entrypoint.sh
Expand Down
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": ["master"],
"branches": ["master", {"name": "rc", "prerelease": true}],
"plugins": [
["@semantic-release/commit-analyzer",{
"preset": "eslint",
Expand Down

0 comments on commit 2387a76

Please sign in to comment.