Skip to content
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
38 changes: 38 additions & 0 deletions .github/workflows/build-release-artifacts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build Release Artifacts

on:
release:
types: [created]

jobs:
build-and-publish:
name: Build and Release Artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get release information
id: get_release
uses: bruceadams/get-release@v1.2.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ply sphinx sphinx sphinx_rtd_theme
- name: Build manpage
run: python -m sphinx -b man docs dist
- name: Archive manpage
run: tar -czvf manpage.tar.gz -C dist pyxtuml.1
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: manpage.tar.gz
asset_name: manpage.tar.gz
asset_content_type: application/gzip
26 changes: 26 additions & 0 deletions .github/workflows/publish-pypi-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# See: https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

name: Publish Source Packages to PyPI

on:
release:
types: [created]

jobs:
build-and-publish:
name: Build and Publish Source Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3
uses: actions/setup-python@v1
with:
python-version: 3.x
- name: Install pypa/build
run: python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/publish-test-results.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Unit Test Results

on:
workflow_run:
workflows: ['Run Unit Tests']
types:
- completed

jobs:
unit-test-results:
name: Publish Unit Test Results
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion != 'skipped'

steps:
- name: Download and Extract Artifacts
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
mkdir -p artifacts && cd artifacts

artifacts_url=${{ github.event.workflow_run.artifacts_url }}

gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
do
IFS=$'\t' read name url <<< "$artifact"
gh api $url > "$name.zip"
unzip -d "$name" "$name.zip"
done

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: artifacts/Event File/event.json
event_name: ${{ github.event.workflow_run.event }}
files: "artifacts/**/*.xml"
52 changes: 52 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Run Unit Tests

on:
push:
branches:
- master
pull_request:
release:

jobs:

build-and-test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: [2.7, 3.x, pypy2, pypy3]
exclude:
# excludes pypy 3 on Windows
- os: windows-latest
python-version: pypy3
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build pyxtuml
run: python setup.py build
- name: Run Unit Tests
run: pytest tests --doctest-modules --junitxml=test-results/test-results-${{ matrix.python-version }}.xml
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Results (Python ${{ matrix.python-version }})
path: test-results/test-results-${{ matrix.python-version }}.xml

event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v2
with:
name: Event File
path: ${{ github.event_path }}
30 changes: 30 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run Coverage Analysis

on:
push:
branches:
- master
pull_request:
release:

jobs:
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 2.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install coveralls
- name: Run coverage analysis
run: coverage run --source=xtuml,bridgepoint setup.py test
- name: Upload to Coveralls
run: coveralls --service=github
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
sphinx:
configuration: docs/conf.py
python:
version: 3.8
install:
- requirements: docs/requirements.txt
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

27 changes: 0 additions & 27 deletions appveyor.yml

This file was deleted.

4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sphinx==4.2.0
sphinx_rtd_theme==1.0.0
readthedocs-sphinx-search==0.1.1
ply==3.11
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ply
ply
pytest
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ def run(self):
sys.exit(exit_code)


from os import path
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.rst')) as f:
long_description = f.read()

setup(name='pyxtuml',
version='2.2.2', # ensure that this is the same as in xtuml.version
description='Library for parsing, manipulating, and generating BridgePoint xtUML models',
long_description=long_description,
long_description_content_type='text/x-rst',
author=u'John Törnblom',
author_email='john.tornblom@gmail.com',
url='https://github.com/xtuml/pyxtuml',
Expand Down
21 changes: 18 additions & 3 deletions tests/test_xtuml/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import sys
import unittest
import pytest

import xtuml.tools

Expand All @@ -44,7 +45,11 @@ def test_node(self):

w.accept(root)

s = sys.stdout.getvalue()
try:
s = sys.stdout.getvalue()
except AttributeError:
s, _ = self.capfd.readouterr()

expected = 'Node\n'
expected += ' Node\n'
expected += ' Node\n'
Expand All @@ -57,7 +62,10 @@ def test_generic_class(self):

w.accept(self)

s = sys.stdout.getvalue()
try:
s = sys.stdout.getvalue()
except AttributeError:
s, _ = self.capfd.readouterr()

self.assertEqual(s, 'TestNodePrinter\n')

Expand All @@ -67,10 +75,17 @@ def test_none(self):

w.accept(None)

s = sys.stdout.getvalue()
try:
s = sys.stdout.getvalue()
except AttributeError:
s, _ = self.capfd.readouterr()

self.assertEqual(s, '')

@pytest.fixture(autouse=True)
def capfd(self, capfd):
self.capfd = capfd


class TestIdGenerator(unittest.TestCase):
'''
Expand Down
4 changes: 2 additions & 2 deletions xtuml/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def _populate_instance_with_positional_arguments(metamodel, stmt):

metaclass = metamodel.find_metaclass(stmt.kind)
if len(metaclass.attributes) != len(stmt.values):
logger.warn('%s:%d:schema mismatch' % (stmt.filename, stmt.lineno))
logger.warning('%s:%d:schema mismatch' % (stmt.filename, stmt.lineno))

inst = metamodel.new(stmt.kind)
for attr, value in zip(metaclass.attributes, stmt.values):
Expand Down Expand Up @@ -341,7 +341,7 @@ def _populate_instance_with_named_arguments(metamodel, stmt):
inst_unames = [name.upper() for name in stmt.names]

if set(inst_unames) - set(schema_unames):
logger.warn('%s:%d:schema mismatch' % (stmt.filename, stmt.lineno))
logger.warning('%s:%d:schema mismatch' % (stmt.filename, stmt.lineno))

inst = metamodel.new(stmt.kind)
for name, ty in metaclass.attributes:
Expand Down
11 changes: 9 additions & 2 deletions xtuml/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
'''

import logging
import collections

import xtuml

Expand All @@ -32,6 +31,14 @@
except ImportError:
pass

import collections
try:
# Python 3.x
collectionsAbc = collections.abc
except:
# Python 2.7
collectionsAbc = collections


logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -741,7 +748,7 @@ def __init__(self, handle):
elif isinstance(handle, Class):
handle = [handle]

elif not isinstance(handle, collections.Iterable):
elif not isinstance(handle, collectionsAbc.Iterable):
raise MetaException("Unable to navigate across '%s'" % type(handle))

self.handle = handle
Expand Down
11 changes: 9 additions & 2 deletions xtuml/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@
#
# You should have received a copy of the GNU Lesser General Public
# License along with pyxtuml. If not, see <http://www.gnu.org/licenses/>.
import collections
import uuid

import collections
try:
# Python 3.x
collectionsAbc = collections.abc
except:
# Python 2.7
collectionsAbc = collections


class IdGenerator(object):
'''
Expand Down Expand Up @@ -121,7 +128,7 @@ def default_leave(self, node):
pass


class OrderedSet(collections.MutableSet):
class OrderedSet(collectionsAbc.MutableSet):
'''
Set that remembers original insertion order.
'''
Expand Down