Skip to content

Commit

Permalink
initial repository setup (#1)
Browse files Browse the repository at this point in the history
* initial repository setup

* removed pytorch dependencies

* updated submodule updating

* added init to modules

* initialized test structure

* added basic test

* black formatting changes

* function return type annotations

* pylint fixes
  • Loading branch information
TongguangZhang authored May 27, 2024
1 parent b0cd63e commit 7d47010
Show file tree
Hide file tree
Showing 12 changed files with 219 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# IDE
.idea/
.vscode/
# Python
__pycache__/
venv/
# Logging
*log*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "modules/common"]
path = modules/common
url = [email protected]:UWARG/common.git
Empty file added modules/__init__.py
Empty file.
1 change: 1 addition & 0 deletions modules/common
Submodule common added at 083b67
111 changes: 111 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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/*"
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Linters and formatters are explicitly versioned
black==24.2.0
flake8-annotations==3.0.1
pylint==3.0.3
23 changes: 23 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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/,
Empty file added tests/__init__.py
Empty file.
Empty file added tests/integration/__init__.py
Empty file.
Empty file added tests/unit/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions tests/unit/test_sample.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7d47010

Please sign in to comment.