From 7d3b10c915d40c3c8d805b8a666b5621a0367e3c Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Sat, 6 Nov 2021 00:24:51 -0400 Subject: [PATCH 01/12] Add files to pin dependencies for readthedocs build --- .readthedocs.yaml | 7 +++++++ docs/requirements.txt | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 .readthedocs.yaml create mode 100644 docs/requirements.txt diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..3c1c3e8 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,7 @@ +version: 2 +sphinx: + configuration: docs/conf.py +python: + version: 3.8 + install: + - requirements: docs/requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..5ce8bf2 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,4 @@ +sphinx==4.2.0 +sphinx_rtd_theme==1.0.0 +readthedocs-sphinx-search==0.1.1 +ply==3.11 From 8c4d3d76aad6b41206c0a2f7b3535d5c5fb87552 Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Sun, 29 Aug 2021 20:37:12 -0400 Subject: [PATCH 02/12] Support pytest for capturing standard output --- tests/test_xtuml/test_tools.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/test_xtuml/test_tools.py b/tests/test_xtuml/test_tools.py index 496935e..06da309 100644 --- a/tests/test_xtuml/test_tools.py +++ b/tests/test_xtuml/test_tools.py @@ -18,6 +18,7 @@ import sys import unittest +import pytest import xtuml.tools @@ -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' @@ -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') @@ -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): ''' From 41561fe1f6c396eecb8034170bb8fd3a6700f741 Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Sun, 29 Aug 2021 19:32:42 -0400 Subject: [PATCH 03/12] Add github action for running unit tests --- .github/workflows/run-tests.yaml | 53 ++++++++++++++++++++++++++++++++ requirements.txt | 3 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/run-tests.yaml diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml new file mode 100644 index 0000000..ec93a01 --- /dev/null +++ b/.github/workflows/run-tests.yaml @@ -0,0 +1,53 @@ +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] + 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 + + publish-test-results: + name: Publish Unit Tests Results + needs: build-and-test + runs-on: ubuntu-latest + if: always() + steps: + - name: Download Artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: artifacts/**/*.xml diff --git a/requirements.txt b/requirements.txt index e4f9a48..7729e67 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -ply \ No newline at end of file +ply +pytest From 0572a42ea66b6a25550200db1d6d5b6ce7777546 Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Mon, 30 Aug 2021 11:53:38 -0400 Subject: [PATCH 04/12] Exclude pypy3 on windows for testing due to compatiblility issue --- .github/workflows/run-tests.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index ec93a01..0789b85 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -14,6 +14,10 @@ jobs: 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: From 17fb65aa19ad211da632272ee50fb24a22af8f3b Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Thu, 2 Sep 2021 08:57:14 -0400 Subject: [PATCH 05/12] Add coverage analysis github action --- .github/workflows/test-coverage.yaml | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/test-coverage.yaml diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..e90106e --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -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 }} From f9e963e2225ee9038678dc146cb3ab113e0970c7 Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Fri, 5 Nov 2021 14:32:51 -0400 Subject: [PATCH 06/12] Fix deprecation warnings where possible --- xtuml/load.py | 4 ++-- xtuml/meta.py | 11 +++++++++-- xtuml/tools.py | 11 +++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/xtuml/load.py b/xtuml/load.py index a272606..4527ab0 100644 --- a/xtuml/load.py +++ b/xtuml/load.py @@ -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): @@ -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: diff --git a/xtuml/meta.py b/xtuml/meta.py index 8527ea8..d4c3e4d 100644 --- a/xtuml/meta.py +++ b/xtuml/meta.py @@ -21,7 +21,6 @@ ''' import logging -import collections import xtuml @@ -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__) @@ -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 diff --git a/xtuml/tools.py b/xtuml/tools.py index a5eb631..285c0b9 100644 --- a/xtuml/tools.py +++ b/xtuml/tools.py @@ -15,9 +15,16 @@ # # You should have received a copy of the GNU Lesser General Public # License along with pyxtuml. If not, see . -import collections import uuid +import collections +try: + # Python 3.x + collectionsAbc = collections.abc +except: + # Python 2.7 + collectionsAbc = collections + class IdGenerator(object): ''' @@ -121,7 +128,7 @@ def default_leave(self, node): pass -class OrderedSet(collections.MutableSet): +class OrderedSet(collectionsAbc.MutableSet): ''' Set that remembers original insertion order. ''' From 6c384827705b953dd9b22f92259cf63401f50d1f Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Fri, 5 Nov 2021 21:32:45 -0400 Subject: [PATCH 07/12] Add github action for uploading release artifacts --- .../workflows/build-release-artifacts.yaml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/build-release-artifacts.yaml diff --git a/.github/workflows/build-release-artifacts.yaml b/.github/workflows/build-release-artifacts.yaml new file mode 100644 index 0000000..dd17bf2 --- /dev/null +++ b/.github/workflows/build-release-artifacts.yaml @@ -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 From 9883ff5e11df5f739b33ede49c4c58f47e72b40f Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Fri, 5 Nov 2021 22:44:58 -0400 Subject: [PATCH 08/12] Adjust setup.py to fix missing long description --- setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup.py b/setup.py index ce03391..4bc5cd9 100755 --- a/setup.py +++ b/setup.py @@ -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', From 2aab15a42c4e9955ad4fd4f35b0ce42ce89b9bac Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Fri, 5 Nov 2021 22:09:32 -0400 Subject: [PATCH 09/12] Add github action for publishing code to PyPI --- .github/workflows/publish-pypi-release.yaml | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/publish-pypi-release.yaml diff --git a/.github/workflows/publish-pypi-release.yaml b/.github/workflows/publish-pypi-release.yaml new file mode 100644 index 0000000..8e1661e --- /dev/null +++ b/.github/workflows/publish-pypi-release.yaml @@ -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 }} From d88de7fdc1793036e6adde00cef9a282e06d9ac6 Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Sat, 6 Nov 2021 00:41:08 -0400 Subject: [PATCH 10/12] Remove old CI/CD config files --- .travis.yml | 12 ------------ appveyor.yml | 27 --------------------------- 2 files changed, 39 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 139a74b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: python -python: - - "3.6" - - "3.5" - - "2.7" -install: - - pip install ply - - pip install coveralls -script: - - coverage run --source=xtuml,bridgepoint setup.py test -after_success: - - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then coveralls; fi diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 955bb4e..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,27 +0,0 @@ -build: off - -environment: - matrix: - - PYTHON: "C:\\Python27" - PYTHON_VERSION: "2.7.x" - PYTHON_ARCH: "32" - -init: - - "%PYTHON%/python --version" - -install: - - "%PYTHON%/python -m pip install ply" - - "%PYTHON%/python -m pip install sphinx" - - "%PYTHON%/python -m pip install sphinx_rtd_theme" - -before_test: - - "%PYTHON%/python setup.py build" - -test_script: - - "%PYTHON%/python setup.py test" - -after_test: - - "%PYTHON%/python -m sphinx -b man docs dist" - -artifacts: - - path: dist\* From ed36d85f4b2c12c50a75e8c5353cd74abc6b27b5 Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Sat, 6 Nov 2021 00:53:54 -0400 Subject: [PATCH 11/12] WIP test tests working with forks --- .github/workflows/publish-test-results.yaml | 37 +++++++++++++++++++++ .github/workflows/run-tests.yaml | 21 +++++------- 2 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/publish-test-results.yaml diff --git a/.github/workflows/publish-test-results.yaml b/.github/workflows/publish-test-results.yaml new file mode 100644 index 0000000..735e6ac --- /dev/null +++ b/.github/workflows/publish-test-results.yaml @@ -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" diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 0789b85..e9a0644 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -41,17 +41,12 @@ jobs: name: Unit Test Results (Python ${{ matrix.python-version }}) path: test-results/test-results-${{ matrix.python-version }}.xml - publish-test-results: - name: Publish Unit Tests Results - needs: build-and-test - runs-on: ubuntu-latest - if: always() - steps: - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - path: artifacts - - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v1 + event_file: + name: "Event File" + runs-on: ubuntu-latest + steps: + - name: Upload + uses: actions/upload-artifact@v2 with: - files: artifacts/**/*.xml + name: Event File + path: ${{ github.event_path }} From bede08cc0efa0980aee03b661e44960d3426db7c Mon Sep 17 00:00:00 2001 From: Levi Starrett Date: Sat, 6 Nov 2021 00:55:28 -0400 Subject: [PATCH 12/12] fixup --- .github/workflows/run-tests.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index e9a0644..4558683 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -41,12 +41,12 @@ jobs: 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 }} + 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 }}