diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76d4f7a..40a7f6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - 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- - - name: Install dependencies - run: poetry install - - name: Run black - run: poetry run poe check-style - - run-tests: - runs-on: ubuntu-latest - - name: Run tests with tox - + tests: + name: ${{ matrix.os }} / ${{ matrix.python-version }} + runs-on: ${{ matrix.os }}-latest strategy: matrix: - python-version: [ '3.6', '3.7', '3.8'] - + 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 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 with: python-version: ${{ matrix.python-version }} - - uses: Gr1N/setup-poetry@v2 - - uses: actions/cache@v2 + + - 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: Install poetry + shell: bash + run: | + python -m pip install poetry + echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH" + + - name: Configure poetry + shell: bash + run: poetry config virtualenvs.in-project true + + - name: Set up cache + uses: actions/cache@v2 + id: cache 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/ diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 0000000..8ab34bd --- /dev/null +++ b/.github/workflows/code-quality.yml @@ -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/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..755f34f --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/tests/generate.py b/tests/generate.py index e24368e..6795ae6 100755 --- a/tests/generate.py +++ b/tests/generate.py @@ -2,6 +2,7 @@ import asyncio import os from pathlib import Path +import platform import shutil import sys from typing import Set @@ -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))