Skip to content

Commit

Permalink
Merge branch 'master' into fix/don_t_get_dependencies_of_non_ros_pack…
Browse files Browse the repository at this point in the history
…ages
  • Loading branch information
cottsay committed May 3, 2024
2 parents 76a44b6 + c928730 commit bdd4e16
Show file tree
Hide file tree
Showing 22 changed files with 79 additions and 62 deletions.
40 changes: 13 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
name: rosdistro-ci
---
name: Run tests

on:
on: # yamllint disable-line rule:truthy
push:
branches: [master]
branches: ['master']
pull_request:

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python: ['3.7', '3.8', '3.9', '3.10']
include:
- os: ubuntu-18.04
python: '2.7'
- os: ubuntu-18.04
python: '3.6'
name: rosdistro tests
runs-on: ${{matrix.os}}

pytest:
uses: ros-infrastructure/ci/.github/workflows/pytest.yaml@main
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{matrix.python}}
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python}}
- name: Install dependencies
run: |
python -m pip install -U -e .[test] pytest-cov -c constraints.txt
- name: Run tests
run: |
python -m pytest test --cov
- uses: actions/checkout@v4
- run: >-
yamllint .
-f github
-d '{extends: default, ignore: [test/files/foo/*.yaml]}'
2 changes: 0 additions & 2 deletions constraints.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/rosdistro/distribution_cache_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def generate_distribution_cache(index, dist_name, preclean=False, ignore_local=F
errors.append('%s: invalid package.xml file for package "%s": %s' % (dist_name, pkg_name, e))
continue
# check that version numbers match (at least without deb inc)
if not re.match('^%s(-[\dA-z~\+\.]+)?$' % re.escape(pkg.version), repo.version):
if not re.match(r'^%s(-[\dA-z~\+\.]+)?$' % re.escape(pkg.version), repo.version):
errors.append('%s: different version in package.xml (%s) for package "%s" than for the repository (%s) (after removing the debian increment)' % (dist_name, pkg.version, pkg_name, repo.version))

if package_xml != old_package_xml:
Expand Down
4 changes: 2 additions & 2 deletions src/rosdistro/external/appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):


def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
"""Return full path to the user-shared data dir for this application.
r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
Expand Down Expand Up @@ -200,7 +200,7 @@ def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):


def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
"""Return full path to the user-shared data dir for this application.
r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
Expand Down
2 changes: 1 addition & 1 deletion src/rosdistro/manifest_provider/tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def tar_manifest_provider(_dist_name, repo, pkg_name):

response = urlopen(request)
with tarfile.open(fileobj=io.BytesIO(response.read())) as tar:
package_xml = tar.extractfile(os.path.join(subdir, 'package.xml')).read()
package_xml = tar.extractfile(subdir + '/package.xml').read()

# Python2 returns strings, Python3 returns bytes-- support both
try:
Expand Down
2 changes: 1 addition & 1 deletion src/rosdistro/release_cache_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def generate_release_cache(index, dist_name, preclean=False, debug=False):
errors.append('%s: invalid package.xml file for package "%s"' % (dist_name, pkg_name))
continue
# check that version numbers match (at least without deb inc)
if not re.match('^%s(-[\dA-z~\+\.]+)?$' % re.escape(pkg.version), repo.version):
if not re.match(r'^%s(-[\dA-z~\+\.]+)?$' % re.escape(pkg.version), repo.version):
errors.append('%s: different version in package.xml (%s) for package "%s" than for the repository (%s) (after removing the debian increment)' % (dist_name, pkg.version, pkg_name, repo.version))

if not debug:
Expand Down
2 changes: 1 addition & 1 deletion src/rosdistro/repository_specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

class RepositorySpecification(object):
# Match groups are server and path on server.
VCS_REGEX = re.compile('(?:https?:\/\/|ssh:\/\/|git:\/\/|git@)((?:[a-fA-F0-9]{40}@)?[\w.-]+)[:/]([\w/-]*)(?:\.git)?$')
VCS_REGEX = re.compile(r'(?:https?:\/\/|ssh:\/\/|git:\/\/|git@)((?:[a-fA-F0-9]{40}@)?[\w.-]+)[:/]([\w/-]*)(?:\.git)?$')

