|
1 | 1 | name: CI
|
2 | 2 |
|
3 |
| -on: [push, pull_request] |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - '**' |
4 | 10 |
|
5 | 11 | 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] |
11 | 19 |
|
12 | 20 | steps:
|
13 | 21 | - 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 |
19 | 25 | 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 }} |
28 | 27 |
|
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))") |
31 | 32 |
|
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" |
33 | 38 |
|
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 |
37 | 42 |
|
38 |
| - steps: |
39 |
| - - uses: actions/checkout@v2 |
40 |
| - - uses: actions/setup-python@v2 |
41 |
| - with: |
42 |
| - python-version: ${{ matrix.python-version }} |
43 |
| - - uses: Gr1N/setup-poetry@v2 |
44 |
| - - uses: actions/cache@v2 |
| 43 | + - name: Set up cache |
| 44 | + uses: actions/cache@v2 |
| 45 | + id: cache |
45 | 46 | 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 | + |
50 | 55 | - name: Install dependencies
|
| 56 | + shell: bash |
51 | 57 | run: |
|
52 | 58 | poetry run pip install --upgrade pip
|
53 | 59 | poetry install
|
54 |
| - - name: Run tests |
| 60 | +
|
| 61 | + - name: Execute test suite |
| 62 | + shell: bash |
55 | 63 | run: |
|
56 | 64 | poetry run poe generate
|
57 | 65 | poetry run poe test
|
58 |
| -
|
59 |
| - build-release: |
60 |
| - runs-on: ubuntu-latest |
61 |
| - |
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