Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add basic project setup & CI #11

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Continuous Integration

on:
pull_request:

jobs:
quality-checks:
runs-on: ubuntu
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
in-project: true
prefer-active-python: true

- name: Install Python dependencies
run: |
just poetry-install

- name: Run style & code checks
run: |
just check

unit-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python: [ 3.8, 3.9, "3.10", "3.11" ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v3

- name: Set up Python v${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install Python dependencies
run: |
just poetry-install

- name: Run unit-tests
run: |
source $VENV # see https://github.com/snok/install-poetry#running-on-windows
just unit-tests
8 changes: 5 additions & 3 deletions .github/workflows/pr-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ jobs:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
- uses: amannn/action-semantic-pull-request@v5.1.0
with:
requireScope: false
allowedScopes: |
\#[0-9]+
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
scopes: |
\#[0-9]+
42 changes: 42 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
files: vistafetch/|tests/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-json
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-docstring-first
- id: check-merge-conflict

- repo: local
hooks:

- id: print_statement
name: Check that print is not in the source code
types: [ python ]
entry: 'print\(.*\)'
language: pygrep

- id: black
name: black
language: python
types: [ python ]
entry: black
verbose: true

- id: mypy
name: mypy
language: python
types: [ python ]
entry: mypy
verbose: true

- id: ruff
name: ruff
language: python
types: [ python ]
entry: ruff
verbose: true
34 changes: 34 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# apply code formatting with black
black:
poetry run black vistafetch tests -t py38 -t py39 -t py310 -t py311

# run static type checking with mypy
mypy:
poetry run mypy vistafetch

# apply linting with ruff
ruff:
poetry run ruff check vistafetch/**/*.py tests/**/*.py --fix-only

# run pre-configured poetry lock
poetry-lock:
poetry lock --no-update

# run pre-configured poetry install
poetry-install:
poetry install --with dev --all-extras

# run a check (ideally before comitting)
check: black mypy
poetry run ruff check vistafetch/*.py tests/*.py

# run pre-commit check
pre-commit:
git ls-files -- 'vistafetch/**/*' | xargs poetry run pre-commit run --verbose --files

# prettify your code (linting & formatting is applied)
pretty: ruff black

# run all unit tests
unit-tests:
poetry run pytest --cov=vistafetch --cov-fail-under=90 --cov-report term-missing --no-cov-on-fail tests/
829 changes: 829 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[tool.poetry]
name = "vistafetch"
version = "0.0.0"
description = "Small & simple library to fetch financial data for stocks, ETFs, funds, etc. from Onvista"
authors = ["bossenti <bossenti@apache.org>"]
license = "Apache 2.0"
readme = "README.md"

keywords = [
"etf",
"exchange",
"financial-data",
"funds",
"onvista",
"stocks"
]

classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Framework :: Pydantic :: 2",
"Intended Audience :: Developers",
"Intended Audience :: Financial and Insurance Industry",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Topic :: Office/Business :: Financial :: Investment"
]

include = [
{ path = "vistafetch/py.typed" }
]

[tool.poetry.dependencies]
python = ">=3.8, <3.12"
pydantic = ">=2.0.0"
requests = ">=2.31.0"

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
black = "23.7.0"
mypy = "1.5.1"
pre-commit = "3.3.3"
pytest = "7.4.0"
pytest-cov = "4.1.0"
ruff = "0.0.285"

[tool.ruff]
select = ["C90", "D", "E", "F", "I", "ICN", "N", "UP"]
ignore = [
"D211", # ignore in favour of D203
"D213", # ignore in favour of D212
]

[tool.ruff.per-file-ignores]
"**/{tests}/*" = ["D100", "D103", "D104"]


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file added tests/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_dummy():
pass
1 change: 1 addition & 0 deletions vistafetch/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Library to fetch financial data from Onvista."""
Loading