1- # This workflow will install Python dependencies, run tests and lint
2- # with a single version of Python
3-
4- name : Tests
1+ name : test
52
63on :
74 push :
85 branches :
96 - ' *' # matches every branch that doesn't contain a '/'
107 - ' */*' # matches every branch containing a single '/'
118 - ' **' # matches every branch
12- pull_request :
13- branches :
14- - ' *' # matches every branch that doesn't contain a '/'
15- - ' */*' # matches every branch containing a single '/'
16- - ' **' # matches every branch
17- jobs :
18- build :
9+ pull_request :
10+ branches :
11+ - ' *' # matches every branch that doesn't contain a '/'
12+ - ' */*' # matches every branch containing a single '/'
13+ - ' **' # matches every branch
1914
15+ jobs :
16+ linting :
2017 runs-on : ubuntu-latest
21-
2218 steps :
23- - uses : actions/checkout@v2
24- - name : Set up Python 3.9
25- uses : actions/setup-python@v2
26- with :
27- python-version : 3.9
28- - name : Install dependencies
29- run : |
30- python -m pip install --upgrade pip
31- pip install flake8
32- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
33- if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
34- - name : Lint with flake8
35- run : |
36- # stop the build if there are Python syntax errors or undefined names
37- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
38- # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
39- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
40- - name : Test
41- run : |
42- python -m unittest discover -s tests/
19+ # ----------------------------------------------
20+ # check-out repo and set-up python
21+ # ----------------------------------------------
22+ - uses : actions/checkout@v4
23+ - uses : actions/setup-python@v5
24+ # ----------------------------------------------
25+ # load pip cache if cache exists
26+ # ----------------------------------------------
27+ - uses : actions/cache@v3
28+ with :
29+ path : ~/.cache/pip
30+ key : ${{ runner.os }}-pip
31+ restore-keys : ${{ runner.os }}-pip
32+ # ----------------------------------------------
33+ # install and run linters
34+ # ----------------------------------------------
35+ - run : python -m pip install black flake8 isort
36+ - run : |
37+ flake8 ./investing_algorithm_framework
38+ test :
39+ needs : linting
40+ strategy :
41+ fail-fast : true
42+ matrix :
43+ os : [ "ubuntu-latest", "macos-latest" ]
44+ python-version : [ "3.8", "3.9", "3.10", "3.11" ]
45+ runs-on : ${{ matrix.os }}
46+ steps :
47+ # ----------------------------------------------
48+ # check-out repo and set-up python
49+ # ----------------------------------------------
50+ - name : Check out repository
51+ uses : actions/checkout@v4
52+ - name : Set up python ${{ matrix.python-version }}
53+ id : setup-python
54+ uses : actions/setup-python@v5
55+ with :
56+ python-version : ${{ matrix.python-version }}
57+ # ----------------------------------------------
58+ # ----- install distutils if needed -----
59+ # ----------------------------------------------
60+ - name : Install distutils on Ubuntu
61+ if : matrix.os == 'ubuntu-latest'
62+ run : |
63+ sudo add-apt-repository ppa:deadsnakes/ppa
64+ sudo apt-get update
65+ sudo apt install python${{ matrix.python-version }}-distutils
66+ # ----------------------------------------------
67+ # ----- install & configure poetry -----
68+ # ----------------------------------------------
69+ - name : Install Poetry
70+ uses : snok/install-poetry@v1
71+ with :
72+ virtualenvs-create : true
73+ virtualenvs-in-project : true
74+ # ----------------------------------------------
75+ # load cached venv if cache exists
76+ # ----------------------------------------------
77+ - name : Load cached venv
78+ id : cached-poetry-dependencies
79+ uses : actions/cache@v3
80+ with :
81+ path : .venv
82+ key : venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
83+ # ----------------------------------------------
84+ # install dependencies if cache does not exist
85+ # ----------------------------------------------
86+ - name : Install dependencies
87+ if : steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
88+ run : |
89+ poetry install --no-interaction --no-root
90+ # ----------------------------------------------
91+ # install your root project, if required
92+ # ----------------------------------------------
93+ - name : Install library
94+ run : |
95+ poetry install --no-interaction
96+ # ----------------------------------------------
97+ # add matrix specifics and run test suite
98+ # ----------------------------------------------
99+ - name : Run tests
100+ run : |
101+ source .venv/bin/activate
102+ coverage run -m unittest discover -s tests
103+ # #----------------------------------------------
104+ # # upload coverage stats
105+ # #----------------------------------------------
106+ # - name: Upload coverage
107+ # uses: codecov/codecov-action@v3
108+ # with:
109+ # file: ./coverage.xml
110+ # fail_ci_if_error: true
0 commit comments