Skip to content

Commit 0116d8c

Browse files
committed
Add actions for tests and code quality
1 parent 5db2893 commit 0116d8c

File tree

5 files changed

+140
-5
lines changed

5 files changed

+140
-5
lines changed

.flake8

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[flake8]
2+
max-line-length = 127
3+
extend-ignore = E203, W503, E501
4+
exclude =
5+
.git,
6+
__pycache__,
7+
.venv,
8+
venv,
9+
htmlcov,
10+
Old,
11+
setup
12+
per-file-ignores =
13+
tests/*:F401,F811

.github/workflows/code-quality.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [ main, develop, tests ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
lint-and-format:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python 3.11
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: 3.11
20+
21+
- name: Cache pip dependencies
22+
uses: actions/cache@v3
23+
with:
24+
path: ~/.cache/pip
25+
key: ${{ runner.os }}-lint-${{ hashFiles('setup/requirements*.txt') }}
26+
restore-keys: |
27+
${{ runner.os }}-lint-
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install black isort flake8 mypy
33+
pip install -r setup/requirements.txt
34+
pip install -r setup/requirements_test.txt
35+
36+
- name: Check code formatting with Black
37+
run: |
38+
black --check --diff .
39+
40+
- name: Check import sorting with isort
41+
run: |
42+
isort --check-only --diff .
43+
44+
- name: Lint with flake8
45+
run: |
46+
# Stop the build if there are Python syntax errors or undefined names
47+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
48+
# Exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
49+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

.github/workflows/tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop, tests ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.9, 3.11, 3.12]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Cache pip dependencies
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.cache/pip
28+
key: ${{ runner.os }}-pip-${{ hashFiles('setup/requirements*.txt') }}
29+
restore-keys: |
30+
${{ runner.os }}-pip-
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -r setup/requirements.txt
36+
pip install -r setup/requirements_test.txt
37+
38+
- name: Run tests with pytest
39+
run: |
40+
pytest tests/ --verbose --tb=short

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,4 @@ The last step for the bUE is to enable it to run when the device power cycles. T
101101
sudo systemctl enable bue.service
102102
```
103103

104-
If you also wish the service to start during this power cycle, just run the `systemctl start` command above.
104+
If you also wish the service to start during this power cycle, just run the `systemctl start` command above.

pyproject.toml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,44 @@ python_classes = ["Test*"]
55
python_functions = ["test_*"]
66
addopts = [
77
"--verbose",
8-
# "--tb=short",
9-
# "--cov=.",
10-
# "--cov-report=html",
11-
# "--cov-report=term-missing"
8+
"--tb=short",
9+
"--cov=.",
10+
"--cov-report=html",
11+
"--cov-report=term-missing"
1212
]
1313
filterwarnings = [
1414
"ignore::DeprecationWarning"
1515
]
16+
17+
[tool.black]
18+
line-length = 127
19+
target-version = ['py39', 'py311', 'py312']
20+
include = '\.pyi?$'
21+
extend-exclude = '''
22+
/(
23+
# directories
24+
\.eggs
25+
| \.git
26+
| \.hg
27+
| \.mypy_cache
28+
| \.tox
29+
| \.venv
30+
| venv
31+
| _build
32+
| buck-out
33+
| build
34+
| dist
35+
| htmlcov
36+
| Old
37+
)/
38+
'''
39+
40+
[tool.isort]
41+
profile = "black"
42+
line_length = 127
43+
multi_line_output = 3
44+
include_trailing_comma = true
45+
force_grid_wrap = 0
46+
use_parentheses = true
47+
ensure_newline_before_comments = true
48+
skip_glob = ["Old/*", "htmlcov/*", "setup/*"]

0 commit comments

Comments
 (0)