Skip to content

ci: refactor jobs and improve platform coverage #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 52 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,69 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:

check-formatting:
runs-on: ubuntu-latest

name: Consult black on python formatting

tests:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [Ubuntu, MacOS, Windows]
python-version: [3.6, 3.7, 3.8]
exclude:
- os: Windows
python-version: 3.6
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.7
- uses: Gr1N/setup-poetry@v2
- uses: actions/cache@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install dependencies
run: poetry install
- name: Run black
run: poetry run poe check-style
python-version: ${{ matrix.python-version }}

run-tests:
runs-on: ubuntu-latest
- name: Get full Python version
id: full-python-version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

name: Run tests with tox
- name: Install poetry
shell: bash
run: |
python -m pip install poetry
echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH"

strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8']
- name: Configure poetry
shell: bash
run: poetry config virtualenvs.in-project true

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Set up cache
uses: actions/cache@v2
id: cache
with:
python-version: ${{ matrix.python-version }}
- uses: Gr1N/setup-poetry@v2
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
shell: bash
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv

- name: Install dependencies
shell: bash
run: |
poetry run pip install --upgrade pip
poetry run python -m pip install pip -U
poetry install
- name: Run tests
run: |
poetry run poe generate
poetry run poe test

build-release:
runs-on: ubuntu-latest
- name: Generate code from proto files
shell: bash
run: poetry run python -m tests.generate -v

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.7
- uses: Gr1N/setup-poetry@v2
- name: Build package
run: poetry build
- name: Publish package to PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
run: poetry publish -n
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.pypi }}
- name: Execute test suite
shell: bash
run: poetry run pytest tests/
20 changes: 20 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Code Quality

on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
black:
name: Black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Black
uses: lgeiger/black-action@master
with:
args: --check src/ tests/
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release

on:
push:
branches:
- master
tags:
- '**'
pull_request:
branches:
- '**'

jobs:
packaging:
name: Distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install poetry
run: python -m pip install poetry
- name: Build package
run: poetry build
- name: Publish package to PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.pypi }}
run: poetry publish -n
5 changes: 5 additions & 0 deletions tests/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import asyncio
import os
from pathlib import Path
import platform
import shutil
import sys
from typing import Set
Expand Down Expand Up @@ -134,6 +135,10 @@ def main():
else:
verbose = False
whitelist = set(sys.argv[1:])

if platform.system() == "Windows":
asyncio.set_event_loop(asyncio.ProactorEventLoop())

asyncio.get_event_loop().run_until_complete(generate(whitelist, verbose))


Expand Down