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

Test on GitHub Actions #494

Merged
merged 8 commits into from Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/examples.yml
@@ -0,0 +1,45 @@
name: Examples

on: [push, pull_request, workflow_dispatch]

env:
FORCE_COLOR: 1

jobs:
examples:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [
"src-layout",
"adhoc-layout",
]

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key:
examples-v1-${{ hashFiles('**/tox.ini') }}
restore-keys: |
examples-v1-

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U wheel
python -m pip install --progress-bar=off tox -rci/requirements.txt

- name: Examples
run: |
cd examples/${{ matrix.target }}
tox -v
41 changes: 41 additions & 0 deletions .github/workflows/lint.yml
@@ -0,0 +1,41 @@
name: Lint

on: [push, pull_request, workflow_dispatch]

env:
FORCE_COLOR: 1

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toxenv: ["check", "docs"]

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key:
lint-v1-${{ hashFiles('**/tox.ini') }}
restore-keys: |
lint-v1-

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U wheel
python -m pip install --progress-bar=off tox -rci/requirements.txt

- name: Lint ${{ matrix.toxenv }}
run: |
tox -v -e ${{ matrix.toxenv }}
48 changes: 45 additions & 3 deletions .github/workflows/test.yml
Expand Up @@ -11,7 +11,26 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
python-version: ["pypy3", "3.6", "3.7", "3.8", "3.9"]
hugovk marked this conversation as resolved.
Show resolved Hide resolved
tox-extra-versions: [
"pytest46-xdist127",
"pytest46-xdist133",
"pytest54-xdist133",
"pytest62-xdist202",
]
include:
# Add new helper variables to existing jobs
- {python-version: "pypy3", tox-python-version: "pypy3"}
- {python-version: "3.6", tox-python-version: "py36"}
- {python-version: "3.7", tox-python-version: "py37"}
- {python-version: "3.8", tox-python-version: "py38"}
- {python-version: "3.9", tox-python-version: "py39"}
exclude:
# Remove some jobs from the matrix
- {tox-extra-versions: "pytest46-xdist127", python-version: "3.8"}
- {tox-extra-versions: "pytest46-xdist127", python-version: "3.9"}
- {tox-extra-versions: "pytest46-xdist133", python-version: "3.9"}
- {tox-extra-versions: "pytest54-xdist133", python-version: "3.9"}

steps:
- uses: actions/checkout@v2
Expand All @@ -21,6 +40,29 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Hello world
- name: Get pip cache dir
id: pip-cache
run: |
echo "hello world"
echo "::set-output name=dir::$(pip cache dir)"

- name: Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
test-${{ matrix.python-version }}-v1-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
test-${{ matrix.python-version }}-v1-

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U wheel
python -m pip install --progress-bar=off tox -rci/requirements.txt
virtualenv --version
pip --version
tox --version

- name: Tox tests
run: |
tox -v -e ${{ matrix.tox-python-version }}-${{ matrix.tox-extra-versions }}-coverage55
89 changes: 0 additions & 89 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Expand Up @@ -73,8 +73,8 @@ For merging, you should:
3. Add a note to ``CHANGELOG.rst`` about the changes.
4. Add yourself to ``AUTHORS.rst``.

.. [1] If you don't have all the necessary python versions available locally you can rely on Travis - it will
`run the tests <https://travis-ci.com//github/pytest-dev/pytest-cov/pull_requests>`_
.. [1] If you don't have all the necessary Python versions available locally you can rely on GitHub Actions - it will
`run the tests <https://github.com/pytest-dev/pytest-cov/actions>`_
for each change you add in the pull request.

