Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Nunavut V2 is not a huge change from v1 but it the Python APIs are
different enough to warrant the semantic, major revision bump.

The core difference is a refactor of the Language objects to fully
support the properties.yaml schema and allow overrides to be provided to
nnvg.

Co-authored-by: Kening Hu <kening@amazon.com>

* refactoring Python API (OpenCyphal#266)

* refactoring Python API

* shoring up coverage

* fixing CI

* Cyphalization and rolling back c++11 stuff

* whoops

* Add fix for primitive memebers initialization and C++ constants stropping (OpenCyphal#270)

* Updating CI workflow

Updating actions and fixing older python versions to the platforms that had support for them.

---------

Co-authored-by: Kening Hu <kening@amazon.com>
  • Loading branch information
thirtytwobits and keningatamazon authored Jan 27, 2023
1 parent 25bc50b commit 8fff5a0
Show file tree
Hide file tree
Showing 105 changed files with 3,488 additions and 2,826 deletions.
12 changes: 6 additions & 6 deletions .github/verify.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
#
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# Copyright (C) 2018-2021 UAVCAN Development Team <uavcan.org>
# Copyright (C) 2018-2021 OpenCyphal Development Team <opencyphal.org>
# This software is distributed under the terms of the MIT License.
#
"""
Expand Down Expand Up @@ -87,11 +87,11 @@ def _make_parser() -> argparse.ArgumentParser:
action="store_true",
help=textwrap.dedent(
"""
Print out the version number (stored in src/nunavut/version.py) only and exit. This number
Print out the version number (stored in src/nunavut/_version.py) only and exit. This number
will be the only output to stdout allowing build scripts to extract this string value for
use in the build environment. For example:
export NUNAVUT_FULL_VERSION=$(./verify.py --version-only)
export NUNAVUT_FULL_VERSION=$(./_verify.py --version-only)
"""[
1:
Expand All @@ -104,11 +104,11 @@ def _make_parser() -> argparse.ArgumentParser:
action="store_true",
help=textwrap.dedent(
"""
Print out the major and minor version number (stored in src/nunavut/version.py) only and exit.
Print out the major and minor version number (stored in src/nunavut/_version.py) only and exit.
This number will be the only output to stdout allowing build scripts to extract this string
value for use in the build environment. For example:
export NUNAVUT_MAJOR_MINOR_VERSION=$(./verify.py --major-minor-version-only)
export NUNAVUT_MAJOR_MINOR_VERSION=$(./_verify.py --major-minor-version-only)
"""[
1:
Expand Down Expand Up @@ -541,7 +541,7 @@ def _create_build_dir_name(args: argparse.Namespace) -> str:

@functools.lru_cache(maxsize=None)
def _get_version_string() -> typing.Tuple[str, str, str]:
with open("src/nunavut/version.py", "r") as version_py:
with open("src/nunavut/_version.py", "r") as version_py:
exec(version_py.read())

version_string = typing.cast(str, eval("__version__"))
Expand Down
77 changes: 34 additions & 43 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
- name: install-tox
run: pip3 install tox
- name: lint
run: tox -e lint
- name: test-nnvg
run: tox -e py39-nnvg
run: tox -e py310-nnvg
- name: test-doctest
run: tox -e py39-doctest,py39-rstdoctest
run: tox -e py310-doctest,py310-rstdoctest
- name: test-pytest
run: tox -e py39-test
run: tox -e py310-test
- name: test-report
run: tox -e report
- name: package
run: tox -e package
- name: upload-coverage-reports
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: coverage-reports
path: .tox/report/tmp/*
- name: upload-xunit-results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: xunit-results
path: .tox/py39-test/tmp/xunit-result.xml
path: .tox/py310-test/tmp/xunit-result.xml
- name: upload-package
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pypi-package
path: .tox/package/dist/*
Expand All @@ -51,22 +51,22 @@ jobs:
needs: test
container: sonarsource/sonar-scanner-cli
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: sonar-cache
uses: actions/cache@v2
with:
path: /opt/sonar-scanner/.sonar/cache
key: sonar-scanner-cli-4.6.2.2472-${{ runner.os }}
- name: download-converage-reports
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: coverage-reports
path: .tox/report/tmp/
- name: download-xunit-results
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: xunit-results
path: .tox/py39-test/tmp/
path: .tox/py310-test/tmp/
- name: set-environment
run: |
echo NUNAVUT_MAJOR_MINOR_VERSION=$(./.github/verify.py --major-minor-version-only) >> $GITHUB_ENV
Expand Down Expand Up @@ -97,36 +97,27 @@ jobs:
-Dsonar.python.version=python3.9
compat-test-python3:
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
python3-version: ['6', '7', '8', '9', '10']
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.${{ matrix.python3-version }}
- name: setup tox
run: pip3 install tox
- name: python3.${{ matrix.python3-version }} test
run: tox -e py3${{ matrix.python3-version }}-nnvg,py3${{ matrix.python3-version }}-test

compat-test-windows:
runs-on: windows-latest
python3-version: ['10']
python3-platform: ['ubuntu-latest', 'windows-latest', 'macos-latest']
include:
- python3-version: 6
python3-platform: ubuntu-18.04
- python3-version: 7
python3-platform: ubuntu-20.04
- python3-version: 8
python3-platform: ubuntu-20.04
- python3-version: 9
python3-platform: ubuntu-20.04
runs-on: ${{ matrix.python3-platform }}
needs: test
strategy:
matrix:
python3-version: ['9', '10']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- name: setup python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.${{ matrix.python3-version }}
- name: setup tox
Expand All @@ -151,7 +142,7 @@ jobs:
- build_type: Release
flag: --disable-asserts
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- name: verify
Expand Down Expand Up @@ -182,7 +173,7 @@ jobs:
flag: --disable-asserts

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- name: verify
Expand Down Expand Up @@ -214,7 +205,7 @@ jobs:
flag: --disable-asserts

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- name: verify
Expand All @@ -231,13 +222,13 @@ jobs:
release:
if: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && github.repository == 'OpenCyphal/nunavut' }}
runs-on: ubuntu-latest
needs: [compat-test-python3, language-verification-cpp-14, language-verification-cpp-17, language-verification-c, sonar, compat-test-windows]
needs: [compat-test-python3, language-verification-cpp-14, language-verification-cpp-17, language-verification-c, sonar]
steps:
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: download-package
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: pypi-package
path: .tox/package/dist/
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contributor Notes
#####################

Hi! Thanks for contributing. This page contains all the details about getting
|:wave:| Thanks for contributing. This page contains all the details about getting
your dev environment setup.

.. note::
Expand All @@ -16,7 +16,7 @@ your dev environment setup.

.. warning::

When committing to main you **must** bump at least the patch number in ``src/nunavut/version.py``
When committing to main you **must** bump at least the patch number in ``src/nunavut/_version.py``
or the build will fail on the upload step.


Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Partial example: generating a C struct
.. code-block:: jinja
/*
* UAVCAN data structure definition
* Cyphal data structure definition
*
* Auto-generated, do not edit.
*
Expand Down Expand Up @@ -163,7 +163,7 @@ The documentation for Nunavut is hosted on readthedocs.io:
- `nunavut contributors guide`_ – Documentation for contributors to the Nunavut project.
- `nunavut licenses`_ – Licenses and copyrights

Nunavut is part of the UAVCAN project:
Nunavut is part of the OpenCyphal project:

- `OpenCyphal website`_
- `OpenCyphal forum`_
Expand Down
15 changes: 6 additions & 9 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,21 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from nunavut.version import __version__
from datetime import date
from nunavut._version import __version__ as nunavut_version
from nunavut._version import __copyright__ as nunavut_copyright

# -- Project information -----------------------------------------------------

project = "nunavut"
copyright = (
"{YEAR} Amazon.com, Inc. or its affiliates. All Rights Reserved. {YEAR}, OpenCyphal Development Team".format(
YEAR=date.today().year
)
)
copyright = nunavut_copyright

author = "OpenCyphal Development Team"

_version_tuple = __version__.split(".")
_version_tuple = nunavut_version.split(".")
# The short X.Y version
version = "{}.{}".format(_version_tuple[0], _version_tuple[1])
# The full version, including alpha/beta/rc tags
release = __version__
release = nunavut_version

exclude_patterns = ["**/test"]

Expand Down Expand Up @@ -58,6 +54,7 @@
"sphinx.ext.githubpages",
"sphinxarg.ext",
"sphinx.ext.intersphinx",
"sphinxemoji.sphinxemoji",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
Loading

0 comments on commit 8fff5a0

Please sign in to comment.