diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..30ca08a --- /dev/null +++ b/.github/workflows/python.yml @@ -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 diff --git a/README.md b/README.md index 965df60..9ad69ff 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..6c01852 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,6 @@ +-r requirements.txt + +flake8==7.2.0 +isort==6.0.1 +pytest==8.3.5 +tox==4.25.0 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_placeholder.py b/tests/test_placeholder.py new file mode 100644 index 0000000..3ada1ee --- /dev/null +++ b/tests/test_placeholder.py @@ -0,0 +1,2 @@ +def test_placeholder(): + assert True diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..93ed773 --- /dev/null +++ b/tox.ini @@ -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