Skip to content

Commit

Permalink
add ape and codecov to CI, update to python 3.9 (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai authored Apr 17, 2023
1 parent a850182 commit 3bca61c
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 245 deletions.
10 changes: 8 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
omit =
tests/test_max_short.py
tests/test_notebooks.py
*/examples/*.*
hyperdrive_solidity/*

[report]
omit =
*test*
*/__init__.py
*test*
*/__init__.py
hyperdrive_solidity/*
exclude_lines =
if typing:
if TYPE_CHECKING:

ignore_errors = True
41 changes: 0 additions & 41 deletions .github/workflows/coverage.yml

This file was deleted.

28 changes: 15 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@ jobs:
build:
name: lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
python-version: "3.9"

- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install black~=22.0 pylint
python -m pip install stochastic --ignore-requires-python
python -m pip install -r requirements-${{ matrix.python-version }}.txt
- name: Analyzing code with black
run: python -m black --check --diff .
- name: Analysing code with pylint
run: python -m pylint $(git ls-files '*.py' ':!:*apeworx*')
python -m pip install -r requirements.txt
ape plugins install .
python -m pip install .
- name: Ensure clear Jupyter Notebooks
uses: ResearchSoftwareActions/[email protected]

- name: Run black
run: python -m black --check --diff .

- name: Run pylint
run: python -m pylint $(git ls-files '*.py' ':!:*apeworx*')
19 changes: 10 additions & 9 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ jobs:
build:
name: static
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
python-version: "3.9"

- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-${{ matrix.python-version }}.txt
python -m pip install . # Install the elfpy module
python -m pip install stochastic --ignore-requires-python
python -m pip install -r requirements.txt
ape plugins install .
python -m pip install .
- name: Analysing code with pyright
run: python -m pyright $(git ls-files '*.py' ':!:*apeworx*')
51 changes: 40 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,50 @@ jobs:
build:
name: test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}

- name: install node
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: install packages
uses: borales/actions-yarn@v4
with:
cmd: install # will run `yarn install` command
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # if needed

- name: install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
python-version: "3.9"

- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install black~=22.0 pylint pytest nose
python -m pip install stochastic --ignore-requires-python
python -m pip install -r requirements-${{ matrix.python-version }}.txt
python -m pip install -r requirements.txt
ape plugins install .
python -m pip install .
- name: Running package tests
run: python -m pytest .
python -m pip install coverage
- name: Run pytest with coverage
run: |
coverage run -m pytest
- name: Generate coverage report
run: |
coverage xml -i
coverage html -i
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3
with:
flags: unittests
fail_ci_if_error: true
50 changes: 16 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,35 @@ Documentation can be found [here](https://elfpy.element.fi).

## Install

Set up your favorite python virutal environment with python == 3.8 (we recommend [pyenv](https://github.com/pyenv/pyenv#how-it-works) and [virtualenv](https://github.com/pyenv/pyenv-virtualenv)). While we don't explicitly support python > 3.8, we haven't had trouble running on later versions (with one exception noted below). For example:
Python 3.9 is required currently, to maintain compatibility with Google Colaboratory.

```bash
pyenv install 3.8.16
pyenv local 3.8.16
python -m venv .venv
source .venv/bin/activate
```
Set up your favorite python virtual environment. We use:

Once this is done, check that your version is correct when you run `python --version`. Within the virtualenv, upgrade pip with `python -m pip install --upgrade pip` and then install the required packages.
- [pyenv](https://github.com/pyenv/pyenv#how-it-works) to manage python versions
- [venv](https://docs.python.org/3/library/venv.html) standard library to manage virtual environments

For Python 3.8.16:
Then run:

```bash
python -m pip install -r requirements-3.8.txt
python -m pip install -e .
pyenv install 3.9
pyenv local 3.9
python -m venv .venv
source .venv/bin/activate
```

for Python 3.11:
Once you're in your favored virtual environment, install the project dependencies:

```bash
python -m pip install -r requirements-3.11.txt
python -m pip install -r requirements.txt
python -m pip install -e .
```

If you intend to improve the documentation, then you must also install the packages in `requirements-dev.txt`.

### Docker

Using Docker is mostly untested, as the core team doesn't use it. However, the following steps should get you started.

To install a docker development environment which may be more reliable to install project dependencies:

```bash
Expand All @@ -70,28 +70,10 @@ Testing is achieved with [py.test](https://docs.pytest.org/en/latest/contents.ht

To run coverage locally you can follow these steps:

install coverage.py:

```
```bash
pip install coverage
```

parse the repo:

```
coverage run --source=elfpy --omit=tests/test_notebooks.py -m unittest discover tests
```

generate the report:

```
coverage xml -i report -m
```

generate html report:

```
coverage xml -i html
coverage run -m pytest
coverage html
```

then just open `htmlcov/index.html` to view the report!
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion elfpy/utils/apeworx_integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# pylint: disable=import-error
import ape # type: ignore[reportMissingImports]

import elfpy.markets.hyperdrive.assets as hyperdrive_assets
import elfpy.markets.hyperdrive.hyperdrive_assets as hyperdrive_assets

if TYPE_CHECKING:
from ape.api.accounts import AccountAPI # type: ignore[reportMissingImports]
Expand Down
Loading

0 comments on commit 3bca61c

Please sign in to comment.