diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..70387ac --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +# Runs the unit tests for the pyroma package +# Based on https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Test package + +on: [pull_request, push] + +jobs: + build: + name: Run package tests + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ['3.6', '3.9', 'pypy-3.7'] + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: python -m pip install --upgrade pip + - name: Install package + run: pip install -e . + - name: Run tests + run: python -bb -X dev -W ignore::UserWarning:setuptools.dist -m unittest -v pyroma.tests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4d8d07c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: python -os: - - linux -matrix: - fast_finish: true - include: - - python: 3.6 - - python: 3.7 - - python: 3.8 - - python: 3.9 - - python: pypy3 -install: - - pip install -U setuptools>=39.2.0 - - python setup.py develop -script: python setup.py test - diff --git a/pyroma/distributiondata.py b/pyroma/distributiondata.py index 53196d1..df10c8d 100644 --- a/pyroma/distributiondata.py +++ b/pyroma/distributiondata.py @@ -1,10 +1,13 @@ -# Extracts information from a distribution file by unpacking in a temporary -# directory and then using projectdata on that. +""" +Extract information from a distribution file by unpacking in a temporary +directory and then using projectdata on that. +""" + import os import shutil +import tarfile import tempfile import zipfile -import tarfile from pyroma import projectdata @@ -15,9 +18,8 @@ def get_data(path): if basename.endswith(".tar"): basename, ignored = os.path.splitext(basename) + tempdir = tempfile.mkdtemp() try: - tempdir = tempfile.mkdtemp() - if ext in (".bz2", ".tbz", "tb2", ".gz", ".tgz", ".tar"): with tarfile.open(name=path, mode="r:*") as tar_file: tar_file.extractall(tempdir) @@ -31,8 +33,7 @@ def get_data(path): projectpath = os.path.join(tempdir, basename) data = projectdata.get_data(projectpath) - finally: - shutil.rmtree(tempdir) + shutil.rmtree(tempdir, ignore_errors=True) return data diff --git a/pyroma/tests.py b/pyroma/tests.py index 3e0433c..e3d90ea 100644 --- a/pyroma/tests.py +++ b/pyroma/tests.py @@ -1,6 +1,7 @@ -import unittest -import os import collections +import io +import os +import unittest try: from xmlrpc import client as xmlrpclib @@ -18,6 +19,8 @@ ) if not isinstance(long_description, str): long_description = long_description.decode() +# Translate newlines to universal format +long_description = io.StringIO(long_description, newline=None).read() COMPLETE = { "_setuptools": True,