def __init__(self, name, data):
self.name = name
Expand Down
2 changes: 1 addition & 1 deletion src/rosdistro/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def ref_is_hash(ref):
def _run_command(cmd, cwd=None, env=None):
result = {'cmd': ' '.join(cmd), 'cwd': cwd}
try:
proc = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
proc = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, env=env)
output, _ = proc.communicate()
result['output'] = output.rstrip()
result['returncode'] = proc.returncode
Expand Down
4 changes: 2 additions & 2 deletions stdeb.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Conflicts: python3-rosdistro
Conflicts3: python-rosdistro
Copyright-File: LICENSE.txt
Suite: bionic cosmic disco eoan buster
Suite3: bionic cosmic disco eoan focal jammy buster bullseye
Suite3: focal jammy noble bookworm trixie
Python2-Depends-Name: python
X-Python3-Version: >= 3.4
Setup-Env-Vars: SKIP_PYTHON_MODULES=1
Expand All @@ -26,7 +26,7 @@ Replaces: python-rosdistro (<< 0.6.0)
Replaces3: python3-rosdistro (<< 0.6.0)
Copyright-File: LICENSE.txt
Suite: bionic cosmic disco eoan buster
Suite3: bionic cosmic disco eoan focal jammy buster bullseye
Suite3: focal jammy noble bookworm trixie
Python2-Depends-Name: python
X-Python3-Version: >= 3.4
Setup-Env-Vars: SKIP_PYTHON_SCRIPTS=1
9 changes: 9 additions & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import os
import sys
try:
from urllib.parse import urljoin
from urllib.request import pathname2url
except ImportError:
from urlparse import urljoin
from urllib import pathname2url

sys.path.insert(0, os.path.join(
os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
'src'))

def path_to_url(path):
return urljoin('file:', pathname2url(path))
4 changes: 3 additions & 1 deletion test/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

from rosdistro import get_distribution_cache, get_index

from . import path_to_url

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files'))


def test_get_release_cache():
url = 'file://' + FILES_DIR + '/index_v2.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
i = get_index(url)
get_distribution_cache(i, 'foo')
6 changes: 4 additions & 2 deletions test/test_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@

import yaml

from . import path_to_url

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files'))


def test_distribution_file():
url = 'file://' + FILES_DIR + '/foo/distribution.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'foo', 'distribution.yaml'))
yaml_str = load_url(url)
data = yaml.safe_load(yaml_str)
dist_file = DistributionFile('foo', data)
_validate_dist_file(dist_file)


def test_get_distribution_file():
url = 'file://' + FILES_DIR + '/index_v2.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
i = get_index(url)
dist_file = get_distribution_file(i, 'foo')
_validate_dist_file(dist_file)
Expand Down
6 changes: 4 additions & 2 deletions test/test_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@

import yaml

from . import path_to_url

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files'))


def test_doc_file():
url = 'file://' + FILES_DIR + '/foo/distribution.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'foo', 'distribution.yaml'))
yaml_str = load_url(url)
data = yaml.safe_load(yaml_str)
doc_file = DocFile('foo', data)
_validate_doc_file(doc_file)


def test_get_doc_file():
url = 'file://' + FILES_DIR + '/index_v2.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
i = get_index(url)
doc_file = get_doc_file(i, 'foo')
_validate_doc_file(doc_file)
Expand Down
6 changes: 4 additions & 2 deletions test/test_doc_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@

import yaml

from . import path_to_url

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files'))


def test_doc_build_file():
url = 'file://' + FILES_DIR + '/foo/doc-build.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'foo', 'doc-build.yaml'))
yaml_str = load_url(url)
data = yaml.safe_load(yaml_str)
DocBuildFile('foo', data)


def test_get_doc_build_files():
url = 'file://' + FILES_DIR + '/index_v2.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
i = get_index(url)
files = get_doc_build_files(i, 'foo')
assert len(files) == 1
Expand Down
10 changes: 6 additions & 4 deletions test/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from rosdistro import get_index
from rosdistro import get_index_url

from . import path_to_url

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files'))


Expand All @@ -13,7 +15,7 @@ def test_get_index_url():