It will be slower though ...
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Expand Up @@ -6,6 +6,7 @@ prune examples/*/*/htmlcov
prune examples/adhoc-layout/*.egg-info
prune examples/src-layout/src/*.egg-info

graft .github/workflows
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason for publishing the github workflow to pypi? they both use actions/checkout@v2 which won't work without a live git repo and can't work from the sdist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the reason is .travis.yml .appveyor.yml were/is included below, so I was aiming for parity.

Can remove if you like?

Copy link
Member

@graingert graingert Sep 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the best option here is.

I assume all these includes come as a result of check-manifest's default recommendation of including files rather than excluding them. I think using the "wheel_from_sdist", build strategy and then using that wheel in tox is the state of the art for ensuring your MANIFEST is correct pypa/build#257

another option is to follow pytest-dev/pytest's approach of using setuptools-scm, which makes the MANIFEST.in redundant

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion here, although I use setuptools-scm elsewhere and it makes things easy. Something for a followup issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fair to include it in the sdist, considering travis stuff was previously included, and it would be useful to have some evidence in the sdist of how that particular release was supposed to be tested.

graft src
graft ci
graft tests
Expand All @@ -21,6 +22,6 @@ include CONTRIBUTING.rst
include LICENSE
include README.rst

include tox.ini .travis.yml .appveyor.yml .readthedocs.yml .pre-commit-config.yaml
include tox.ini .appveyor.yml .readthedocs.yml .pre-commit-config.yaml

global-exclude *.py[cod] __pycache__/* *.so *.dylib .coverage .coverage.*
8 changes: 4 additions & 4 deletions README.rst
Expand Up @@ -10,7 +10,7 @@ Overview
* - docs
- |docs|
* - tests
- | |travis| |appveyor| |requires|
- | |github-actions| |appveyor| |requires|
* - package
- | |version| |conda-forge| |wheel| |supported-versions| |supported-implementations|
| |commits-since|
Expand All @@ -19,9 +19,9 @@ Overview
:target: https://readthedocs.org/projects/pytest-cov
:alt: Documentation Status

.. |travis| image:: https://api.travis-ci.com/pytest-dev/pytest-cov.svg?branch=master
:alt: Travis-CI Build Status
:target: https://travis-ci.com/github/pytest-dev/pytest-cov
.. |github-actions| image:: https://github.com/pytest-dev/pytest-cov/actions/workflows/test.yml/badge.svg
:alt: GitHub Actions Status
:target: https://github.com/pytest-dev/pytest-cov/actions

.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/pytest-dev/pytest-cov?branch=master&svg=true
:alt: AppVeyor Build Status
Expand Down
61 changes: 0 additions & 61 deletions ci/templates/.travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/releasing.rst
Expand Up @@ -16,7 +16,7 @@ The process for releasing should follow these steps:
git push
git push --tags
#. Wait for `AppVeyor <https://ci.appveyor.com/project/pytestbot/pytest-cov>`_
and `Travis <https://travis-ci.org/schlamar/pytest-cov>`_ to give the green builds.
and `GitHub Actions <https://github.com/pytest-dev/pytest-cov/actions>`_ to give the green builds.
#. Check that the docs on `ReadTheDocs <https://readthedocs.org/projects/pytest-cov>`_ are built.
#. Make sure you have a clean checkout, run ``git status`` to verify.
#. Manually clean temporary files (that are ignored and won't show up in ``git status``)::
Expand Down
2 changes: 1 addition & 1 deletion docs/reporting.rst
Expand Up @@ -71,4 +71,4 @@ The final report option can also suppress printing to the terminal::

This mode can be especially useful on continuous integration servers, where a coverage file
is needed for subsequent processing, but no local report needs to be viewed. For example,
tests run on Travis-CI could produce a .coverage file for use with Coveralls.
tests run on GitHub Actions could produce a .coverage file for use with Coveralls.
Copy link
Member

@graingert graingert Sep 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a CI recommendation and coverage provider recommendation, perhaps more tools could go here? Or pytest-cov could collect sponsorship to recommend a specific CI provider and coverage provider?

eg GitLab has integrated support for coverage files (and recommend pytest-cov!) https://docs.gitlab.com/ee/user/project/merge_requests/test_coverage_visualization.html#python-example

just a heads up: no need to worry about this now in this PR though imho

14 changes: 2 additions & 12 deletions examples/adhoc-layout/example/__init__.py
@@ -1,12 +1,2 @@
import sys

PY2 = sys.version_info[0] == 2


if PY2:
def add(a, b):
return b + a

else:
def add(a, b):
return a + b
def add(a, b):
return a + b
hugovk marked this conversation as resolved.
Show resolved Hide resolved