Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
Create a basic CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
talshani committed Aug 27, 2021
1 parent c618872 commit 93a82dc
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 3 deletions.
17 changes: 17 additions & 0 deletions .github/actions/install-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Install Poetry Action"
description: "Installs and configures Poetry"
inputs:
version:
description: "The Poetry version to install"
required: false
default: "1.1.7"
runs:
using: "composite"
steps:
- name: Install and configure Poetry
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade virtualenv
pip install poetry==${{ inputs.version }}
poetry config virtualenvs.in-project true
shell: bash
139 changes: 139 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Main

on:
pull_request:
branches: [ main ]

workflow_dispatch:
inputs:
version:
description: 'Release Version'
required: false
default: ''

jobs:

Validate-gRPC:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bufbuild/[email protected]
id: setup
- uses: bufbuild/[email protected]
if: ${{ steps.setup.outcome == 'success' }}
with:
input: 'proto'
- uses: bufbuild/[email protected]
if: ${{ steps.setup.outcome == 'success' }}
env:
BUF_INPUT_HTTPS_USERNAME: ${{ github.actor }}
BUF_INPUT_HTTPS_PASSWORD: ${{ github.token }}
with:
input: 'proto'
against: 'https://github.com/qua-platform/qua-sdk-py.git#branch=main,subdir=proto'
Build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.project-version.outputs.version }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install poetry
uses: ./.github/actions/install-poetry

- name: Setup venv Cache
id: cache-poetry-venv
uses: actions/cache@v2
with:
path: .venv
key: poetry-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
poetry-${{ runner.os }}-
- name: Create output directories
shell: bash
run: |
[ -d ${COVERAGE_REPORT_PATH} ] || mkdir -p ${COVERAGE_REPORT_PATH}
[ -d ${JUNIT_REPORT_PATH} ] || mkdir -p ${JUNIT_REPORT_PATH}
- name: Set up the project
run: poetry install

- name: Generate files
run: poetry run poe generate-grpc

- name: Check formatting
run: poetry run poe check-format

- name: Check linting
run: poetry run poe lint

- name: Test
run: poetry run poe test

- name: Build
run: poetry build

- name: Upload dist
uses: actions/upload-artifact@v2
with:
name: dist
path: |
dist/*.tar.gz
dist/*.whl
retention-days: 3

- name: Get version from project
id: project-version
run: echo ::set-output name=version::$(poetry version -s)

Release:
needs: [Build]
environment: PyPI Deployment
runs-on: ubuntu-latest
if: github.event.inputs.version != '' && github.event.inputs.version == needs.Build.outputs.version
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2

- name: Version release logic
id: version-logic
env:
RELEASE_VERSION: ${{ needs.Build.outputs.version }}
run: |
if [[ "$RELEASE_VERSION" == *"-"* ]]
then
echo '::set-output name=GITHUB_EXTRA_FLAG::-p'
echo '::set-output name=CHANGLOG_VERSION::Unreleased'
else
echo '::set-output name=GITHUB_EXTRA_FLAG::'
echo "::set-output name=CHANGLOG_VERSION::${RELEASE_VERSION}"
fi
- name: Extract version changelog
id: extracted-changelog
uses: talshani/[email protected]
with:
version: ${{ steps.version-logic.outputs.CHANGLOG_VERSION }}

- name: Create GitHub release
run: |
zip -r "proto-${RELEASE_VERSION}.zip" proto
gh release create v${RELEASE_VERSION} ${EXTRA_FLAG} --notes "${RELEASE_NOTES}" \
dist/qua-*.tar.gz \
dist/qua-*-py3-none-any.whl \
proto-${RELEASE_VERSION}.zip
env:
RELEASE_NOTES: ${{ steps.extracted-changelog.outputs.body }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ needs.Build.outputs.version }}
EXTRA_FLAG: ${{ steps.version-logic.outputs.GITHUB_EXTRA_FLAG }}

- name: Publish distribution 📦 to Test PyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.0-rc1] 2021-08-26

### Added

* Basic QUA Client connecting to the info service collecting capabilities
Expand Down
87 changes: 86 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ version = "0.1.0-rc1"
description = "SDK to interact with a quantum computer at the pulse level"
authors = ["Tal Shani <[email protected]>"]
license = "BSD-3-Clause"
repository = "https://github.com/qua-platform/qua-sdk-py"
readme = "README.md"
include = [
"CHANGELOG.md",
"LICENSE",
Expand All @@ -27,6 +29,7 @@ flake8-bugbear = "^21.4.3"
poethepoet = "^0.10.0"
grpcio-tools = "^1.39.0"
betterproto = {extras = ["compiler"], version = "^1.2.5"}
pytest-cov = "^2.12.1"

[tool.poe.tasks]

Expand Down

0 comments on commit 93a82dc

Please sign in to comment.