From dd35df515fdc3131fe7a3d69d4970aed19c44753 Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Sun, 26 Jul 2020 01:15:51 +0200 Subject: [PATCH 1/3] ci: refactor jobs and improve platform coverage --- .github/workflows/ci.yml | 105 ++++++++++++++--------------- .github/workflows/code-quality.yml | 20 ++++++ .github/workflows/release.yml | 31 +++++++++ 3 files changed, 100 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/code-quality.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76d4f7a4f..018d90f30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,74 +1,67 @@ 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] 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/ diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 000000000..8ab34bd5a --- /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 000000000..755f34f6c --- /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 From 075c5b4326a212bcb9c491c9d76e609de7e7f10e Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Sun, 26 Jul 2020 01:44:21 +0200 Subject: [PATCH 2/3] generate: fix windows compatibility issue --- tests/generate.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/generate.py b/tests/generate.py index e24368eb3..6795ae6f6 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)) From 7287d93557924771de9e8536e84997d0bd8c0a9c Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Sun, 26 Jul 2020 01:50:10 +0200 Subject: [PATCH 3/3] ci: skip windows python 3.6 environment This is done so since github's windows environment cannot reliably compile datetime backports. --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 018d90f30..40a7f6fd3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,9 @@ jobs: 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