|
96 | 96 | run: |
|
97 | 97 | echo "Running pytest discovery..."
|
98 | 98 | python -m pytest --collect-only -v
|
99 |
| - echo "Running tests..." |
100 |
| - python -m pytest ./tests -v |
101 |
| - python -m pytest --doctest-modules ./patterns -v || true |
| 99 | + |
| 100 | + # First run any test files that correspond to changed files |
| 101 | + echo "Running tests for changed files..." |
| 102 | + changed_files="${{ needs.check_changes.outputs.files }}" |
| 103 | + |
| 104 | + # Extract module paths from changed files |
| 105 | + modules=() |
| 106 | + for file in $changed_files; do |
| 107 | + # Convert file path to module path (remove .py and replace / with .) |
| 108 | + if [[ $file == patterns/* ]]; then |
| 109 | + module_path=${file%.py} |
| 110 | + module_path=${module_path//\//.} |
| 111 | + modules+=("$module_path") |
| 112 | + fi |
| 113 | + done |
| 114 | + |
| 115 | + # Run tests for each module |
| 116 | + for module in "${modules[@]}"; do |
| 117 | + echo "Testing module: $module" |
| 118 | + python -m pytest -xvs tests/ -k "$module" || true |
| 119 | + done |
| 120 | + |
| 121 | + # Then run doctests on the changed files |
| 122 | + echo "Running doctests for changed files..." |
| 123 | + for file in $changed_files; do |
| 124 | + if [[ $file == *.py ]]; then |
| 125 | + echo "Running doctest for $file" |
| 126 | + python -m pytest --doctest-modules -v $file || true |
| 127 | + fi |
| 128 | + done |
102 | 129 |
|
103 | 130 | # Check Python version compatibility
|
104 | 131 | - name: Check Python version compatibility
|
|
0 commit comments