Skip to content

Commit dd35df5

Browse files
committed
ci: refactor jobs and improve platform coverage
1 parent 3d8c0cb commit dd35df5

File tree

3 files changed

+100
-56
lines changed

3 files changed

+100
-56
lines changed

.github/workflows/ci.yml

+49-56
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,67 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- '**'
410

511
jobs:
6-
7-
check-formatting:
8-
runs-on: ubuntu-latest
9-
10-
name: Consult black on python formatting
12+
tests:
13+
name: ${{ matrix.os }} / ${{ matrix.python-version }}
14+
runs-on: ${{ matrix.os }}-latest
15+
strategy:
16+
matrix:
17+
os: [Ubuntu, MacOS, Windows]
18+
python-version: [3.6, 3.7, 3.8]
1119

1220
steps:
1321
- uses: actions/checkout@v2
14-
- uses: actions/setup-python@v2
15-
with:
16-
python-version: 3.7
17-
- uses: Gr1N/setup-poetry@v2
18-
- uses: actions/cache@v2
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v1
1925
with:
20-
path: ~/.cache/pypoetry/virtualenvs
21-
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
22-
restore-keys: |
23-
${{ runner.os }}-poetry-
24-
- name: Install dependencies
25-
run: poetry install
26-
- name: Run black
27-
run: poetry run poe check-style
26+
python-version: ${{ matrix.python-version }}
2827

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

32-
name: Run tests with tox
33+
- name: Install poetry
34+
shell: bash
35+
run: |
36+
python -m pip install poetry
37+
echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH"
3338
34-
strategy:
35-
matrix:
36-
python-version: [ '3.6', '3.7', '3.8']
39+
- name: Configure poetry
40+
shell: bash
41+
run: poetry config virtualenvs.in-project true
3742

38-
steps:
39-
- uses: actions/checkout@v2
40-
- uses: actions/setup-python@v2
43+
- name: Set up cache
44+
uses: actions/cache@v2
45+
id: cache
4146
with:
42-
python-version: ${{ matrix.python-version }}
43-
- uses: Gr1N/setup-poetry@v2
44-
- uses: actions/cache@v2
45-
with:
46-
path: ~/.cache/pypoetry/virtualenvs
47-
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
48-
restore-keys: |
49-
${{ runner.os }}-poetry-
47+
path: .venv
48+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
49+
50+
- name: Ensure cache is healthy
51+
if: steps.cache.outputs.cache-hit == 'true'
52+
shell: bash
53+
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
54+
5055
- name: Install dependencies
56+
shell: bash
5157
run: |
52-
poetry run pip install --upgrade pip
58+
poetry run python -m pip install pip -U
5359
poetry install
54-
- name: Run tests
55-
run: |
56-
poetry run poe generate
57-
poetry run poe test
5860
59-
build-release:
60-
runs-on: ubuntu-latest
61+
- name: Generate code from proto files
62+
shell: bash
63+
run: poetry run python -m tests.generate -v
6164

62-
steps:
63-
- uses: actions/checkout@v2
64-
- uses: actions/setup-python@v2
65-
with:
66-
python-version: 3.7
67-
- uses: Gr1N/setup-poetry@v2
68-
- name: Build package
69-
run: poetry build
70-
- name: Publish package to PyPI
71-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
72-
run: poetry publish -n
73-
env:
74-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.pypi }}
65+
- name: Execute test suite
66+
shell: bash
67+
run: poetry run pytest tests/

.github/workflows/code-quality.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
black:
13+
name: Black
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Run Black
18+
uses: lgeiger/black-action@master
19+
with:
20+
args: --check src/ tests/

.github/workflows/release.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- '**'
9+
pull_request:
10+
branches:
11+
- '**'
12+
13+
jobs:
14+
packaging:
15+
name: Distribution
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python 3.8
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.8
23+
- name: Install poetry
24+
run: python -m pip install poetry
25+
- name: Build package
26+
run: poetry build
27+
- name: Publish package to PyPI
28+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
29+
env:
30+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.pypi }}
31+
run: poetry publish -n

0 commit comments

Comments
 (0)