Skip to content
Merged
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
19 changes: 19 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Python package

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
# This is the Python version that comes with the latest Ubuntu LTS.
# It's likely the version used when developing.
python-version: "3.12"
- name: Install tox and any other packages
run: pip install tox
- name: Run tox
run: tox
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
# .github
Defaults for repos by this org
# .github-python

Defaults for Python repos by this org.

## Requirements

Python 3.12. May work with other versions, but not guaranteed.

## Development

It's recommended to do development with [Venv](https://docs.python.org/3/library/venv.html). To set up the environment run:

```
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```

## Testing

To install test modules run:

```
pip install -r requirements-test.txt
```

Testing is done by [Tox](https://tox.wiki). Run `tox` for all tests. Settings can be changed in tox.ini.

Unit tests are run with [Pytest](https://docs.pytest.org). Test files live in tests/.

Style is checked by [Flake8](https://flake8.pycqa.org/).

Module import order is handled by [Isort](https://pycqa.github.io/isort/).

### CI

Github actions are specified in .github/workflows/python.yml. By deafult Tox will run when code is pushed.
6 changes: 6 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-r requirements.txt

flake8==7.2.0
isort==6.0.1
pytest==8.3.5
tox==4.25.0
Empty file added requirements.txt
Empty file.
2 changes: 2 additions & 0 deletions tests/test_placeholder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_placeholder():
assert True
35 changes: 35 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[tox]
env_list = pytest, flake8, isort
no_package = true

[testenv]
setenv =
PYWIKIBOT2_NO_USER_CONFIG = 1
# Since pywikibot fallback to the user home directory:
HOME={envdir}
deps = -r requirements-test.txt

[testenv:pytest]
description = install pytest in a virtual environment and invoke it on the tests folder
commands = pytest tests/

[testenv:flake8]
commands = flake8

[flake8]
exclude =
.venv
.tox
user-config.py
user-password.py
# line break before binary operator; against current PEP 8
ignore = W503

[testenv:isort]
commands = isort {toxinidir}/ {posargs:--check-only --diff} --skip-gitignore

[isort]
known_first_party =
known_third_party =
multi_line_output = 3
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER