Skip to content

Commit

Permalink
sync ci configs with pymplate
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Oct 4, 2023
1 parent 037bffc commit 01d0099
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 20 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ on:
jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12.0-rc.3']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
# vvv just an example of excluding stuff from matrix
# exclude: [{platform: macos-latest, python-version: '3.6'}]

Expand All @@ -41,6 +42,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0 # nicer to have all git history when debugging/for tests

- uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
Expand Down
30 changes: 20 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
# see https://github.com/karlicoss/pymplate for up-to-date reference
[project]
dynamic = ["version"] # version is managed by setuptools_scm
name = "pockexport"
dependencies = [
"pocket", # pocket API bindings
]

## these need to be set if you're planning to upload to pypi
# description = "TODO"
# license = {file = "LICENSE"}
# authors = [
# {name = "Dima Gerasimov (@karlicoss)", email = "karlicoss@gmail.com"},
# ]
# maintainers = [
# {name = "Dima Gerasimov (@karlicoss)", email = "karlicoss@gmail.com"},
# ]
# keywords = []
# # see: http://pypi.python.org/pypi?%3Aaction=list_classifiers
# classifiers = [
# ]
#
# this needs to be set if you're planning to upload to pypi
# url = ""
# author = ""
# author_email = ""
# description = ""

# Rest like -- classifiers, license, etc, I don't think it matters for pypi
# it's just unnecessary duplication
#
# [project.urls]
# Homepage = "https://github.com/karlicoss/pymplate"
##

[project.optional-dependencies]
testing = ["pytest"]
linting = [
testing = [
"pytest",
"ruff",
"mypy",
"lxml", # for mypy html coverage
"orjson", # exporthelpers
Expand Down
25 changes: 25 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ignore = [
### too opinionated style checks
"E501", # too long lines
"E702", # Multiple statements on one line (semicolon)
"E731", # assigning lambda instead of using def
"E741", # Ambiguous variable name: `l`
"E742", # Ambiguous class name: `O
"E401", # Multiple imports on one line
"F403", # import *` used; unable to detect undefined names
###

###
"E722", # Do not use bare `except` ## Sometimes it's useful for defensive imports and that sort of thing..
"F811", # Redefinition of unused # this gets in the way of pytest fixtures (e.g. in cachew)

## might be nice .. but later and I don't wanna make it strict
"E402", # Module level import not at top of file

### maybe consider these soon
# sometimes it's useful to give a variable a name even if we don't use it as a documentation
# on the other hand, often is a sign of error
"F841", # Local variable `count` is assigned to but never used
"F401", # imported but unused
###
]
27 changes: 18 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
[tox]
minversion = 3.5
minversion = 3.21
# relies on the correct version of Python installed
envlist = tests,mypy
envlist = ruff,tests,mypy
# https://github.com/tox-dev/tox/issues/20#issuecomment-247788333
# hack to prevent .tox from crapping to the project directory
toxworkdir={env:TOXWORKDIR_BASE:}{toxinidir}/.tox
toxworkdir = {env:TOXWORKDIR_BASE:}{toxinidir}/.tox

[testenv]
# TODO how to get package name from setuptools?
package_name = "pockexport"
passenv =
# useful for tests to know they are running under ci
CI
CI_*
CI
CI_*
# respect user's cache dirs to prevent tox from crapping into project dir
MYPY_CACHE_DIR
PYTHONPYCACHEPREFIX
PYTHONPYCACHEPREFIX
MYPY_CACHE_DIR
RUFF_CACHE_DIR


[testenv:ruff]
commands =
{envpython} -m pip install --use-pep517 -e .[testing]
{envpython} -m ruff src/


# note: --use-pep517 here is necessary for tox --parallel flag to work properly
# otherwise it seems that it tries to modify .eggs dir in parallel and it fails
[testenv:tests]
commands =
{envpython} -m pip install -e .[testing]
{envpython} -m pip install --use-pep517 -e .[testing]
# posargs allow test filtering, e.g. tox ... -- -k test_name
{envpython} -m pytest \
--pyargs {[testenv]package_name} \
Expand All @@ -29,7 +38,7 @@ commands =

[testenv:mypy]
commands =
{envpython} -m pip install -e .[linting]
{envpython} -m pip install --use-pep517 -e .[testing]
{envpython} -m mypy --install-types --non-interactive \
-p {[testenv]package_name} \
# txt report is a bit more convenient to view on CI
Expand Down

0 comments on commit 01d0099

Please sign in to comment.