|
1 | 1 | name: CI
|
2 | 2 |
|
3 |
| -on: |
4 |
| - push: |
5 |
| - branches: |
6 |
| - - master |
7 |
| - pull_request: |
8 |
| - branches: |
9 |
| - - '**' |
| 3 | +on: [push, pull_request] |
10 | 4 |
|
11 | 5 | jobs:
|
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] |
19 |
| - exclude: |
20 |
| - - os: Windows |
21 |
| - python-version: 3.6 |
| 6 | + |
| 7 | + check-formatting: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + name: Consult black on python formatting |
| 11 | + |
22 | 12 | steps:
|
23 | 13 | - uses: actions/checkout@v2
|
24 |
| - |
25 |
| - - name: Set up Python ${{ matrix.python-version }} |
26 |
| - uses: actions/setup-python@v1 |
| 14 | + - uses: actions/setup-python@v2 |
27 | 15 | with:
|
28 |
| - python-version: ${{ matrix.python-version }} |
| 16 | + python-version: 3.7 |
| 17 | + - uses: Gr1N/setup-poetry@v2 |
| 18 | + - uses: actions/cache@v2 |
| 19 | + 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 |
29 | 28 |
|
30 |
| - - name: Get full Python version |
31 |
| - id: full-python-version |
32 |
| - shell: bash |
33 |
| - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") |
| 29 | + run-tests: |
| 30 | + runs-on: ubuntu-latest |
34 | 31 |
|
35 |
| - - name: Install poetry |
36 |
| - shell: bash |
37 |
| - run: | |
38 |
| - python -m pip install poetry |
39 |
| - echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH" |
| 32 | + name: Run tests with tox |
40 | 33 |
|
41 |
| - - name: Configure poetry |
42 |
| - shell: bash |
43 |
| - run: poetry config virtualenvs.in-project true |
| 34 | + strategy: |
| 35 | + matrix: |
| 36 | + python-version: [ '3.6', '3.7', '3.8'] |
44 | 37 |
|
45 |
| - - name: Set up cache |
46 |
| - uses: actions/cache@v2 |
47 |
| - id: cache |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v2 |
| 40 | + - uses: actions/setup-python@v2 |
48 | 41 | with:
|
49 |
| - path: .venv |
50 |
| - key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} |
51 |
| - |
52 |
| - - name: Ensure cache is healthy |
53 |
| - if: steps.cache.outputs.cache-hit == 'true' |
54 |
| - shell: bash |
55 |
| - run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv |
56 |
| - |
| 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- |
57 | 50 | - name: Install dependencies
|
58 |
| - shell: bash |
59 | 51 | run: |
|
60 |
| - poetry run python -m pip install pip -U |
| 52 | + poetry run pip install --upgrade pip |
61 | 53 | poetry install
|
| 54 | + - name: Run tests |
| 55 | + run: | |
| 56 | + poetry run poe generate |
| 57 | + poetry run poe test |
62 | 58 |
|
63 |
| - - name: Generate code from proto files |
64 |
| - shell: bash |
65 |
| - run: poetry run python -m tests.generate -v |
| 59 | + build-release: |
| 60 | + runs-on: ubuntu-latest |
66 | 61 |
|
67 |
| - - name: Execute test suite |
68 |
| - shell: bash |
69 |
| - run: poetry run pytest tests/ |
| 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 }} |
0 commit comments