|
1 | | -# This workflow will install Python dependencies, run tests and lint with a single version of Python |
2 | | -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions |
3 | | - |
4 | | -name: Python application |
| 1 | +name: Testing |
5 | 2 |
|
6 | 3 | on: |
7 | 4 | push: |
8 | | - branches: [ main ] |
| 5 | + branches: [ master ] |
9 | 6 | pull_request: |
10 | | - branches: [ main ] |
| 7 | + branches: [ master ] |
11 | 8 |
|
12 | 9 | jobs: |
13 | 10 | build: |
14 | 11 |
|
15 | 12 | runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + python-version: [ 3.8, 3.9 ] |
16 | 16 |
|
17 | 17 | steps: |
18 | | - - uses: actions/checkout@v2 |
19 | | - - name: Set up Python 3.9 |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v2 |
| 20 | + |
| 21 | + - name: Set up Python ${{ matrix.python-version }} |
20 | 22 | uses: actions/setup-python@v2 |
21 | 23 | with: |
22 | | - python-version: 3.9 |
| 24 | + python-version: ${{ matrix.python-version }} |
| 25 | + |
| 26 | + - name: Install Poetry |
| 27 | + uses: snok/install-poetry@v1 |
| 28 | + with: |
| 29 | + virtualenvs-create: true |
| 30 | + virtualenvs-in-project: true |
| 31 | + installer-parallel: true |
| 32 | + |
| 33 | + - name: Load cached venv |
| 34 | + id: cached-poetry-dependencies |
| 35 | + uses: actions/cache@v2 |
| 36 | + with: |
| 37 | + path: .venv |
| 38 | + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} |
| 39 | + |
23 | 40 | - name: Install dependencies |
| 41 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 42 | + run: poetry install --no-interaction --no-root |
| 43 | + |
| 44 | + - name: Install library |
| 45 | + run: poetry install --no-interaction |
| 46 | + |
| 47 | + - name: Run tests |
24 | 48 | run: | |
25 | | - python -m pip install --upgrade pip |
26 | | - pip install flake8 pytest pytest-asyncio pytest-httpx yarl httpx |
27 | | - - name: Lint with flake8 |
28 | | - run: | |
29 | | - # stop the build if there are Python syntax errors or undefined names |
30 | | - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
31 | | - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
32 | | - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
33 | | - - name: Test with pytest |
34 | | - run: | |
35 | | - pytest |
| 49 | + source .venv/bin/activate |
| 50 | + pytest tests/ |
0 commit comments