Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add template for packages with c-code. #94

Merged
merged 10 commits into from
Jun 2, 2021
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
36 changes: 34 additions & 2 deletions config/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ packages:
processes, so coverage has to be configured in a special way. (Supports
pure Python packages which also run on PyPy.)

* c-code

- Configuration for package containing C code besides the Python one.

* pure-python

- Configuration for a pure Python package.
Expand Down Expand Up @@ -222,6 +226,9 @@ updated. Example:
coverage-setenv = [
"COVERAGE_HOME={toxinidir}",
]
coverage-additional = [
"depends = py37,docs"
]
use-flake8 = true

[flake8]
Expand Down Expand Up @@ -288,10 +295,18 @@ updated. Example:
"- pip install zc.buildout",
"- buildout",
]
build-script = [
"- python -W ignore setup.py -q bdist_wheel",
]
test-steps = [
"- zope-testrunner --test-path=src",
"- jasmine",
]
additional-lines = [
"artifacts:",
" - path: 'dist\*.whl'",
" name: wheel",
]
replacement = [
"environment:",
" matrix:",
Expand Down Expand Up @@ -395,6 +410,10 @@ coverage-setenv
in the buildout-recipe template), the default value is replaced by the value
given here. This option has to be a list of strings.

coverage-additional
This option allows to add additional lines below ``[testenv:coverage]`` in
``tox.ini``. This option has to be a list of strings.

use-flake8
Whether to add the ``flake8`` and ``isort`` linting steps to the section
``[testenv:lint]``. By default these steps are run. On an older code base it
Expand Down Expand Up @@ -493,6 +512,8 @@ steps-before-checkout
additional-install
Additional lines to be executed during the install dependencies step when
running the tests on GitHub Actions. This option has to be a list of strings.
For the template ``c-code`` this option is currently used to replace how to
install the package itself and run tests and coverage.

test-commands
Replacement for the test command in ``tests.yml``.
Expand All @@ -516,9 +537,20 @@ install-steps
Steps to install the package under test on AppVeyor. This option has to be a
list of strings. It defaults to ``["- pip install -U -e .[test]"]``.

build-script
Steps to to build the project. If this option is not given because no
additional build steps are necessary ``build: false`` is rendered to the
AppVeyor configuration. This option has to be a list of strings, each one
starting with a ``-``.

test-steps
Steps to run the tests on AppVeyor. This option has to be a list of strings.
It defaults to ``["- zope-testrunner --test-path=src"]``.
Steps to run the tests on AppVeyor. This option has to be a list of strings
, each one starting with a ``-``. It defaults to
``["- zope-testrunner --test-path=src"]``.

additional-lines
This option allows to add arbitrary additional lines to the end of the
configuration file. It has to be a list of strings.

replacement
Replace the whole template of the AppVeyor configuration with the contents of
Expand Down
3 changes: 3 additions & 0 deletions config/buildout-recipe/tox.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ commands =
coverage combine
coverage html
coverage report -m --fail-under=%(fail_under)s
{% for line in coverage_additional %}
%(line)s
{% endfor %}
30 changes: 30 additions & 0 deletions config/c-code/coveragerc.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[run]
source = %(package_name)s
# New in 5.0; required for the GHA coveralls submission.
relative_files = True
branch = true
{% for line in run_additional_config %}
%(line)s
{% endfor %}

[paths]
source =
src/
.tox/*/lib/python*/site-packages/
.tox/pypy*/site-packages/

[report]
show_missing = true
precision = 2
exclude_lines =
except ImportError:
if __name__ == '__main__':
pragma: no cover
pragma: nocover
raise AssertionError
raise NotImplementedError
raise unittest.Skip
self.fail\(

[html]
directory = parts/htmlcov
4 changes: 4 additions & 0 deletions config/c-code/packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Packages configured having C code are listed here.
# Do not edit the file by hand but use the script config-package.py as
# described in README.rst
zope.interface
24 changes: 24 additions & 0 deletions config/c-code/tests-cache.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- name: checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
###
# Caching.
# This actually *restores* a cache and schedules a cleanup action
# to save the cache. So it must come before the thing we want to use
# the cache.
###
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: %(cache_key)s
restore-keys: |
${{ runner.os }}-pip-
6 changes: 6 additions & 0 deletions config/c-code/tests-download.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

- name: Download %(package_name)s wheel
uses: actions/download-artifact@v2
with:
name: %(package_name)s-${{ runner.os }}-${{ matrix.python-version }}.whl
path: dist/
33 changes: 33 additions & 0 deletions config/c-code/tests-strategy.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
strategy:
matrix:
python-version:
{% if with_legacy_python %}
- 2.7
- 3.5
{% endif %}
{% if with_pypy and with_legacy_python %}
- pypy-2.7
{% endif %}
{% if with_pypy %}
- pypy-3.6
{% endif %}
- 3.6
- 3.7
- 3.8
- 3.9
os: [ubuntu-20.04, macos-latest]
{% if with_pypy or with_legacy_python %}
exclude:
{% endif %}
{% if with_pypy and with_legacy_python %}
- os: macos-latest
python-version: pypy-2.7
{% endif %}
{% if with_pypy %}
- os: macos-latest
python-version: pypy-3.6
{% endif %}
{% if with_legacy_python %}
- os: macos-latest
python-version: 3.5
{% endif %}
Loading