Skip to content

Commit

Permalink
[chore] switch to Drone CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Gr1N committed Jul 23, 2019
1 parent 436eb69 commit c5e00f3
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 93 deletions.
118 changes: 118 additions & 0 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
local
volume_cached_poetry = 'cached-poetry',
volume_cached_deps = 'cached-deps',

git_step = {
name: 'fetch',
image: 'docker:git',
commands: ['git fetch --tags'],
},
py_step(name, commands, version='3.7') = {
name: name,
pull: 'always',
image: 'python:%s' % version,
commands: commands,
volumes: [
{
name: volume_cached_poetry,
path: '/root/.poetry',
},
{
name: volume_cached_deps,
path: '/root/.cache/pypoetry/virtualenvs',
},
],
},
notify_step(name, message) = {
name: name,
pull: 'always',
image: 'appleboy/drone-telegram',
environment: {
PLUGIN_TOKEN: {
from_secret: 'TELEGRAM_BOT_TOKEN',
},
PLUGIN_TO: {
from_secret: 'TELEGRAM_CHAT_ID',
},
PLUGIN_MESSAGE: message,
},
};

{
kind: 'pipeline',
name: 'default',
clone: {
depth: 50,
},
steps: [
git_step,
py_step('deps-3.6', ['make install'], version='3.6'),
py_step('deps-3.7', ['make install']),
py_step('lint-3.7', ['make lint']),
py_step('test-3.6', ['make test'], version='3.6'),
py_step('test-3.7', ['make test', 'make codecov']) {
environment: {
CODECOV_TOKEN: {
from_secret: 'CODECOV_TOKEN',
},
},
},
notify_step('lint/test completed', |||
{{#success build.status}}
`{{repo.name}}` build {{build.number}} succeeded. Good job.
{{else}}
`{{repo.name}}` build {{build.number}} failed. Fix me please.
{{/success}}
|||) {
when: {
branch: ['master'],
event: {
exclude:
['pull_request'],
},
status: [
'success',
'failure',
],
},
},
py_step('publish', ['make publish']) {
environment: {
PYPI_USERNAME: {
from_secret: 'PYPI_USERNAME',
},
PYPI_PASSWORD: {
from_secret: 'PYPI_PASSWORD',
},
},
when: {
event: ['tag'],
},
},
notify_step('publish completed', |||
{{#success build.status}}
`{{repo.name}}` publish {{build.tag}} succeeded. Good job.
{{else}}
`{{repo.name}}` publish {{build.tag}} failed. Fix me please.
{{/success}}
|||) {
when: {
event: ['tag'],
status: [
'success',
'failure',
],
},
},
],
volumes: [
{
name: volume_cached_poetry,
temp: {},
},
{
name: volume_cached_deps,
temp: {},
},
],
}
137 changes: 137 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
kind: pipeline
name: default

platform:
os: linux
arch: amd64

clone:
depth: 50

steps:
- name: fetch
image: docker:git
commands:
- git fetch --tags

- name: deps-3.6
pull: always
image: python:3.6
commands:
- make install
volumes:
- name: cached-poetry
path: /root/.poetry
- name: cached-deps
path: /root/.cache/pypoetry/virtualenvs

- name: deps-3.7
pull: always
image: python:3.7
commands:
- make install
volumes:
- name: cached-poetry
path: /root/.poetry
- name: cached-deps
path: /root/.cache/pypoetry/virtualenvs

- name: lint-3.7
pull: always
image: python:3.7
commands:
- make lint
volumes:
- name: cached-poetry
path: /root/.poetry
- name: cached-deps
path: /root/.cache/pypoetry/virtualenvs

- name: test-3.6
pull: always
image: python:3.6
commands:
- make test
volumes:
- name: cached-poetry
path: /root/.poetry
- name: cached-deps
path: /root/.cache/pypoetry/virtualenvs

- name: test-3.7
pull: always
image: python:3.7
commands:
- make test
- make codecov
environment:
CODECOV_TOKEN:
from_secret: CODECOV_TOKEN
volumes:
- name: cached-poetry
path: /root/.poetry
- name: cached-deps
path: /root/.cache/pypoetry/virtualenvs

- name: lint/test completed
pull: always
image: appleboy/drone-telegram
environment:
PLUGIN_MESSAGE: "{{#success build.status}}\n `{{repo.name}}` build {{build.number}} succeeded. Good job.\n{{else}}\n `{{repo.name}}` build {{build.number}} failed. Fix me please.\n{{/success}}\n"
PLUGIN_TO:
from_secret: TELEGRAM_CHAT_ID
PLUGIN_TOKEN:
from_secret: TELEGRAM_BOT_TOKEN
when:
branch:
- master
event:
exclude:
- pull_request
status:
- success
- failure

- name: publish
pull: always
image: python:3.7
commands:
- make publish
environment:
PYPI_PASSWORD:
from_secret: PYPI_PASSWORD
PYPI_USERNAME:
from_secret: PYPI_USERNAME
volumes:
- name: cached-poetry
path: /root/.poetry
- name: cached-deps
path: /root/.cache/pypoetry/virtualenvs
when:
event:
- tag

- name: publish completed
pull: always
image: appleboy/drone-telegram
environment:
PLUGIN_MESSAGE: "{{#success build.status}}\n `{{repo.name}}` publish {{build.tag}} succeeded. Good job.\n{{else}}\n `{{repo.name}}` publish {{build.tag}} failed. Fix me please.\n{{/success}}\n"
PLUGIN_TO:
from_secret: TELEGRAM_CHAT_ID
PLUGIN_TOKEN:
from_secret: TELEGRAM_BOT_TOKEN
when:
event:
- tag
status:
- success
- failure

volumes:
- name: cached-poetry
temp: {}
- name: cached-deps
temp: {}

...
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{hcl,md,toml,yml}]
[*.{jsonnet,md,toml,yml}]
indent_style = space
indent_size = 2

Expand Down
79 changes: 0 additions & 79 deletions .github/main.workflow

This file was deleted.

14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,10 @@ lint: lint-black lint-flake8 lint-isort lint-mypy
test:
@$(POETRY) run pytest --cov-report term --cov-report html --cov=aiodogstatsd -vv

.PHONY: codecov
codecov:
@$(POETRY) run codecov --token=$(CODECOV_TOKEN)

.PHONY: publish
publish:
@$(POETRY) publish --username=$(PYPI_USERNAME) --password=$(PYPI_PASSWORD) --build

.PHONY: ci-quality-basic
ci-quality-basic: install lint test

.PHONY: ci-quality
ci-quality: ci-quality-basic
@$(POETRY) run codecov --token=$(CODECOV_TOKEN)

.PHONY: ci-publish
ci-publish: install-poetry publish
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# aiodogstatsd

![GitHub commit merge status](https://img.shields.io/github/commit-status/Gr1N/aiodogstatsd/master/HEAD.svg?label=build%20status) [![codecov](https://codecov.io/gh/Gr1N/aiodogstatsd/branch/master/graph/badge.svg)](https://codecov.io/gh/Gr1N/aiodogstatsd) ![PyPI](https://img.shields.io/pypi/v/aiodogstatsd.svg?label=pypi%20version) ![PyPI - Downloads](https://img.shields.io/pypi/dm/aiodogstatsd.svg?label=pypi%20downloads) ![GitHub](https://img.shields.io/github/license/Gr1N/aiodogstatsd.svg)
[![Build Status](https://cloud.drone.io/api/badges/Gr1N/aiodogstatsd/status.svg)](https://cloud.drone.io/Gr1N/aiodogstatsd) [![codecov](https://codecov.io/gh/Gr1N/aiodogstatsd/branch/master/graph/badge.svg)](https://codecov.io/gh/Gr1N/aiodogstatsd) ![PyPI](https://img.shields.io/pypi/v/aiodogstatsd.svg?label=pypi%20version) ![PyPI - Downloads](https://img.shields.io/pypi/dm/aiodogstatsd.svg?label=pypi%20downloads) ![GitHub](https://img.shields.io/github/license/Gr1N/aiodogstatsd.svg)

An asyncio-based client for sending metrics to StatsD with support of [DogStatsD](https://docs.datadoghq.com/developers/dogstatsd/) extension.

Expand Down
4 changes: 2 additions & 2 deletions aiodogstatsd/contrib/aiohttp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import AsyncIterator, Callable, Optional
from typing import AsyncIterator, Callable, Optional, cast

from aiohttp import web
from aiohttp.web_app import _Middleware
Expand Down Expand Up @@ -68,7 +68,7 @@ async def middleware(
response_status = e.status
raise e
except Exception as e:
response_status = HTTPStatus.INTERNAL_SERVER_ERROR.value
response_status = cast(int, HTTPStatus.INTERNAL_SERVER_ERROR.value)
raise e
finally:
if _proceed_collecting( # pragma: no branch
Expand Down

0 comments on commit c5e00f3

Please sign in to comment.