|
| 1 | +name: default |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + |
| 7 | + lint: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + python-version: [3.7, 3.8] |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + - name: Set up Python ${{ matrix.python-version }} |
| 15 | + uses: actions/setup-python@v2 |
| 16 | + with: |
| 17 | + python-version: ${{ matrix.python-version }} |
| 18 | + - name: Cache pip packages |
| 19 | + uses: actions/cache@v2 |
| 20 | + with: |
| 21 | + path: ~/.cache/pip |
| 22 | + key: lint-flake8-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }} |
| 23 | + restore-keys: | |
| 24 | + lint-flake8-${{ runner.os }}-pip-${{ matrix.python-version }} |
| 25 | + lint-flake8-${{ runner.os }}-pip- |
| 26 | + - name: Install dependencies |
| 27 | + run: | |
| 28 | + python -m pip install -U pip setuptools |
| 29 | + python -m pip install -U -r requirements/lint.txt |
| 30 | + - name: Lint with flake8 |
| 31 | + run: | |
| 32 | + if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then |
| 33 | + echo "(skipping matchers for pull request from local branches)" |
| 34 | + else |
| 35 | + echo "::add-matcher::.github/workflows/flake8-matcher.json" |
| 36 | + fi |
| 37 | + python -m flake8 src/ai/backend tests |
| 38 | +
|
| 39 | + typecheck: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + strategy: |
| 42 | + matrix: |
| 43 | + python-version: [3.8] |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v2 |
| 46 | + - name: Set up Python ${{ matrix.python-version }} |
| 47 | + uses: actions/setup-python@v2 |
| 48 | + with: |
| 49 | + python-version: ${{ matrix.python-version }} |
| 50 | + - name: Cache pip packages |
| 51 | + uses: actions/cache@v2 |
| 52 | + with: |
| 53 | + path: ~/.cache/pip |
| 54 | + key: typecheck-mypy-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }} |
| 55 | + restore-keys: | |
| 56 | + typecheck-mypy-${{ runner.os }}-pip-${{ matrix.python-version }} |
| 57 | + typecheck-mypy-${{ runner.os }}-pip- |
| 58 | + - name: Install dependencies |
| 59 | + run: | |
| 60 | + python -m pip install -U pip setuptools |
| 61 | + python -m pip install -U -r requirements/typecheck.txt |
| 62 | + - name: Type check with mypy |
| 63 | + run: | |
| 64 | + if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then |
| 65 | + echo "(skipping matchers for pull request from local branches)" |
| 66 | + else |
| 67 | + echo "::add-matcher::.github/workflows/mypy-matcher.json" |
| 68 | + fi |
| 69 | + python -m mypy --no-color-output src/ai/backend |
| 70 | +
|
| 71 | + test: |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + strategy: |
| 74 | + matrix: |
| 75 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 76 | + python-version: [3.7, 3.8] |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v2 |
| 79 | + - name: Set up Python ${{ matrix.python-version }} |
| 80 | + uses: actions/setup-python@v2 |
| 81 | + with: |
| 82 | + python-version: ${{ matrix.python-version }} |
| 83 | + - name: Cache pip packages |
| 84 | + uses: actions/cache@v2 |
| 85 | + with: |
| 86 | + path: ~/.cache/pip |
| 87 | + key: test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }} |
| 88 | + restore-keys: | |
| 89 | + test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }} |
| 90 | + test-pytest-${{ runner.os }}-pip- |
| 91 | + - name: Install dependencies |
| 92 | + run: | |
| 93 | + python -m pip install -U pip setuptools |
| 94 | + python -m pip install -U -r requirements/test.txt |
| 95 | + python <<EOF |
| 96 | + # temporary patch until pnuckowski/aioresponses#174 is released or aiohttp is patched. |
| 97 | + from pathlib import Path |
| 98 | + import aioresponses |
| 99 | + p = (Path(aioresponses.__file__).parent / "compat.py") |
| 100 | + print(">>> Patching aioresponses #174 manually") |
| 101 | + t = p.read_text() |
| 102 | + t = t.replace("return StreamReader(protocol, loop=loop)", "return StreamReader(protocol, limit=2 ** 16, loop=loop)") |
| 103 | + p.write_text(t) |
| 104 | + EOF |
| 105 | + shell: bash |
| 106 | + - name: Test with pytest |
| 107 | + run: | |
| 108 | + python -m pytest -v --cov=src -m 'not integration' tests |
| 109 | + - name: Send code coverage report |
| 110 | + uses: codecov/codecov-action@v1 |
| 111 | + |
| 112 | + deploy-to-pypi: |
| 113 | + needs: [lint, typecheck, test] |
| 114 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 115 | + runs-on: ubuntu-latest |
| 116 | + steps: |
| 117 | + - uses: actions/checkout@v2 |
| 118 | + - name: Set up Python 3.8 |
| 119 | + uses: actions/setup-python@v2 |
| 120 | + with: |
| 121 | + python-version: 3.8 |
| 122 | + - name: Cache pip packages |
| 123 | + uses: actions/cache@v2 |
| 124 | + with: |
| 125 | + path: ~/.cache/pip |
| 126 | + key: test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }} |
| 127 | + restore-keys: | |
| 128 | + test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }} |
| 129 | + test-pytest-${{ runner.os }}-pip- |
| 130 | + - name: Install dependencies |
| 131 | + env: |
| 132 | + REQUIREMENTS_FILE: build |
| 133 | + run: | |
| 134 | + python -m pip install -U pip setuptools |
| 135 | + python -m pip install -U -r requirements/build.txt |
| 136 | + - name: Build and publish |
| 137 | + env: |
| 138 | + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 139 | + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 140 | + run: | |
| 141 | + python setup.py sdist bdist_wheel |
| 142 | + twine upload dist/* |
0 commit comments