Skip to content

Commit

Permalink
Developments in formatting, mostly (#50)
Browse files Browse the repository at this point in the history
* Single project (#49)
* Pre commit setup (#51)
* Black for formatting (#54)

---------

Signed-off-by: Christian Henkel <[email protected]>
  • Loading branch information
ct2034 authored Oct 8, 2024
1 parent d0d2088 commit c8e5f6f
Show file tree
Hide file tree
Showing 236 changed files with 3,832 additions and 2,867 deletions.
74 changes: 40 additions & 34 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
name: Lint

on:
push:
branches: [ main ]
branches: [ "main" ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
name: ${{ matrix.package }} ⏩ ${{ matrix.linter }}
build:
name: Pre-commit checks
strategy:
fail-fast: false
matrix:
linter: [
"pylint",
"pycodestyle",
"flake8",
"mypy",
"isort"
]
package: [ "jani_generator", "as2fm_common", "scxml_converter" ]
# linter: [
# "pylint",
# "pycodestyle",
# "flake8",
# "mypy",
# "isort"
# ]
# package: [
# "as2fm_common",
# "jani_generator",
# "jani_visualizer",
# "scxml_converter",
# "trace_visualizer"
# ]
include:
# (for humble):
- python-version: "3.10"
- python-version: "3.10"
# os: "ubuntu-latest"
runs-on: ubuntu-latest

Expand Down Expand Up @@ -54,24 +60,24 @@ jobs:
pip install -e btlib/.
- name: Install packages
run: |
pip install jani_generator/.[dev]
pip install as2fm_common/.[dev]
pip install scxml_converter/.[dev]
- uses: marian-code/python-lint-annotate@v4
with:
python-root-list: ${{ matrix.package }}/src/${{ matrix.package }}
python-version: ${{ matrix.python-version }}
use-pylint: ${{ matrix.linter == 'pylint' }}
use-pycodestyle: ${{ matrix.linter == 'pycodestyle' }}
use-flake8: ${{ matrix.linter == 'flake8' }}
use-black: false
use-mypy: ${{ matrix.linter == 'mypy' }}
use-isort: ${{ matrix.linter == 'isort' }}
use-vulture: false
use-pydocstyle: false
extra-pylint-options: ""
extra-pycodestyle-options: ""
extra-flake8-options: "--max-line-length=100"
extra-black-options: ""
extra-mypy-options: "--ignore-missing-imports"
extra-isort-options: ""
pip install .
# - uses: marian-code/python-lint-annotate@v4
# with:
# python-root-list: src/${{ matrix.package }}
# python-version: ${{ matrix.python-version }}
# use-pylint: ${{ matrix.linter == 'pylint' }}
# use-pycodestyle: ${{ matrix.linter == 'pycodestyle' }}
# use-flake8: ${{ matrix.linter == 'flake8' }}
# use-black: false
# use-mypy: ${{ matrix.linter == 'mypy' }}
# use-isort: ${{ matrix.linter == 'isort' }}
# use-vulture: false
# use-pydocstyle: false
# extra-pylint-options: ""
# extra-pycodestyle-options: ""
# extra-flake8-options: "--max-line-length=100"
# extra-black-options: ""
# extra-mypy-options: "--ignore-missing-imports"
# extra-isort-options: ""
- name: Pre-commit
uses: pre-commit/[email protected]
22 changes: 8 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]


jobs:
test:
strategy:
Expand All @@ -16,7 +15,7 @@ jobs:
os: ubuntu-24.04
- ros-distro: humble
os: ubuntu-22.04
fail-fast: false
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
# Checkout the repository
Expand Down Expand Up @@ -61,33 +60,28 @@ jobs:
echo SMC_STORM_PATH=$PWD/bin/ >> $GITHUB_OUTPUT
# Update pip
- name: Update pip
run: python -m pip install ${{ matrix.os == 'ubuntu-24.04' && '--break-system-packages' || '' }} --upgrade pip
run: python -m pip install ${{ matrix.os == 'ubuntu-24.04' && '--break-system-packages' || '' }} --upgrade pip
# workaround python 3.12 issue
- name: Install special fork of js2py
run: |
pip install --break-system-packages git+https://github.com/felixonmars/[email protected]
if: ${{ matrix.os == 'ubuntu-24.04' }}
# install the packages
- name: Install packages
run: |
source colcon_ws/install/setup.bash # TODO: remove after the release of bt_tools
pip install ${{ matrix.os == 'ubuntu-24.04' && '--break-system-packages' || '' }} as2fm_common/.[dev]
pip install ${{ matrix.os == 'ubuntu-24.04' && '--break-system-packages' || '' }} jani_generator/.[dev]
pip install ${{ matrix.os == 'ubuntu-24.04' && '--break-system-packages' || '' }} scxml_converter/.[dev]
pip install ${{ matrix.os == 'ubuntu-24.04' && '--break-system-packages' || '' }} visualizers/jani_visualizer/.[dev]
pip install ${{ matrix.os == 'ubuntu-24.04' && '--break-system-packages' || '' }} visualizers/trace_visualizer/.[dev]
run: |
pip install ${{ matrix.os == 'ubuntu-24.04' && '--break-system-packages' || '' }} .
# this solves
# E ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
- name: Downgrade numpy, networkx to match
run: |
run: |
pip install numpy==1.26.4 networkx==2.8.8
if: ${{ matrix.os == 'ubuntu-22.04' }}
# lint packages
# TODO: add linting
# TODO: add linting
# run the tests
- name: Run tests
run: |
export PATH=$PATH:${{ steps.get_smc_storm.outputs.SMC_STORM_PATH }}
# source /opt/ros/${{ matrix.ros-distro }}/setup.bash
source colcon_ws/install/setup.bash # TODO: remove after the release of bt_tools
pytest-3 -vs as2fm_common jani_generator scxml_converter visualizers/jani_visualizer visualizers/trace_visualizer
pytest-3 -vs test/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.vscode
*.egg-info/
*/build/
build/
*/*/build/
*.pyc

Expand Down
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
# black for auto-formatting
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
language_version: python3.10
# same as lint.yml
# - repo: https://github.com/pycqa/pylint
# rev: v3.3.1
# hooks:
# - id: pylint
# TODO: add pycodestyle
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.11.2
# hooks:
# - id: mypy
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ holder(s) to the [NOTICE](NOTICE) file as part of your contribution.

[DCO]: https://developercertificate.org/

[SubmittingPatches]: https://github.com/wking/signed-off-by/blob/7d71be37194df05c349157a2161c7534feaf86a4/Documentation/SubmittingPatches
[SubmittingPatches]: https://github.com/wking/signed-off-by/blob/7d71be37194df05c349157a2161c7534feaf86a4/Documentation/SubmittingPatches
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ Robert Bosch GmbH
Marco Lampacrescia <[email protected]>

Robert Bosch GmbH
Michaela Klauck <[email protected]>
Michaela Klauck <[email protected]>
33 changes: 0 additions & 33 deletions as2fm_common/pyproject.toml

This file was deleted.

51 changes: 0 additions & 51 deletions as2fm_common/test/test_utilities_smc_storm.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pip install ../scxml_converter
pip install ../jani_generator
pip install -r requirements.txt
make html
```
```
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ sphinx==7.1.2
sphinx-rtd-theme==1.3.0rc1

sphinx-autodoc2==0.5.0
myst-parser==2.0.0
myst-parser==2.0.0
2 changes: 1 addition & 1 deletion docs/source/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ a:hover {
/* Visited links */
a:visited {
color: var(--convince-orange);
}
}
4 changes: 2 additions & 2 deletions docs/source/_templates/custom-class-template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:members:
:show-inheritance:
:inherited-members:

{% block methods %}
.. automethod:: __init__

Expand All @@ -29,4 +29,4 @@
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% endblock %}
6 changes: 3 additions & 3 deletions docs/source/_templates/custom-module-template.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ fullname | escape | underline}}

.. automodule:: {{ fullname }}

{% block attributes %}
{% if attributes %}
.. rubric:: Module Attributes
Expand Down Expand Up @@ -57,10 +57,10 @@

.. autosummary::
:toctree:
:template: custom-module-template.rst
:template: custom-module-template.rst
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% endblock %}
1 change: 0 additions & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ API
as2fm_common
jani_generator
scxml_converter

Loading

0 comments on commit c8e5f6f

Please sign in to comment.