def test_get_index_v2():
url = 'file://' + FILES_DIR + '/index_v2.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
i = get_index(url)
assert len(i.distributions.keys()) == 1
assert 'foo' in i.distributions.keys()
Expand All @@ -23,7 +25,7 @@ def test_get_index_v2():


def test_get_index_v3():
url = 'file://' + FILES_DIR + '/index_v3.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v3.yaml'))
i = get_index(url)
assert len(i.distributions.keys()) == 1
assert 'foo' in i.distributions.keys()
Expand All @@ -37,7 +39,7 @@ def test_get_index_v3():


def test_get_index_v3_invalid():
url = 'file://' + FILES_DIR + '/index_v3_invalid.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v3_invalid.yaml'))
i = get_index(url)

dist_files = get_distribution_files(i, 'foo')
Expand All @@ -50,7 +52,7 @@ def test_get_index_v3_invalid():


def test_get_index_v4():
url = 'file://' + FILES_DIR + '/index_v4.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v4.yaml'))
i = get_index(url)
assert len(i.distributions.keys()) == 1
assert 'foo' in i.distributions.keys()
Expand Down
4 changes: 3 additions & 1 deletion test/test_manifest_providers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-

import os

try:
from unittest.mock import patch
except ImportError:
Expand Down Expand Up @@ -109,7 +111,7 @@ def test_git_source_multi():
repo_cache = git_source_manifest_provider(_ros_source_repo())
assert repo_cache.ref()
package_path, package_xml = repo_cache['roslib']
assert package_path == 'core/roslib'
assert package_path == os.path.join('core', 'roslib')


def test_tar_source():
Expand Down
6 changes: 4 additions & 2 deletions test/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@

import yaml

from . import path_to_url

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files'))


def test_release_file():
url = 'file://' + FILES_DIR + '/foo/distribution.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'foo', 'distribution.yaml'))
yaml_str = load_url(url)
data = yaml.safe_load(yaml_str)
rel_file = ReleaseFile('foo', data)
_validate_rel_file(rel_file)


def test_get_release_file():
url = 'file://' + FILES_DIR + '/index_v2.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
i = get_index(url)
rel_file = get_release_file(i, 'foo')
_validate_rel_file(rel_file)
Expand Down
8 changes: 5 additions & 3 deletions test/test_release_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@

import yaml

from . import path_to_url

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files'))


def test_release_build_file():
url = 'file://' + FILES_DIR + '/foo/release-build.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'foo', 'release-build.yaml'))
yaml_str = load_url(url)
data = yaml.safe_load(yaml_str)
ReleaseBuildFile('foo', data)


def test_get_release_build_files():
url = 'file://' + FILES_DIR + '/index_v2.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
i = get_index(url)
get_release_build_files(i, 'foo')


def test_get_release_builds():
url = 'file://' + FILES_DIR + '/index_v2.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
i = get_index(url)
d = get_release(i, 'foo')
builds = get_release_builds(i, d)
Expand Down
6 changes: 4 additions & 2 deletions test/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@

import yaml

from . import path_to_url

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files'))


def test_source_file():
url = 'file://' + FILES_DIR + '/foo/distribution.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'foo', 'distribution.yaml'))
yaml_str = load_url(url)
data = yaml.safe_load(yaml_str)
src_file = SourceFile('foo', data)
_validate_src_file(src_file)


def test_get_source_file():
url = 'file://' + FILES_DIR + '/index_v2.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
i = get_index(url)
src_file = get_source_file(i, 'foo')
_validate_src_file(src_file)
Expand Down
6 changes: 4 additions & 2 deletions test/test_source_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@

import yaml

from . import path_to_url

FILES_DIR = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files'))


def test_source_build_file():
url = 'file://' + FILES_DIR + '/foo/source-build.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'foo', 'source-build.yaml'))
yaml_str = load_url(url)
data = yaml.safe_load(yaml_str)
SourceBuildFile('foo', data)


def test_get_source_build_files():
url = 'file://' + FILES_DIR + '/index_v2.yaml'
url = path_to_url(os.path.join(FILES_DIR, 'index_v2.yaml'))
i = get_index(url)
files = get_source_build_files(i, 'foo')
assert len(files) == 1
Expand Down
Loading

0 comments on commit bdd4e16

Please sign in to comment.