From 10d2cafccba31641b80395fd203b4e37f55ba9c2 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 18 May 2023 16:46:50 -0400 Subject: [PATCH 01/13] Remove .travis.yml, update documentation building in Makefile, update pre-commit hooks, update dev dependencies, update actions, fix some issues with spacing --- .github/workflows/main.yml | 10 ++- cookiecutter.json | 4 +- {{cookiecutter.project_slug}}/.coveralls.yml | 2 +- .../.pre-commit-config.yaml | 31 ++++--- {{cookiecutter.project_slug}}/.travis.yml | 80 ------------------- {{cookiecutter.project_slug}}/AUTHORS.rst | 2 +- .../CONTRIBUTING.rst | 9 +-- {{cookiecutter.project_slug}}/Makefile | 32 +++++--- .../environment-docs.yml | 2 +- .../requirements_dev.txt | 27 ++++--- .../requirements_docs.txt | 2 +- {{cookiecutter.project_slug}}/setup.cfg | 3 +- {{cookiecutter.project_slug}}/setup.py | 1 + {{cookiecutter.project_slug}}/tox.ini | 48 ++++++----- 14 files changed, 102 insertions(+), 151 deletions(-) delete mode 100644 {{cookiecutter.project_slug}}/.travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 518b4010c..6b5474d64 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,16 +18,20 @@ jobs: python-version: "3.8" - tox-env: py39 python-version: "3.9" + - tox-env: py310 + python-version: "3.10" + - tox-env: py311 + python-version: "3.11" - tox-env: pypy3 python-version: pypy3 steps: - name: Cancel previous runs - uses: styfle/cancel-workflow-action@0.9.1 + uses: styfle/cancel-workflow-action@0.11.0 with: access_token: ${{ github.token }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install tox diff --git a/cookiecutter.json b/cookiecutter.json index a95294b9b..ab70ed8ed 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -7,8 +7,8 @@ "project_short_description": "Python Boilerplate contains all the boilerplate you need to create a Python package.", "pypi_username": "{{ cookiecutter.github_username }}", "version": "0.1.0", - "use_pytest": "n", - "use_black": "n", + "use_pytest": "y", + "use_black": "y", "use_pypi_deployment_with_travis": "y", "add_pyup_badge": "n", "make_docs": "y", diff --git a/{{cookiecutter.project_slug}}/.coveralls.yml b/{{cookiecutter.project_slug}}/.coveralls.yml index 152945cd2..4ecf44e5d 100644 --- a/{{cookiecutter.project_slug}}/.coveralls.yml +++ b/{{cookiecutter.project_slug}}/.coveralls.yml @@ -1,2 +1,2 @@ service_name: github -repo_token: YOURTOKENHERE +# repo_token: YOURTOKENHERE diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index c3d1260ab..10be7dfc5 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -3,12 +3,12 @@ default_language_version: repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.38.0 + rev: v3.4.0 hooks: - id: pyupgrade args: [--py38-plus] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: trailing-whitespace exclude: setup.cfg @@ -17,44 +17,43 @@ repos: args: ['--allow-multiple-documents'] - id: debug-statements - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 + rev: v1.10.0 hooks: - id: rst-inline-touching-normal + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + exclude: ^docs/ - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: [ 'flake8-rst-docstrings' ] args: ['--config=setup.cfg'] - - repo: https://github.com/psf/black - rev: 22.8.0 - hooks: - - id: black - exclude: ^docs/ - args: [ '--target-version=py38' ] - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort args: ['--settings-file=setup.cfg'] exclude: ^docs/ - repo: https://github.com/PyCQA/pydocstyle - rev: 6.1.1 + rev: 6.3.0 hooks: - id: pydocstyle args: [ '--config=setup.cfg' ] - repo: https://github.com/keewis/blackdoc - rev: v0.3.7 + rev: v0.3.8 hooks: - id: blackdoc - additional_dependencies: [ 'black==22.8.0' ] + additional_dependencies: [ 'black==23.3.0' ] - repo: https://github.com/adrienverge/yamllint.git - rev: v1.28.0 + rev: v1.31.0 hooks: - id: yamllint args: ['--config-file', '.yamllint.yaml'] - repo: https://github.com/mgedmin/check-manifest - rev: "0.48" + rev: "0.49" hooks: - id: check-manifest - repo: meta diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml deleted file mode 100644 index 237c4079b..000000000 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ /dev/null @@ -1,80 +0,0 @@ - -# Config file for automatic testing at travis-ci.com - -language: python - -dist: xenial -os: linux - -jobs: - fast_finish: true - include: - - env: TOXENV=docs - name: "Documentation" - python: 3.7 - - env: TOXENV=black - name: "Black" - python: 3.7 - - env: TOXENV=py38-macOS - name: "Python3.8 (macOS)" - os: osx - language: shell - addons: - homebrew: - update: true - packages: - - python@3.8 - install: - - /usr/local/opt/python@3.8/bin/pip3 install -U tox-travis - - env: - - TOXENV=py38-windows - - DESIRED_PYTHON=3.8 - - MINICONDA_PATH=$(cygpath --windows /c/miniconda) - name: "Python3.8 (Windows + Anaconda via Chocolatey)" - os: windows - language: shell - before_install: - - printenv - - choco install miniconda3 --params="'/AddToPath:0 /D:$MINICONDA_PATH'" - - source /c/miniconda/Scripts/activate - - hash -r - - conda config --set always_yes yes --set changeps1 no - - conda install setuptools - - conda update -q conda - - conda create -n {{ cookiecutter.project_slug }} -c conda-forge python=$DESIRED_PYTHON - - source activate {{ cookiecutter.project_slug }} - - python: 3.6 - - python: 3.7 - - python: 3.8 - allow_failures: - - env: TOXENV=black - - env: TOXENV=py38-macOS - - env: - - TOXENV=py38-Windows - - DESIRED_PYTHON=3.8 - - MINICONDA_PATH=$(cygpath --windows /c/miniconda) - -before_install: printenv - -# Command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors -install: pip install -U tox-travis - -# Command to run tests, e.g. python setup.py test -script: tox - -{% if cookiecutter.use_pypi_deployment_with_travis == 'y' -%} -# Assuming you have installed the travis-ci CLI tool, after you -# create the GitHub repo and add it to Travis, run the -# following command to finish PyPI deployment setup: -# $ travis encrypt --add deploy.password -deploy: - provider: pypi - distributions: sdist bdist_wheel - user: {{ cookiecutter.pypi_username }} - password: - secure: PLEASE_REPLACE_ME - on: - tags: true - repo: {{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }} - python: 3.8 -{%- endif %} diff --git a/{{cookiecutter.project_slug}}/AUTHORS.rst b/{{cookiecutter.project_slug}}/AUTHORS.rst index 06770ce42..42162d6f3 100644 --- a/{{cookiecutter.project_slug}}/AUTHORS.rst +++ b/{{cookiecutter.project_slug}}/AUTHORS.rst @@ -5,7 +5,7 @@ Credits Development Lead ---------------- -* {{ cookiecutter.full_name }} <{{ cookiecutter.email }}> +* {{ cookiecutter.full_name }} <{{ cookiecutter.email }}> `@{{ cookiecutter.github_username }} `https://github.com/{{ cookiecutter.github_username }}>`_ Contributors ------------ diff --git a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst index 49e3c140c..7c78a4580 100644 --- a/{{cookiecutter.project_slug}}/CONTRIBUTING.rst +++ b/{{cookiecutter.project_slug}}/CONTRIBUTING.rst @@ -119,9 +119,7 @@ Before you submit a pull request, check that it meets these guidelines: 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. -3. The pull request should work for Python 3.8, 3.9, and 3.10. Check - https://travis-ci.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/pull_requests - and make sure that the tests pass for all supported Python versions. +3. The pull request should work for Python 3.8, 3.9, 3.10, and 3.11. Check that the tests pass for all supported Python versions. Tips ---- @@ -155,14 +153,15 @@ The simple approach ~~~~~~~~~~~~~~~~~~~ The simplest approach to packaging for general support (pip wheels) requires the following packages installed: + * build * setuptools - * wheel * twine + * wheel From the command line on your Linux distribution, simply run the following from the clone's main dev branch:: # To build the packages (sources and wheel) - $ python setup.py sdist bdist_wheel + $ python -m build --sdist --wheel # To upload to PyPI $ twine upload dist/* diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile index 26a13694a..565eeb657 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_slug}}/Makefile @@ -36,6 +36,14 @@ clean-build: ## remove build artifacts find . -name '*.egg-info' -exec rm -fr {} + find . -name '*.egg' -exec rm -f {} + +{%- if cookiecutter.make_docs == 'y' %} + +clean-docs: ## remove docs artifacts + rm -f docs/apidoc/ravenpy*.rst + rm -f docs/apidoc/modules.rst + $(MAKE) -C docs clean + +{% endif -%} clean-pyc: ## remove Python file artifacts find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyo' -exec rm -f {} + @@ -52,10 +60,11 @@ lint/flake8: ## check style with flake8 flake8 {{ cookiecutter.project_slug }} tests {%- if cookiecutter.use_black == 'y' %} + lint/black: ## check style with black black --check {{ cookiecutter.project_slug }} tests -{%- endif %} +{%- endif -%} lint: lint/flake8{%- if cookiecutter.use_black == 'y' %} lint/black{%- endif %} ## check style test: ## run tests quickly with the default Python @@ -79,24 +88,29 @@ coverage: ## check code coverage quickly with the default Python $(BROWSER) htmlcov/index.html {%- if cookiecutter.make_docs == 'y' %} -docs: ## generate Sphinx HTML documentation, including API docs - rm -f docs/{{ cookiecutter.project_slug }}.rst - rm -f docs/modules.rst - sphinx-apidoc -o docs/ {{ cookiecutter.project_slug }} - $(MAKE) -C docs clean + +autodoc: clean-docs ## create sphinx-apidoc files: + sphinx-apidoc -o docs/apidoc --private --module-first ravenpy + +linkcheck: autodoc ## run checks over all external links found throughout the documentation + $(MAKE) -C docs linkcheck + +docs: autodoc ## generate Sphinx HTML documentation, including API docs $(MAKE) -C docs html +ifndef READTHEDOCS $(BROWSER) docs/_build/html/index.html +endif servedocs: docs ## compile the docs watching for changes watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . -{%- endif %} +{% endif -%} release: dist ## package and upload a release twine upload dist/* dist: clean ## builds source and wheel package - python setup.py sdist - python setup.py bdist_wheel + python -m build --sdist + python -m build --wheel ls -l dist install: clean ## install the package to the active Python's site-packages diff --git a/{{cookiecutter.project_slug}}/environment-docs.yml b/{{cookiecutter.project_slug}}/environment-docs.yml index a15df93f4..1ae52a56f 100644 --- a/{{cookiecutter.project_slug}}/environment-docs.yml +++ b/{{cookiecutter.project_slug}}/environment-docs.yml @@ -5,7 +5,7 @@ channels: dependencies: - sphinx - pandoc - - sphinx_rtd_theme + - sphinx_rtd_theme >=1.0 - sphinx-autoapi - sphinx-codeautolink - sphinx-copybutton diff --git a/{{cookiecutter.project_slug}}/requirements_dev.txt b/{{cookiecutter.project_slug}}/requirements_dev.txt index b3600d571..02995e26e 100644 --- a/{{cookiecutter.project_slug}}/requirements_dev.txt +++ b/{{cookiecutter.project_slug}}/requirements_dev.txt @@ -1,19 +1,20 @@ -pip==19.2.3 -bump2version==0.5.11 -wheel==0.33.6 -watchdog==0.9.0 -flake8==3.7.8 -tox==3.14.0 -coverage==4.5.4 +pip==23.1.2 +bump2version==1.0.1 +wheel==0.40.0 +build==0.10.0 +watchdog==3.0.0 +flake8==6.0.0 +tox==4.5.1 +coverage==7.2.5 coveralls==3.3.1 -Sphinx==1.8.5 -twine==1.14.0 +sphinx==7.0.1 +twine==4.0.2 {% if cookiecutter.command_line_interface|lower == 'click' -%} Click==8.1.3{% endif %} {% if cookiecutter.use_pytest == 'y' -%} -pytest==6.2.4 -pytest-cov==3.0.0{% endif %} +pytest==7.3.1 +pytest-cov==4.0.0{% endif %} {% if cookiecutter.use_black == 'y' -%} -black==21.7b0 -isort==5.10.1{% endif %} +black==23.3.0 +isort==5.12.0{% endif %} pre-commit diff --git a/{{cookiecutter.project_slug}}/requirements_docs.txt b/{{cookiecutter.project_slug}}/requirements_docs.txt index 791a15744..d425dc907 100644 --- a/{{cookiecutter.project_slug}}/requirements_docs.txt +++ b/{{cookiecutter.project_slug}}/requirements_docs.txt @@ -2,7 +2,7 @@ sphinx sphinx-click sphinx-codeautolink sphinx-copybutton -sphinx-rtd-theme +sphinx-rtd-theme>=1.0 nbsphinx pandoc ipython diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index cb8268d63..feb912bd2 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -23,7 +23,8 @@ test = pytest [tool:pytest] collect_ignore = ['setup.py'] -addopts = --verbose +addopts = + --verbose filterwarnings = ignore::UserWarning {%- endif %} diff --git a/{{cookiecutter.project_slug}}/setup.py b/{{cookiecutter.project_slug}}/setup.py index 5a3c7c19e..2e3181dc9 100644 --- a/{{cookiecutter.project_slug}}/setup.py +++ b/{{cookiecutter.project_slug}}/setup.py @@ -45,6 +45,7 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], description="{{ cookiecutter.project_short_description }}", {%- if 'no' not in cookiecutter.command_line_interface|lower %} diff --git a/{{cookiecutter.project_slug}}/tox.ini b/{{cookiecutter.project_slug}}/tox.ini index 2817e372b..01c0f4ac0 100644 --- a/{{cookiecutter.project_slug}}/tox.ini +++ b/{{cookiecutter.project_slug}}/tox.ini @@ -1,44 +1,56 @@ [tox] -envlist = black, py{38,39,310},{%- if cookiecutter.make_docs == 'y' %} docs,{%- endif %} coveralls -requires = pip >= 20.0 -opts = --verbose - -[travis] -python = - {% if cookiecutter.make_docs == 'y' -%} - 3.8: docs - {%- endif %} +min_version = 4.0 +envlist = + black + py{38,39,310,311} + {%- if cookiecutter.make_docs == 'y' %} docs,{%- endif -%} + coveralls +requires = + pip >= 21.0 +opts = + --verbose [testenv:black] skip_install = True deps = flake8 black -commands = make lint -allowlist_externals = make +commands = + make lint +allowlist_externals = + make {% if cookiecutter.make_docs == 'y' %} [testenv:docs] -extras = docs -commands = make --directory=docs clean html -allowlist_externals = make{%- endif %} +extras = + docs +commands = + make --directory=docs clean html +allowlist_externals = + make{%- endif %} [testenv] setenv = PYTEST_ADDOPTS = "--color=yes" PYTHONPATH = {toxinidir} -passenv = GITHUB_* +passenv = + GITHUB_* {% if cookiecutter.use_pytest == 'y' -%} -extras = dev -download = true +extras = + dev +download = True install_command = python -m pip install --no-user {opts} {packages} deps = ; If you want to make tox run the tests with the same versions, create a ; requirements.txt with the pinned versions and uncomment the following line: ; -r{toxinidir}/requirements.txt +{% if cookiecutter.use_pytest == 'y' -%} commands = pytest --cov {{ cookiecutter.project_slug }} # Coveralls requires access to a repo token set in .coveralls.yml in order to report stats coveralls: - coveralls {% else %} -commands = python setup.py test +commands = + python setup.py test + # Coveralls requires access to a repo token set in .coveralls.yml in order to report stats + coveralls: - coveralls {%- endif %} From 3d54483744b14ccf2fec7f785f517be529215616 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 18 May 2023 16:55:05 -0400 Subject: [PATCH 02/13] update pypy to pypy3.9 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b5474d64..f2552cf8a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: - tox-env: py311 python-version: "3.11" - tox-env: pypy3 - python-version: pypy3 + python-version: "pypy3.9" steps: - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.11.0 From 92aa962bb48ce81419f61b3eac2247c7e145a94e Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Jun 2023 16:14:49 -0400 Subject: [PATCH 03/13] small adjustments - WIP --- cookiecutter.json | 4 ++-- tests/test_bake_project.py | 3 ++- {{cookiecutter.project_slug}}/.pre-commit-config.yaml | 8 +++++++- {{cookiecutter.project_slug}}/Makefile | 3 +-- {{cookiecutter.project_slug}}/tox.ini | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index ab70ed8ed..a95294b9b 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -7,8 +7,8 @@ "project_short_description": "Python Boilerplate contains all the boilerplate you need to create a Python package.", "pypi_username": "{{ cookiecutter.github_username }}", "version": "0.1.0", - "use_pytest": "y", - "use_black": "y", + "use_pytest": "n", + "use_black": "n", "use_pypi_deployment_with_travis": "y", "add_pyup_badge": "n", "make_docs": "y", diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index 42e7fda28..0f5e371ca 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -3,6 +3,7 @@ import subprocess import sys from contextlib import contextmanager +from pathlib import Path import yaml import datetime @@ -35,7 +36,7 @@ def bake_in_temp_dir(cookies, *args, **kwargs): :param cookies: pytest_cookies.Cookies, cookie to be baked and its temporal files will be removed """ - result = cookies.bake(*args, **kwargs) + result = cookies.bake(*args, template=Path(__file__).parents[1].as_posix(), **kwargs) try: yield result finally: diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 10be7dfc5..97e5eed12 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -31,6 +31,12 @@ repos: - id: flake8 additional_dependencies: [ 'flake8-rst-docstrings' ] args: ['--config=setup.cfg'] + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + exclude: ^docs/ + args: [ '--target-version=py38' ] - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: @@ -48,7 +54,7 @@ repos: - id: blackdoc additional_dependencies: [ 'black==23.3.0' ] - repo: https://github.com/adrienverge/yamllint.git - rev: v1.31.0 + rev: v1.32.0 hooks: - id: yamllint args: ['--config-file', '.yamllint.yaml'] diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile index 565eeb657..80955af94 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_slug}}/Makefile @@ -88,7 +88,6 @@ coverage: ## check code coverage quickly with the default Python $(BROWSER) htmlcov/index.html {%- if cookiecutter.make_docs == 'y' %} - autodoc: clean-docs ## create sphinx-apidoc files: sphinx-apidoc -o docs/apidoc --private --module-first ravenpy @@ -103,8 +102,8 @@ endif servedocs: docs ## compile the docs watching for changes watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . +{%- endif -%} -{% endif -%} release: dist ## package and upload a release twine upload dist/* diff --git a/{{cookiecutter.project_slug}}/tox.ini b/{{cookiecutter.project_slug}}/tox.ini index 01c0f4ac0..e329fe3c3 100644 --- a/{{cookiecutter.project_slug}}/tox.ini +++ b/{{cookiecutter.project_slug}}/tox.ini @@ -3,7 +3,7 @@ min_version = 4.0 envlist = black py{38,39,310,311} - {%- if cookiecutter.make_docs == 'y' %} docs,{%- endif -%} + {%- if cookiecutter.make_docs == 'y' %} docs,{%- endif %} coveralls requires = pip >= 21.0 From 1b4ce513029dcc276e047858a07cfb1b7e8faf12 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Jun 2023 16:23:19 -0400 Subject: [PATCH 04/13] test configuration fixes --- tests/test_bake_project.py | 14 ++------------ {{cookiecutter.project_slug}}/tox.ini | 1 - 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index 0f5e371ca..b5303fbc7 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -36,7 +36,8 @@ def bake_in_temp_dir(cookies, *args, **kwargs): :param cookies: pytest_cookies.Cookies, cookie to be baked and its temporal files will be removed """ - result = cookies.bake(*args, template=Path(__file__).parents[1].as_posix(), **kwargs) + kwargs.update(template=Path(__file__).parents[1].as_posix()) + result = cookies.bake(*args, **kwargs) try: yield result finally: @@ -121,17 +122,6 @@ def test_bake_with_apostrophe_and_run_tests(cookies): run_inside_dir("python setup.py test", str(result.project)) == 0 -def test_bake_without_travis_pypi_setup(cookies): - with bake_in_temp_dir( - cookies, extra_context={"use_pypi_deployment_with_travis": "n"} - ) as result: - result_travis_config = yaml.load( - result.project.join(".travis.yml").open(), Loader=yaml.FullLoader - ) - assert "deploy" not in result_travis_config - assert "python" == result_travis_config["language"] - - def test_bake_without_docs(cookies): with bake_in_temp_dir(cookies, extra_context={"make_docs": "n"}) as result: found_toplevel_files = [f.basename for f in result.project.listdir()] diff --git a/{{cookiecutter.project_slug}}/tox.ini b/{{cookiecutter.project_slug}}/tox.ini index e329fe3c3..f310f04d7 100644 --- a/{{cookiecutter.project_slug}}/tox.ini +++ b/{{cookiecutter.project_slug}}/tox.ini @@ -34,7 +34,6 @@ setenv = PYTHONPATH = {toxinidir} passenv = GITHUB_* -{% if cookiecutter.use_pytest == 'y' -%} extras = dev download = True From 63ad0727b0a0de946bd2b9e500e8b5c73709e8f9 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Jun 2023 16:57:06 -0400 Subject: [PATCH 05/13] several fixes --- tests/test_bake_project.py | 11 +++++------ {{cookiecutter.project_slug}}/LICENSE | 2 +- {{cookiecutter.project_slug}}/docs/conf.py | 1 - {{cookiecutter.project_slug}}/requirements_dev.txt | 2 +- .../{{cookiecutter.project_slug}}/cli.py | 5 ++--- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index b5303fbc7..fbdaaec1b 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -5,7 +5,6 @@ from contextlib import contextmanager from pathlib import Path -import yaml import datetime import pytest from cookiecutter.utils import rmtree @@ -223,7 +222,7 @@ def test_not_using_pytest(cookies): def test_bake_with_no_console_script(cookies): context = {"command_line_interface": "No command-line interface"} - result = cookies.bake(extra_context=context) + result = cookies.bake(extra_context=context, template=Path(__file__).parents[1].as_posix()) project_path, project_slug, project_dir = project_info(result) found_project_files = os.listdir(project_dir) assert "cli.py" not in found_project_files @@ -233,10 +232,10 @@ def test_bake_with_no_console_script(cookies): assert "entry_points" not in setup_file.read() -@pytest.mark.parametrize("option", ["click", "argparse"]) +@pytest.mark.parametrize("option", ["Click", "Argparse"]) def test_bake_with_console_options_script_files(cookies, option): context = {"command_line_interface": option} - result = cookies.bake(extra_context=context) + result = cookies.bake(extra_context=context, template=Path(__file__).parents[1].as_posix()) project_path, project_slug, project_dir = project_info(result) found_project_files = os.listdir(project_dir) assert "cli.py" in found_project_files @@ -246,10 +245,10 @@ def test_bake_with_console_options_script_files(cookies, option): assert "entry_points" in setup_file.read() -@pytest.mark.parametrize("option", ["click", "argparse"]) +@pytest.mark.parametrize("option", ["Click", "Argparse"]) def test_bake_with_console_options_script_cli(cookies, option): context = {"command_line_interface": option} - result = cookies.bake(extra_context=context) + result = cookies.bake(extra_context=context, template=Path(__file__).parents[1].as_posix()) project_path, project_slug, project_dir = project_info(result) module_path = os.path.join(project_dir, "cli.py") module_name = ".".join([project_slug, "cli"]) diff --git a/{{cookiecutter.project_slug}}/LICENSE b/{{cookiecutter.project_slug}}/LICENSE index 8ac71fbc1..6c6f4c861 100644 --- a/{{cookiecutter.project_slug}}/LICENSE +++ b/{{cookiecutter.project_slug}}/LICENSE @@ -59,7 +59,7 @@ Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' %} +{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%} Apache Software License 2.0 Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} diff --git a/{{cookiecutter.project_slug}}/docs/conf.py b/{{cookiecutter.project_slug}}/docs/conf.py index 7fa7fbd92..07a69bb0e 100755 --- a/{{cookiecutter.project_slug}}/docs/conf.py +++ b/{{cookiecutter.project_slug}}/docs/conf.py @@ -101,7 +101,6 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -# html_theme = 'alabaster' html_theme = "sphinx_rtd_theme" # Theme options are theme-specific and customize the look and feel of a diff --git a/{{cookiecutter.project_slug}}/requirements_dev.txt b/{{cookiecutter.project_slug}}/requirements_dev.txt index 02995e26e..1ed9f768d 100644 --- a/{{cookiecutter.project_slug}}/requirements_dev.txt +++ b/{{cookiecutter.project_slug}}/requirements_dev.txt @@ -17,4 +17,4 @@ pytest-cov==4.0.0{% endif %} {% if cookiecutter.use_black == 'y' -%} black==23.3.0 isort==5.12.0{% endif %} -pre-commit +pre-commit==3.3.2 diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/cli.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/cli.py index b9751acea..c1c953f1b 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/cli.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/cli.py @@ -7,8 +7,9 @@ {%- if cookiecutter.command_line_interface|lower == 'click' %} import click +{%- endif %} - +{% if cookiecutter.command_line_interface|lower == 'click' %} @click.command() def main(args=None): """Console script for {{cookiecutter.project_slug}}.""" @@ -19,8 +20,6 @@ def main(args=None): return 0 {%- endif %} {%- if cookiecutter.command_line_interface|lower == 'argparse' %} - - def main(): """Console script for {{cookiecutter.project_slug}}.""" parser = argparse.ArgumentParser() From 64803669a96c8f91f51e1a0e0e60b0206430136d Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Jun 2023 16:59:19 -0400 Subject: [PATCH 06/13] remove newer python versions --- .github/workflows/main.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f2552cf8a..07f311af1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,10 +18,6 @@ jobs: python-version: "3.8" - tox-env: py39 python-version: "3.9" - - tox-env: py310 - python-version: "3.10" - - tox-env: py311 - python-version: "3.11" - tox-env: pypy3 python-version: "pypy3.9" steps: From 8647f4609182255d40176571bb19bfa1d28ba97e Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Jun 2023 17:01:20 -0400 Subject: [PATCH 07/13] drop Python3.7 --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 07f311af1..cf1ba31dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,8 +12,6 @@ jobs: strategy: matrix: include: - - tox-env: py37 - python-version: "3.7" - tox-env: py38 python-version: "3.8" - tox-env: py39 From 821b75f44529e866f203f11b7f13742b39ceb576 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Jun 2023 18:39:20 -0400 Subject: [PATCH 08/13] precommit --- setup.cfg | 2 +- tests/test_bake_project.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index aee696d9e..b1e6cb0a7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,4 +13,4 @@ replace = version='{new_version}' [tool:pytest] addopts = --verbose markers = - requires_precommit: mark tests that can only be run with precommit present + precommit: mark tests that can only be run with precommit present diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index fbdaaec1b..7d231d1fd 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -94,7 +94,7 @@ def test_bake_and_run_tests(cookies): print("test_bake_and_run_tests path", str(result.project)) -@pytest.mark.requires_precommit +@pytest.mark.precommit def test_bake_and_run_pre_commit(cookies): with bake_in_temp_dir(cookies) as result: assert result.project.isdir() From 0cf14620d24ccadf7863c7770f28c5b378f42b8f Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 2 Jun 2023 10:18:05 -0400 Subject: [PATCH 09/13] relax test --- tests/test_bake_project.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index 7d231d1fd..a032b854a 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -11,7 +11,7 @@ from click.testing import CliRunner -import importlib +import importlib.util @contextmanager @@ -245,9 +245,8 @@ def test_bake_with_console_options_script_files(cookies, option): assert "entry_points" in setup_file.read() -@pytest.mark.parametrize("option", ["Click", "Argparse"]) -def test_bake_with_console_options_script_cli(cookies, option): - context = {"command_line_interface": option} +def test_bake_with_console_options_script_click(cookies): + context = {"command_line_interface": "Click"} result = cookies.bake(extra_context=context, template=Path(__file__).parents[1].as_posix()) project_path, project_slug, project_dir = project_info(result) module_path = os.path.join(project_dir, "cli.py") From 26d58f5bcb0e9810e511c488b564d0a36920e2d7 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 2 Jun 2023 13:43:28 -0400 Subject: [PATCH 10/13] add workflows, update license spdx identifiers, add zenodo config, add issue templates --- cookiecutter.json | 2 +- hooks/post_gen_project.py | 24 ++++++ hooks/pre_gen_project.py | 4 +- tests/test_bake_project.py | 11 ++- .../0001-GENERIC-ISSUE-TEMPLATE.yml | 34 ++++++++ .../ISSUE_TEMPLATE/0002-BUG-REPORT.yml | 44 ++++++++++ .../ISSUE_TEMPLATE/0003-FEATURE-REQUEST.yml | 31 +++++++ .../ISSUE_TEMPLATE/0004-QUESTION-SUPPORT.yml | 23 ++++++ .../.github/ISSUE_TEMPLATE/config.yml | 1 + .../.github/workflows/first_pull_request.yml | 46 +++++++++++ .../.github/workflows/main.yml | 80 +++++++++++++++++++ .../.github/workflows/publish-pypi.yml | 28 +++++++ .../.github/workflows/tag-testpypi.yml | 30 +++++++ {{cookiecutter.project_slug}}/.zenodo.json | 14 ++++ {{cookiecutter.project_slug}}/LICENSE | 10 +-- {{cookiecutter.project_slug}}/MANIFEST.in | 5 ++ {{cookiecutter.project_slug}}/setup.py | 10 +-- 17 files changed, 378 insertions(+), 19 deletions(-) create mode 100644 {{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0001-GENERIC-ISSUE-TEMPLATE.yml create mode 100644 {{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0002-BUG-REPORT.yml create mode 100644 {{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0003-FEATURE-REQUEST.yml create mode 100644 {{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0004-QUESTION-SUPPORT.yml create mode 100644 {{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/config.yml create mode 100644 {{cookiecutter.project_slug}}/.github/workflows/first_pull_request.yml create mode 100644 {{cookiecutter.project_slug}}/.github/workflows/main.yml create mode 100644 {{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml create mode 100644 {{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml create mode 100644 {{cookiecutter.project_slug}}/.zenodo.json diff --git a/cookiecutter.json b/cookiecutter.json index a95294b9b..47fa3faec 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -14,6 +14,6 @@ "make_docs": "y", "command_line_interface": ["Click", "Argparse", "No command-line interface"], "create_author_file": "y", - "open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"], + "open_source_license": ["MIT", "BSD-3-Clause", "ISC", "Apache-2.0", "GPL-3.0-or-later", "Not open source"], "generated_with_cruft": "y" } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 14df306d7..34fd45587 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -17,6 +17,26 @@ def remove_folder(folderpath): Path(PROJECT_DIRECTORY).joinpath(folderpath).rmdir() +def replace_contents(filepath): + replacements = { + "__PYTHON_VERSION__": 'matrix.python-version', + "__GITHUB_TOKEN__": 'secrets.GITHUB_TOKEN', + '__TOX_ENV__': 'matrix.tox-env', + "__PYPI_API_TOKEN__": "secrets.PYPI_API_TOKEN", + "__TESTPYPI_API_TOKEN__": "secrets.TEST_PYPI_API_TOKEN" + } + + lines = [] + with open(filepath) as infile: + for line in infile: + for src, target in replacements.items(): + line = line.replace(src, " ".join(["${ {".replace(" ", ""), target, "} }".replace(" ", "")])) + lines.append(line) + with open(filepath, 'w') as outfile: + for line in lines: + outfile.write(line) + + if __name__ == "__main__": if "{{ cookiecutter.create_author_file }}" != "y": @@ -33,3 +53,7 @@ def remove_folder(folderpath): if "Not open source" == "{{ cookiecutter.open_source_license }}": remove_file("LICENSE") + remove_file(".zenodo.json") + + for f in Path(".github/workflows").glob("*.yml"): + replace_contents(f) diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 6d3940066..77acf350b 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -9,5 +9,5 @@ if not re.match(MODULE_REGEX, module_name): print('ERROR: The project slug (%s) is not a valid Python module name. Please do not use a - and use _ instead' % module_name) - #Exit to cancel project - sys.exit(1) \ No newline at end of file + # Exit to cancel project + sys.exit(1) diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index a032b854a..4f84c381a 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -156,12 +156,11 @@ def test_make_help(cookies): def test_bake_selecting_license(cookies): license_strings = { - "MIT license": "MIT ", - "BSD license": "Redistributions of source code must retain the " - + "above copyright notice, this", - "ISC license": "ISC License", - "Apache Software License 2.0": "Licensed under the Apache License, Version 2.0", - "GNU General Public License v3": "GNU GENERAL PUBLIC LICENSE", + "MIT": "MIT", + "BSD-3-Clause": "Redistributions of source code must retain the above copyright notice, this", + "ISC": "ISC License", + "Apache-2.0": "Licensed under the Apache License, Version 2.0", + "GPL-3.0-or-later": "GNU GENERAL PUBLIC LICENSE", } for license, target_string in license_strings.items(): with bake_in_temp_dir( diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0001-GENERIC-ISSUE-TEMPLATE.yml b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0001-GENERIC-ISSUE-TEMPLATE.yml new file mode 100644 index 000000000..c0d6df3e5 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0001-GENERIC-ISSUE-TEMPLATE.yml @@ -0,0 +1,34 @@ +name: Generic issue template +description: For detailing generic/uncategorized issues in {{ cookiecutter.project_name }} + +body: + - type: textarea + id: generic-issue + attributes: + label: Generic Issue + description: Please fill in the following information fields as needed. + value: | + * {{ cookiecutter.project_slug }} version: + * Python version: + * Operating System: + + ### Description + + + ### What I Did + + ``` + $ pip install foo --bar + ``` + + ### What I Received + + ``` + Traceback (most recent call last): + File "/path/to/file/script.py", line 3326, in run_code + exec(code_obj, self.user_global_ns, self.user_ns) + File "", line 1, in + 1/0 + ZeroDivisionError: division by zero diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0002-BUG-REPORT.yml b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0002-BUG-REPORT.yml new file mode 100644 index 000000000..e03b322f0 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0002-BUG-REPORT.yml @@ -0,0 +1,44 @@ +name: Bug report +description: Help us improve {{ cookiecutter.project_name }} +labels: [ "bug" ] + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: textarea + id: setup-information + attributes: + label: Setup Information + description: | + What software versions are you running? Example: + - {{ cookiecutter.project_slug }} version: 0.55.0-gamma + - Python version: 4.2 + - Operating System: Nutmeg Linux 12.34 | macOS 11.0 "Redmond" + value: | + - {{ cookiecutter.project_slug }} version: + - Python version: + - Operating System: + - type: textarea + id: description + attributes: + label: Description + description: Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen. + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps To Reproduce + description: Paste the command(s) you ran and the output. If there was a crash, please include the traceback below. + - type: textarea + id: additional-context + attributes: + label: Additional context + description: Add any other context about the problem here. + - type: checkboxes + id: submit-pr + attributes: + label: Contribution + description: Do you intend to submit a fix for this bug? (The {{ cookiecutter.project_name }} developers will help with code compliance) + options: + - label: I would be willing/able to open a Pull Request to address this bug. diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0003-FEATURE-REQUEST.yml b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0003-FEATURE-REQUEST.yml new file mode 100644 index 000000000..1d7d49cb2 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0003-FEATURE-REQUEST.yml @@ -0,0 +1,31 @@ +name: Feature request +description: Suggest an idea for {{ cookiecutter.project_name }} +labels: [ "enhancement" ] + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this feature request! + - type: textarea + id: problem + attributes: + label: Addressing a Problem? + description: Is your feature request related to a problem? Please describe it. + - type: textarea + id: potential-solution + attributes: + label: Potential Solution + description: Describe the solution you'd like to see implemented. + - type: textarea + id: additional-context + attributes: + label: Additional context + description: Add any other context about the feature request here. + - type: checkboxes + id: submit-pr + attributes: + label: Contribution + description: Do you intend to submit a fix for this bug? (The {{ cookiecutter.project_name }} developers will help with code compliance) + options: + - label: I would be willing/able to open a Pull Request to contribute this feature. diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0004-QUESTION-SUPPORT.yml b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0004-QUESTION-SUPPORT.yml new file mode 100644 index 000000000..798a55384 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/0004-QUESTION-SUPPORT.yml @@ -0,0 +1,23 @@ +name: Question/Support +description: Ask for help from the developers +labels: [ "support" ] + +body: + - type: textarea + id: setup-information + attributes: + label: Setup Information + description: | + What software versions are you running? Example: + - {{ cookiecutter.project_slug }} version: 0.55.0-gamma + - Python version: 4.2 + - Operating System: Nutmeg Linux 12.34 | macOS 11.0 "Redmond" + value: | + - {{ cookiecutter.project_slug }} version: + - Python version: + - Operating System: + - type: textarea + id: description + attributes: + label: Context + description: Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen. diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/config.yml b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..0086358db --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: true diff --git a/{{cookiecutter.project_slug}}/.github/workflows/first_pull_request.yml b/{{cookiecutter.project_slug}}/.github/workflows/first_pull_request.yml new file mode 100644 index 000000000..1a1c48279 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/workflows/first_pull_request.yml @@ -0,0 +1,46 @@ +name: First Pull Request + +on: + pull_request_target: + types: + - opened + +jobs: + welcome: + name: Welcome + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v6 + with: + script: | + // Get a list of all issues created by the PR opener + // See: https://octokit.github.io/rest.js/#pagination + const creator = context.payload.sender.login + const opts = github.rest.issues.listForRepo.endpoint.merge({ + ...context.issue, + creator, + state: 'all' + }) + const issues = await github.paginate(opts) + + for (const issue of issues) { + if (issue.number === context.issue.number) { + continue + } + + if (issue.pull_request) { + return // Creator is already a contributor. + } + } + + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `**Welcome**, new contributor! + + It appears that this is your first Pull Request. To give credit where it's due, we ask that you add your information to the \`AUTHORS.rst\` and \`.zenodo.json\`.: + - [ ] The relevant author information has been added to \`AUTHORS.rst\` and \`.zenodo.json\`. + + Please make sure you've read our [contributing guide](CONTRIBUTING.rst). We look forward to reviewing your Pull Request shortly ✨` + }) diff --git a/{{cookiecutter.project_slug}}/.github/workflows/main.yml b/{{cookiecutter.project_slug}}/.github/workflows/main.yml new file mode 100644 index 000000000..fd401e523 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/workflows/main.yml @@ -0,0 +1,80 @@ +name: {{ cookiecutter.project_name }} Testing Suite + +on: + push: + branches: + - main + paths-ignore: + - CHANGES.rst + - MANIFEST.in + - README.rst + - setup.py + - setup.cfg + - {{ cookiecutter.project_slug }}/__init__.py + pull_request: + +jobs: + black: + name: Black (Python__PYTHON_VERSION__) + runs-on: ubuntu-latest + strategy: + matrix: + python-version: + - "3.8" + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.11.0 + with: + access_token: __GITHUB_TOKEN__ + - uses: actions/checkout@v3 + - name: Set up Python__PYTHON_VERSION__ + uses: actions/setup-python@v4 + with: + python-version: __PYTHON_VERSION__ + - name: Install tox + run: pip install tox + - name: Run linting suite + run: tox -e black + + test: + name: test-__TOX_ENV__ (Python__PYTHON_VERSION__) + needs: black + runs-on: ubuntu-latest + strategy: + matrix: + include: + - tox-env: "py38" + python-version: "3.8" + - tox-env: "py39" + python-version: "3.9" + - tox-env: "py310" + python-version: "3.10" + steps: + - uses: actions/checkout@v3 + - name: Set up Python__PYTHON_VERSION__ + uses: actions/setup-python@v4 + with: + python-version: __PYTHON_VERSION__ + - name: Install tox + run: pip install tox + - name: Test with tox + run: tox -e __TOX_ENV__ + env: + GITHUB_TOKEN: __GITHUB_TOKEN__ + COVERALLS_FLAG_NAME: run-__TOX_ENV__ + COVERALLS_PARALLEL: true + COVERALLS_SERVICE_NAME: github + + finish: + needs: + - test + runs-on: ubuntu-latest + container: python:3-slim + steps: + - name: Coveralls Finished + run: | + pip install --upgrade coveralls + coveralls --finish + env: + GITHUB_TOKEN: __GITHUB_TOKEN__ + COVERALLS_SERVICE_NAME: github diff --git a/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml b/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml new file mode 100644 index 000000000..31e186277 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml @@ -0,0 +1,28 @@ +name: Publish Python 🐍 distributions 📦 to PyPI + +on: + release: + types: + - published + +jobs: + build-n-publish-pypi: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python3 + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install packaging libraries + run: | + pip install wheel + - name: Build a binary wheel and a source tarball + run: | + python setup.py sdist bdist_wheel + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: __PYPI_API_TOKEN__ diff --git a/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml b/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml new file mode 100644 index 000000000..d03372b82 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml @@ -0,0 +1,30 @@ +name: Publish Python 🐍 distributions 📦 to TestPyPI + +on: + push: + tags: + - '*' + +jobs: + build-n-publish-testpypi: + name: Build and publish Python 🐍 distributions 📦 to TestPyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python3 + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install packaging libraries + run: | + pip install wheel + - name: Build a binary wheel and a source tarball + run: | + python setup.py sdist bdist_wheel + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: __TEST_PYPI_API_TOKEN__ + repository_url: https://test.pypi.org/legacy/ + skip_existing: true diff --git a/{{cookiecutter.project_slug}}/.zenodo.json b/{{cookiecutter.project_slug}}/.zenodo.json new file mode 100644 index 000000000..caee5e671 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.zenodo.json @@ -0,0 +1,14 @@ +{ + "title": "{{ cookiecutter.project_name }}", + "creators": [ + { + "name": "{{ cookiecutter.full_name.split()[-1] }}, {{ ' '.join(cookiecutter.full_name.split()[:-1]) }}" + } + ], + "keywords": [ ], + "license": "{{ cookiecutter.open_source_license }}", + "language": "eng", + "communities": [ ], + "upload_type": "software", + "access_right": "open" +} diff --git a/{{cookiecutter.project_slug}}/LICENSE b/{{cookiecutter.project_slug}}/LICENSE index 6c6f4c861..1037da9d4 100644 --- a/{{cookiecutter.project_slug}}/LICENSE +++ b/{{cookiecutter.project_slug}}/LICENSE @@ -1,4 +1,4 @@ -{% if cookiecutter.open_source_license == 'MIT license' -%} +{% if cookiecutter.open_source_license == 'MIT' -%} MIT License Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} @@ -20,7 +20,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -{% elif cookiecutter.open_source_license == 'BSD license' %} +{% elif cookiecutter.open_source_license == 'BSD-3-Clause' %} BSD License @@ -51,7 +51,7 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -{% elif cookiecutter.open_source_license == 'ISC license' -%} +{% elif cookiecutter.open_source_license == 'ISC' -%} ISC License Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} @@ -59,7 +59,7 @@ Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%} +{% elif cookiecutter.open_source_license == 'Apache-2.0' -%} Apache Software License 2.0 Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} @@ -75,7 +75,7 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -{% elif cookiecutter.open_source_license == 'GNU General Public License v3' -%} +{% elif cookiecutter.open_source_license == 'GPL-3.0-or-later' -%} GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 diff --git a/{{cookiecutter.project_slug}}/MANIFEST.in b/{{cookiecutter.project_slug}}/MANIFEST.in index c64756d61..f129d721e 100644 --- a/{{cookiecutter.project_slug}}/MANIFEST.in +++ b/{{cookiecutter.project_slug}}/MANIFEST.in @@ -3,7 +3,9 @@ include AUTHORS.rst {% endif -%} include CONTRIBUTING.rst include HISTORY.rst +{% if cookiecutter.open_source_license != 'Not open source' -%} include LICENSE +{% endif -%} include README.rst include requirements_dev.txt {% if cookiecutter.make_docs == 'y' -%} @@ -21,6 +23,9 @@ exclude .editorconfig exclude .pre-commit-config.yaml exclude .readthedocs.yml exclude .yamllint.yaml +{% if cookiecutter.open_source_license != 'Not open source' -%} +include .zenodo.json +{% endif -%} exclude Makefile exclude environment-docs.yml exclude tox.ini diff --git a/{{cookiecutter.project_slug}}/setup.py b/{{cookiecutter.project_slug}}/setup.py index 2e3181dc9..f996f2109 100644 --- a/{{cookiecutter.project_slug}}/setup.py +++ b/{{cookiecutter.project_slug}}/setup.py @@ -23,11 +23,11 @@ ] {%- set license_classifiers = { - 'MIT license': 'License :: OSI Approved :: MIT License', - 'BSD license': 'License :: OSI Approved :: BSD License', - 'ISC license': 'License :: OSI Approved :: ISC License (ISCL)', - 'Apache Software License 2.0': 'License :: OSI Approved :: Apache Software License', - 'GNU General Public License v3': 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)' + 'MIT': 'License :: OSI Approved :: MIT License', + 'BSD-3-Clause': 'License :: OSI Approved :: BSD License', + 'ISC': 'License :: OSI Approved :: ISC License (ISCL)', + 'Apache-2.0': 'License :: OSI Approved :: Apache Software License', + 'GPL-3.0-or-later': 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)' } %} setup( From 6837ea255ea72a1cce7d205634d9798155227704 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 2 Jun 2023 14:03:09 -0400 Subject: [PATCH 11/13] add setuptools --- .../.github/workflows/publish-pypi.yml | 2 +- .../.github/workflows/tag-testpypi.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml b/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml index 31e186277..cbf62540a 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml @@ -17,7 +17,7 @@ jobs: python-version: "3.x" - name: Install packaging libraries run: | - pip install wheel + pip install setuptools wheel - name: Build a binary wheel and a source tarball run: | python setup.py sdist bdist_wheel diff --git a/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml b/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml index d03372b82..92877a74f 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml @@ -17,7 +17,7 @@ jobs: python-version: "3.x" - name: Install packaging libraries run: | - pip install wheel + pip install setuptools wheel - name: Build a binary wheel and a source tarball run: | python setup.py sdist bdist_wheel From 0778c4116d104d466cd3c0ea1e449ca7fa7cc205 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 2 Jun 2023 14:26:01 -0400 Subject: [PATCH 12/13] add co-developers --- {{cookiecutter.project_slug}}/AUTHORS.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/{{cookiecutter.project_slug}}/AUTHORS.rst b/{{cookiecutter.project_slug}}/AUTHORS.rst index 42162d6f3..8803bcea4 100644 --- a/{{cookiecutter.project_slug}}/AUTHORS.rst +++ b/{{cookiecutter.project_slug}}/AUTHORS.rst @@ -7,6 +7,11 @@ Development Lead * {{ cookiecutter.full_name }} <{{ cookiecutter.email }}> `@{{ cookiecutter.github_username }} `https://github.com/{{ cookiecutter.github_username }}>`_ +Co-Developers +------------- + +None yet. Why not be the first? + Contributors ------------ From ddc281b368d4bef796fa8faa46e83f11211a2934 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 7 Jun 2023 14:40:22 -0400 Subject: [PATCH 13/13] address review comments --- {{cookiecutter.project_slug}}/.github/workflows/main.yml | 2 ++ {{cookiecutter.project_slug}}/MANIFEST.in | 6 +++--- {{cookiecutter.project_slug}}/Makefile | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.github/workflows/main.yml b/{{cookiecutter.project_slug}}/.github/workflows/main.yml index fd401e523..88e52030b 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/main.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/main.yml @@ -49,6 +49,8 @@ jobs: python-version: "3.9" - tox-env: "py310" python-version: "3.10" + - tox-env: "py311" + python-version: "3.11" steps: - uses: actions/checkout@v3 - name: Set up Python__PYTHON_VERSION__ diff --git a/{{cookiecutter.project_slug}}/MANIFEST.in b/{{cookiecutter.project_slug}}/MANIFEST.in index f129d721e..90d839927 100644 --- a/{{cookiecutter.project_slug}}/MANIFEST.in +++ b/{{cookiecutter.project_slug}}/MANIFEST.in @@ -11,6 +11,9 @@ include requirements_dev.txt {% if cookiecutter.make_docs == 'y' -%} include requirements_docs.txt {% endif -%} +{% if cookiecutter.open_source_license != 'Not open source' -%} +include .zenodo.json +{% endif -%} recursive-include tests * recursive-exclude * __pycache__ @@ -23,9 +26,6 @@ exclude .editorconfig exclude .pre-commit-config.yaml exclude .readthedocs.yml exclude .yamllint.yaml -{% if cookiecutter.open_source_license != 'Not open source' -%} -include .zenodo.json -{% endif -%} exclude Makefile exclude environment-docs.yml exclude tox.ini diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile index 80955af94..dbae10e5a 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_slug}}/Makefile @@ -39,7 +39,7 @@ clean-build: ## remove build artifacts {%- if cookiecutter.make_docs == 'y' %} clean-docs: ## remove docs artifacts - rm -f docs/apidoc/ravenpy*.rst + rm -f docs/apidoc/{{ cookiecutter.project_slug }}*.rst rm -f docs/apidoc/modules.rst $(MAKE) -C docs clean @@ -89,7 +89,7 @@ coverage: ## check code coverage quickly with the default Python {%- if cookiecutter.make_docs == 'y' %} autodoc: clean-docs ## create sphinx-apidoc files: - sphinx-apidoc -o docs/apidoc --private --module-first ravenpy + sphinx-apidoc -o docs/apidoc --private --module-first {{ cookiecutter.project_slug }} linkcheck: autodoc ## run checks over all external links found throughout the documentation $(MAKE) -C docs linkcheck