Skip to content

Commit

Permalink
Add testing, linting, gh action
Browse files Browse the repository at this point in the history
s, move folder
  • Loading branch information
blackary committed Nov 14, 2022
1 parent a777341 commit 7ef3854
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 37 deletions.
21 changes: 21 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[flake8]
max-line-length = 88
select =
E # pep8 errors
F # pyflakes errors
W # pep8 warnings
B # flake8-bugbear warnings
ignore =
E501 # "Line lengths are recommended to be no greater than 79 characters"
E203 # "Whitespace before ':'": conflicts with black
W503 # "line break before binary operator": conflicts with black
exclude =
.git
.vscode
.pytest_cache
.mypy_cache
.venv
.env
.direnv
streamlit_patches.py
per-file-ignores =
13 changes: 13 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: linting

on:
pull_request:
push:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
18 changes: 18 additions & 0 deletions .github/workflows/pypi_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This workflows will upload a Python Package using Poetry when a release is created

name: PyPI synchronization

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build and publish to pypi
uses: JRubics/[email protected]
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: testing

on:
pull_request:
push:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.2.1"
- name: Install dependencies
run: |
poetry install
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox
#- name: Test with pytest
# run: |
# poetry run pytest
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:
- repo: https://gitlab.com/pycqa/flake8
rev: "4.0.1"
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- repo: https://github.com/psf/black
rev: "22.3.0"
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: "5.10.1"
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v0.942"
hooks:
- id: mypy
args:
- --ignore-missing-imports
- --follow-imports=silent
additional_dependencies:
- types-all
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
68 changes: 37 additions & 31 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 34 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tool.poetry]
name = "streamlit-pages"
name = "st-pages"
version = "0.1.0"
description = "An experimental version of Streamlit Multi-Page Apps"
authors = ["Zachary Blackwood <[email protected]>"]
readme = "README.md"
packages = [{include = "streamlit_pages", from = "src"}]
packages = [{include = "st_pages", from = "src"}]

[tool.poetry.dependencies]
python = ">=3.8,<3.9.7 || >3.9.7,<4.0"
Expand All @@ -21,3 +21,35 @@ tox = "^3.27.1"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"


[tool.isort]
profile = "black"
line_length = 88
skip = ["./.venv", "./direnv", ".env"]

[tool.black]
exclude = '''
(
/(
\.vscode
| \.git
| \.pytest_cache
| \.mypy_cache
| \.venv
| \.env
| \.direnv
)/
)
'''
include = '\.pyi?$'
line-length = 88

[tool.mypy]
files = [
"**/*.py",
]
follow_imports = "silent"
ignore_missing_imports = true
scripts_are_modules = true
python_version = 3.9
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/test_streamlit_pages.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
def test_import():
from streamlit_pages import Page, show_pages
from st_pages import Page, show_pages # noqa: F401


def test_page():
from streamlit_pages import Page
from st_pages import Page

page = Page("tests/test_streamlit_pages.py")
assert page.page_name == "Test Streamlit Pages"
Expand All @@ -12,7 +12,7 @@ def test_page():


def test_page_icon():
from streamlit_pages import Page
from st_pages import Page

page = Page("tests/test_streamlit_pages.py", icon=":dog:")
assert page.page_icon == "🐶"
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ commands:
# note tox will use the same python version as under what tox is installed to package
# so unless this is python 3 you can require a given python version for the packaging
# environment via the basepython key
basepython = python3
basepython = python3

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310

0 comments on commit 7ef3854

Please sign in to comment.