1+ name : test
2+
3+ on : push
4+
5+ jobs :
6+ linting :
7+ runs-on : ubuntu-latest
8+ steps :
9+ # ----------------------------------------------
10+ # check-out repo and set-up python
11+ # ----------------------------------------------
12+ - uses : actions/checkout@v2
13+ - uses : actions/setup-python@v2
14+ # ----------------------------------------------
15+ # load pip cache if cache exists
16+ # ----------------------------------------------
17+ - uses : actions/cache@v2
18+ with :
19+ path : ~/.cache/pip
20+ key : ${{ runner.os }}-pip
21+ restore-keys : ${{ runner.os }}-pip
22+ # ----------------------------------------------
23+ # install and run linters
24+ # ----------------------------------------------
25+ - run : python -m pip install black flake8 isort
26+ - run : |
27+ flake8 .
28+ black . --check
29+ isort .
30+ test :
31+ needs : linting
32+ strategy :
33+ fail-fast : true
34+ matrix :
35+ python-version : [ "3.7", "3.8", "3.9", "3.10" ]
36+ runs-on : " ubuntu-latest"
37+ steps :
38+ # ----------------------------------------------
39+ # check-out repo and set-up python
40+ # ----------------------------------------------
41+ - name : Check out repository
42+ uses : actions/checkout@v2
43+ - name : Set up python ${{ matrix.python-version }}
44+ id : setup-python
45+ uses : actions/setup-python@v2
46+ with :
47+ python-version : ${{ matrix.python-version }}
48+ # ----------------------------------------------
49+ # ----- install & configure poetry -----
50+ # ----------------------------------------------
51+ - name : Install Poetry
52+ uses : snok/install-poetry@v1
53+ with :
54+ virtualenvs-create : true
55+ virtualenvs-in-project : true
56+ # ----------------------------------------------
57+ # load cached venv if cache exists
58+ # ----------------------------------------------
59+ - name : Load cached venv
60+ id : cached-poetry-dependencies
61+ uses : actions/cache@v2
62+ with :
63+ path : .venv
64+ key : venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
65+ # ----------------------------------------------
66+ # install dependencies if cache does not exist
67+ # ----------------------------------------------
68+ - name : Install dependencies
69+ if : steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
70+ run : poetry install --no-interaction --no-root
71+ # ----------------------------------------------
72+ # install your root project, if required
73+ # ----------------------------------------------
74+ - name : Install library
75+ run : poetry install --no-interaction
76+
77+ - name : Run tests
78+ run : |
79+ source .venv/bin/activate
80+ pytest tests/
81+ coverage report
0 commit comments