diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..256b1ec --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,48 @@ +# This workflow will install Python dependencies and run tests with PyTest using Python 3.8 +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Run tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # Checkout repository + - uses: actions/checkout@v3 + with: + submodules: 'true' + + # Set Python version + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + # Set up submodules and submodule dependencies + - name: Set up submodule and submodule dependencies + run: | + pip install -r ./modules/common/requirements.txt + + # Install project dependencies + - name: Install project dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + # Run linters and formatters + - name: Linters and formatters + run: | + black --check . + flake8 . + pylint . + + # Run unit tests with PyTest + - name: Run unit tests + run: pytest -vv diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..44e49fa --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# IDE +.idea/ +.vscode/ +# Python +__pycache__/ +venv/ +# Logging +*log* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..249daac --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "modules/common"] + path = modules/common + url = git@github.com:UWARG/common.git diff --git a/modules/__init__.py b/modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/modules/common b/modules/common new file mode 160000 index 0000000..083b67c --- /dev/null +++ b/modules/common @@ -0,0 +1 @@ +Subproject commit 083b67c507283edbaa2218c332b9d44977cbeba3 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4927a25 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,111 @@ +[tool.pylint.main] +# Add files or directories matching the regular expressions patterns to the +# ignore-list. The regex matches against paths and can be in Posix or Windows +# format. Because '\\' represents the directory delimiter on Windows systems, it +# can't be used as an escape character. +ignore-paths = [ + # From .gitignore + # IDEs + ".idea/", + ".vscode/", + + # Python + "__pycache__/", + "venv/", + + # Logging + "logs/", + + # Outside of .gitignore + # Submodules + "modules/common/", +] + +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use, and will cap the count on Windows to +# avoid hangs. +jobs = 0 + +# Minimum Python version to use for version dependent checks. Will default to the +# version used to run pylint. +py-version = "3.8" + +# Discover python modules and packages in the file system subtree. +recursive = true + +# [tool.pylint.basic] +# Good variable names which should always be accepted, separated by a comma. +good-names = [ + "i", + "j", + "k", + "ex", + "Run", + "_", + + # Return of main() + "result_main", +] + +[tool.pylint."messages control"] +# Disable the message, report, category or checker with the given id(s). You can +# either give multiple identifiers separated by comma (,) or put this option +# multiple times (only on the command line, not in the configuration file where +# it should appear only once). You can also use "--disable=all" to disable +# everything first and then re-enable specific checks. For example, if you want +# to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable = [ + "raw-checker-failed", + "bad-inline-option", + "locally-disabled", + "file-ignored", + "suppressed-message", + "useless-suppression", + "deprecated-pragma", + "use-symbolic-message-instead", + "use-implicit-booleaness-not-comparison-to-string", + "use-implicit-booleaness-not-comparison-to-zero", + # WARG + # Ignore TODOs + "fixme", + # Pylint cannot find modules + "import-error", + # Covered by Black formatter + "line-too-long", + # Pylint cannot handle 3rd party imports + "no-member", + # Some classes are simple + "too-few-public-methods", + # Function signatures + "too-many-arguments", + # Don't care + "too-many-branches", + # Line count in file + "too-many-lines", + # Don't care + "too-many-locals", + # Don't care + "too-many-statements", + # Don't care + "too-many-return-statements", +] + +[tool.pylint.similarities] +# Minimum lines number of a similarity. +# Main guard +min-similarity-lines = 10 + +[tool.pytest.ini_options] +minversion = "6.0" +# Submodules +addopts = "--ignore=modules/common/" + +[tool.black] +line-length = 100 +target-version = ["py38"] +# Excludes files or directories in addition to the defaults +# Submodules +extend-exclude = "modules/common/*" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a818894 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +# Linters and formatters are explicitly versioned +black==24.2.0 +flake8-annotations==3.0.1 +pylint==3.0.3 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..6a4f4bf --- /dev/null +++ b/setup.cfg @@ -0,0 +1,23 @@ +[flake8] +# For annotations only +select=ANN +# Disable annotations for `self` and `cls` +# https://github.com/sco1/flake8-annotations +ignore=ANN101,ANN102 +# File exclusion +extend-exclude= + # From .gitignore + # IDEs + .idea/, + .vscode/, + + # Python + __pycache__/, + venv/, + + # Logging + logs/, + + # Outside of .gitignore + # Submodules + modules/common/, diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/test_sample.py b/tests/unit/test_sample.py new file mode 100644 index 0000000..d9c00bf --- /dev/null +++ b/tests/unit/test_sample.py @@ -0,0 +1,21 @@ +""" +Sample test class, delete when tests are written +""" + + +class TestSample: + """ + This class runs a basic test + """ + + def test_add(self) -> None: + """ + Test addition + """ + input_1 = 1 + input_2 = 2 + expected = 3 + + actual = input_1 + input_2 + + assert actual == expected