Skip to content

Commit 952fad0

Browse files
committed
Added tests, modified Makefile commands, removed nbqa and more
1 parent 044e45f commit 952fad0

6 files changed

Lines changed: 49 additions & 20 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Test Code
2+
description: Run Python tests with Pytest
3+
4+
inputs:
5+
src-project-folder:
6+
description: "Directory where the project is located"
7+
required: true
8+
default: "src"
9+
10+
src-tests-folder:
11+
description: "Directory where the tests are located"
12+
required: true
13+
default: "tests"
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Run tests with Pytest
19+
shell: bash
20+
run: |
21+
if [ -d "${{ inputs.src-tests-folder }}" ] && [ -n "$(find ${{ inputs.src-tests-folder }} -name 'test_*.py')" ]; then
22+
uv run pytest ${{ inputs.src-tests-folder }}
23+
fi

.github/workflows/workflow.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ on:
88

99
env:
1010
SRC_PYTHON_VERSION: "3.11"
11+
TEST_PATH: "tests"
1112

1213
jobs:
13-
setup:
14-
name: Setup Code
14+
setup-test:
15+
name: Setup and Test
1516
runs-on: ubuntu-latest
1617

1718
steps:
@@ -25,11 +26,16 @@ jobs:
2526
uv-group: "pipeline"
2627
uv-extra: "--all-extras"
2728

29+
- name: Run Tests
30+
uses: ./.github/actions/test-code
31+
with:
32+
src-tests-folder: ${{ env.TEST_PATH }}
33+
2834
build-deploy-docs:
2935
if: github.ref == 'refs/heads/main'
3036
name: Build MkDocs Documentation
3137
runs-on: ubuntu-latest
32-
needs: setup
38+
needs: setup-test
3339

3440
permissions:
3541
contents: write

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.DEFAULT_GOAL := all
88

99
PATH_PROJECT_ROOT ?= .
10-
PATH_TEST ?= tests
10+
TEST_PATH ?= tests
1111

1212
setup:
1313
@echo "Installing dependencies..."
@@ -37,7 +37,7 @@ code-check:
3737

3838
test:
3939
@echo "Running tests..."
40-
@uv run pytest $(PATH_TEST) -v
40+
@uv run pytest $(TEST_PATH) -v
4141
@echo "✅ Tests complete."
4242

4343
doc:

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

{{ cookiecutter.project_name }}/.github/workflows/workflow.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
env:
1010
SRC_PROJECT_FOLDER: "{{ cookiecutter.project_module_name }}"
11-
SRC_PROJECT_TESTS: "{{ cookiecutter.project_test_folder_name }}"
11+
TEST_PATH: "{{ cookiecutter.project_test_folder_name }}"
1212
SRC_PYTHON_VERSION: "{{ cookiecutter.project_version_python }}"
1313

1414
jobs:
@@ -36,13 +36,13 @@ jobs:
3636
uses: ./.github/actions/test-code
3737
with:
3838
src-project-folder: ${{'{{'}} env.SRC_PROJECT_FOLDER {{'}}'}}
39-
src-tests-folder: ${{'{{'}} env.SRC_PROJECT_TESTS {{'}}'}}
39+
src-tests-folder: ${{'{{'}} env.TEST_PATH {{'}}'}}
4040

4141
- name: Security Scan
4242
uses: ./.github/actions/security
4343
with:
4444
src-project-folder: ${{'{{'}} env.SRC_PROJECT_FOLDER {{'}}'}}
45-
src-exclude: ${{'{{'}} env.SRC_PROJECT_TESTS {{'}}'}}
45+
src-exclude: ${{'{{'}} env.TEST_PATH {{'}}'}}
4646

4747
build-deploy-docs:
4848
if: github.ref == 'refs/heads/main'

{{ cookiecutter.project_name }}/Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
.DEFAULT_GOAL := all
99

10-
SRC_PROJECT_NAME ?= {{ cookiecutter.project_module_name }}
11-
SRC_PROJECT_TESTS ?= {{ cookiecutter.project_test_folder_name }}
12-
SRC_PROJECT_NOTEBOOKS_FOLDER ?= notebooks
10+
SOURCE_PATH ?= {{ cookiecutter.project_module_name }}
11+
TEST_PATH ?= {{ cookiecutter.project_test_folder_name }}
12+
NOTEBOOKS_PATH ?= notebooks
1313

1414
setup:
1515
@echo "Installing dependencies..."
@@ -27,26 +27,26 @@ clean-cache-temp-files:
2727

2828
lint:
2929
@echo "Running lint checks..."
30-
@uv run isort $(SRC_PROJECT_NAME)
31-
@uv run ruff check --fix $(SRC_PROJECT_NAME)
32-
@uv run ruff format $(SRC_PROJECT_NAME)
30+
@uv run isort $(SOURCE_PATH)
31+
@uv run ruff check --fix $(SOURCE_PATH)
32+
@uv run ruff format $(SOURCE_PATH)
3333
@echo "✅ Linting complete."
3434

3535
code-check:
3636
@echo "Running static code checks..."
37-
@uv run mypy $(SRC_PROJECT_NAME)
38-
@uv run complexipy -f $(SRC_PROJECT_NAME)
39-
@uv run bandit -r $(SRC_PROJECT_NAME) --exclude $(SRC_PROJECT_TESTS)
37+
@uv run mypy $(SOURCE_PATH)
38+
@uv run complexipy -f $(SOURCE_PATH)
39+
@uv run bandit -r $(SOURCE_PATH) --exclude $(TEST_PATH)
4040
@echo "✅ Code and security checks complete."
4141

4242
check-dead-code:
4343
@echo "Checking dead code..."
44-
@uv run deadcode $(SRC_PROJECT_NAME)
44+
@uv run deadcode $(SOURCE_PATH)
4545
@echo "✅ Dead code check complete."
4646

4747
tests:
4848
@echo "Running tests..."
49-
@uv run pytest $(SRC_PROJECT_TESTS)
49+
@uv run pytest $(TEST_PATH)
5050
@echo "✅ Tests complete."
5151

5252
doc:

0 commit comments

Comments
 (0)