Skip to content

Commit

Permalink
Merge pull request #42 from nitrictech/feature/release-workflow
Browse files Browse the repository at this point in the history
Release workflow
  • Loading branch information
jyecusch authored Sep 20, 2021
2 parents 1d3aafa + 941b583 commit 7d76a1b
Show file tree
Hide file tree
Showing 31 changed files with 191 additions and 152 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/draft_release.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
- name: Checkout
uses: actions/[email protected]
with:
token: ${{secrets.SUBMOD_PAT}}
submodules: recursive
fetch-depth: 0 # needed to retrieve most recent tag
- name: Set up Python 3.8
uses: actions/setup-python@v2
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/rc-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release Candidate
on:
pull_request:
types: [closed]
branches:
- 'develop'

jobs:
# Bump the SDK version
version_bump:
if: github.event.pull_request.merged == true
name: Bump Version and Create Release
runs-on: ubuntu-latest
outputs:
version_id: ${{ steps.tag_version.outputs.new_tag }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
# Don't commit tag
# this will be done as part of the release
dry_run: true
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: main,develop

- name: Calculate RC number
id: vars
run: echo "::set-output name=rc_num::$(git rev-list --merges --count origin/develop...origin/main)"

- name: Create a GitHub release
id: create_release
uses: actions/create-release@v1
env:
# Use NITRIC_BOT_TOKEN here to
# trigger release 'published' workflows
GITHUB_TOKEN: ${{ secrets.NITRIC_BOT_TOKEN }}
with:
prerelease: true
tag_name: ${{ steps.tag_version.outputs.new_tag }}-rc.${{ steps.vars.outputs.rc_num }}
release_name: Release ${{ steps.tag_version.outputs.new_tag }}-rc.${{ steps.vars.outputs.rc_num }}
body: ${{ steps.tag_version.outputs.changelog }}
37 changes: 37 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Production Release
on:
pull_request:
types: [closed]
branches:
- 'main'
jobs:
# Bump the SDK version
version_bump:
if: github.event.pull_request.merged == true
name: Bump Version and Create Release
runs-on: ubuntu-latest
outputs:
version_id: ${{ steps.tag_version.outputs.new_tag }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
# Use GITHUB_TOKEN here to prevent further workflows
# generated on 'tag' action
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
id: create_release
uses: actions/create-release@v1
env:
# Use NITRIC_BOT_TOKEN here to
# trigger release 'published' workflows
GITHUB_TOKEN: ${{ secrets.NITRIC_BOT_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
2 changes: 0 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install
run: make install
- name: Generate gRPC Client
run: make grpc-client
- name: Run Tox
# Run tox using the version of Python in `PATH`
run: tox -e py
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion contracts
Submodule contracts deleted from 43e281
11 changes: 1 addition & 10 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,8 @@ install:
@pip3 install -e .[dev]
@pre-commit install

OUTPUT="./nitric/proto"
CONTRACTS="./contracts/proto"

.PHONY: docs clean license

grpc-client:
@echo Generating Proto Sources
@echo $(OUTPUT)
@mkdir -p $(OUTPUT)
@python3 -m grpc_tools.protoc -I $(CONTRACTS) --python_betterproto_out=$(OUTPUT) ./contracts/proto/**/**/*.proto

docs:
@echo Generating SDK Documentation
@pdoc3 -f --html -o docs nitric
Expand All @@ -30,7 +21,7 @@ license:
@licenseheaders -t tools/apache-2.tmpl -o "Nitric Technologies Pty Ltd" -y 2021 -n "Nitric Python 3 SDK" -u "https://github.com/nitrictech/python-sdk" -d tests
@licenseheaders -t tools/apache-2.tmpl -o "Nitric Technologies Pty Ltd" -y 2021 -n "Nitric Python 3 SDK" -u "https://github.com/nitrictech/python-sdk" -d tools

build: clean install grpc-client license docs
build: clean install license docs
@echo Building sdist and wheel
@python3 setup.py sdist bdist_wheel

Expand Down
7 changes: 4 additions & 3 deletions nitric/api/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@

from nitric.api.const import MAX_SUB_COLLECTION_DEPTH
from nitric.api.exception import exception_from_grpc_error
from nitric.proto.nitric.document.v1 import (
from nitricapi.nitric.document.v1 import (
DocumentServiceStub,
Collection as CollectionMessage,
Key as KeyMessage,
Expression as ExpressionMessage,
ExpressionValue,
Document as DocumentMessage,
)

from nitric.utils import new_default_channel, _dict_from_struct, _struct_from_dict

NIL_DOC_ID = ""
Expand Down Expand Up @@ -228,7 +229,7 @@ def is_sub_collection(self):
return self.parent is not None

def to_collection_ref(self):
"""Return this collection group as a collection ref"""
"""Return this collection group as a collection ref."""
return CollectionRef(
self._documents,
self.name,
Expand All @@ -241,7 +242,7 @@ def to_collection_ref(self):

@staticmethod
def from_collection_ref(collectionRef: CollectionRef, documents: Documents) -> CollectionGroupRef:
"""Return a collection ref as a collection group"""
"""Return a collection ref as a collection group."""
if collectionRef.parent is not None:
return CollectionGroupRef(
documents,
Expand Down
2 changes: 1 addition & 1 deletion nitric/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from nitric.api.exception import exception_from_grpc_error
from nitric.utils import new_default_channel, _struct_from_dict
from nitric.proto.nitric.event.v1 import EventServiceStub, NitricEvent, TopicServiceStub
from nitricapi.nitric.event.v1 import EventServiceStub, NitricEvent, TopicServiceStub
from dataclasses import dataclass, field


Expand Down
4 changes: 2 additions & 2 deletions nitric/api/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class NitricServiceException(Exception):


class AbortedException(NitricServiceException):
"""The operation was aborted, typically due to a concurrency issue such as a sequencer check failure or
transaction abort."""
"""The operation was aborted, typically due to a concurrency issue such as a transaction abort."""

pass

Expand Down Expand Up @@ -144,6 +143,7 @@ class UnknownException(NitricServiceException):


def exception_from_grpc_error(error: GRPCError):
"""Translate a gRPC error to a nitric api exception."""
return exception_from_grpc_code(error.status.value, error.message)


Expand Down
2 changes: 1 addition & 1 deletion nitric/api/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from nitric.api.exception import FailedPreconditionException, exception_from_grpc_error, InvalidArgumentException
from nitric.utils import new_default_channel, _struct_from_dict, _dict_from_struct
from nitric.proto.nitric.queue.v1 import QueueServiceStub, NitricTask, FailedTask as WireFailedTask
from nitricapi.nitric.queue.v1 import QueueServiceStub, NitricTask, FailedTask as WireFailedTask
from dataclasses import dataclass, field


Expand Down
2 changes: 1 addition & 1 deletion nitric/api/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from nitric.api.exception import exception_from_grpc_error
from nitric.utils import new_default_channel
from nitric.proto.nitric.secret.v1 import SecretServiceStub, Secret as SecretMessage, SecretVersion as VersionMessage
from nitricapi.nitric.secret.v1 import SecretServiceStub, Secret as SecretMessage, SecretVersion as VersionMessage


class Secrets(object):
Expand Down
2 changes: 1 addition & 1 deletion nitric/api/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from nitric.api.exception import exception_from_grpc_error
from nitric.utils import new_default_channel
from nitric.proto.nitric.storage.v1 import StorageServiceStub
from nitricapi.nitric.storage.v1 import StorageServiceStub


class Storage(object):
Expand Down
2 changes: 1 addition & 1 deletion nitric/faas/faas.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from nitric.utils import new_default_channel
from nitric.faas import Trigger, Response
from nitric.proto.nitric.faas.v1 import FaasServiceStub, InitRequest, ClientMessage
from nitricapi.nitric.faas.v1 import FaasServiceStub, InitRequest, ClientMessage
import asyncio

Handler = Callable[
Expand Down
4 changes: 2 additions & 2 deletions nitric/faas/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import json
from dataclasses import dataclass, field
from typing import Union, Any
from nitric.proto.nitric.faas import v1
from nitric.proto.nitric.faas.v1 import TriggerResponse
from nitricapi.nitric.faas import v1
from nitricapi.nitric.faas.v1 import TriggerResponse


@dataclass(order=True)
Expand Down
9 changes: 7 additions & 2 deletions nitric/faas/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import betterproto

from nitric.proto.nitric.faas.v1 import TriggerRequest
from nitricapi.nitric.faas.v1 import TriggerRequest
from nitric.faas.response import Response, TopicResponseContext, HttpResponseContext, ResponseContext


Expand Down Expand Up @@ -94,9 +94,14 @@ def from_trigger_request(trigger_request: TriggerRequest):
"""Return a TriggerContext from a TriggerRequest."""
context_type, context = betterproto.which_one_of(trigger_request, "context")
if context_type == "http":
if len(trigger_request.http.headers.keys()) > 0:
new_headers = {k: v[0].value for (k, v) in trigger_request.http.headers.items()}
else:
new_headers = trigger_request.http.headers_old

return TriggerContext(
context=HttpTriggerContext(
headers=trigger_request.http.headers,
headers=new_headers,
method=trigger_request.http.method,
query_params=trigger_request.http.query_params,
path=trigger_request.http.path,
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,12 @@ def get_current_version_tag():
],
setup_requires=["wheel"],
install_requires=[
"nitric-api==0.12.0rc7",
"protobuf==3.13.0",
"betterproto==2.0.0b3",
"asyncio",
],
extras_require={
"dev": [
"betterproto[compiler]==2.0.0b3",
# "grpcio==1.33.2",
"grpcio-tools==1.33.2",
"tox==3.20.1",
"twine==3.2.0",
"pytest==6.0.1",
Expand Down
Loading

0 comments on commit 7d76a1b

Please sign in to comment.