Skip to content

Commit d7b6141

Browse files
Update logging;
1 parent 9da80f1 commit d7b6141

File tree

1 file changed

+43
-30
lines changed

1 file changed

+43
-30
lines changed

.github/workflows/test-pytest.yml

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,23 @@ jobs:
9595

9696
- name: Install dependencies
9797
run: |
98-
python -m pip install --upgrade pip
99-
pip install pytest pytest-json-report pytest-asyncio
98+
python -m pip install --upgrade pip --quiet
99+
pip install pytest pytest-json-report pytest-asyncio --quiet
100100
if [ -f requirements.txt ]; then
101-
pip install -r requirements.txt
101+
pip install -r requirements.txt --quiet
102102
fi
103103
104104
- name: Check for test collection errors
105105
id: check-collection
106106
run: |
107-
# Create verbose debug file for artifact
108-
exec 3>&1 4>&2
109-
exec 1> >(tee -a debug_collection.log) 2>&1
110-
111107
echo "Running pytest collection check..."
108+
109+
# Redirect ALL output to files, including subprocess stderr
112110
python -m pytest --collect-only -v > collection_output.txt 2>&1 || true
113111
114-
# Restore stdout/stderr for GitHub Actions
115-
exec 1>&3 2>&4
112+
# Save to debug file for artifact
113+
echo "=== COLLECTION CHECK OUTPUT ===" >> debug_collection.log
114+
cat collection_output.txt >> debug_collection.log
116115
117116
# Set default values
118117
HAS_COLLECTION_ERRORS="false"
@@ -183,17 +182,24 @@ jobs:
183182
echo "has_errors=false" >> $GITHUB_OUTPUT
184183
fi
185184
186-
# Save full collection output to debug file for artifact (full details preserved)
187-
echo "=== FULL COLLECTION OUTPUT ===" >> debug_collection.log
188-
cat collection_output.txt >> debug_collection.log
189-
190185
- name: Run tests on PR Branch
191186
if: steps.check-collection.outputs.has_collection_errors != 'true'
187+
env:
188+
PYTHONUNBUFFERED: "1"
189+
PYTHONIOENCODING: "utf-8"
190+
PYTHONWARNINGS: "ignore"
191+
MIGRATION_MANAGER_LOG_LEVEL: "ERROR"
192+
MIGRATION_MANAGER_QUIET: "true"
193+
SQLALCHEMY_WARN_20: "false"
194+
SQLALCHEMY_SILENCE_UBER_WARNING: "1"
192195
run: |
193196
echo "Running tests on PR branch..."
194197
195-
# Run pytest with minimal console output, redirect everything to files
196-
python -m pytest --json-report --json-report-file=pr_results.json > test_run_output.log 2>&1 || true
198+
# Suppress Python logging and redirect all output
199+
python -c "import logging; logging.getLogger().setLevel(logging.ERROR); logging.getLogger('migration_manager').setLevel(logging.ERROR)" 2>/dev/null || true
200+
201+
# Run pytest with comprehensive output suppression
202+
python -m pytest --json-report --json-report-file=pr_results.json --tb=no -q --disable-warnings --log-level=ERROR > test_run_output.log 2>&1 || true
197203
198204
# Save output to debug file for artifact
199205
echo "=== PYTEST RUN OUTPUT ===" >> debug_test_run.log
@@ -359,24 +365,23 @@ jobs:
359365

360366
- name: Install dependencies
361367
run: |
362-
python -m pip install --upgrade pip
363-
pip install pytest pytest-json-report pytest-asyncio
368+
python -m pip install --upgrade pip --quiet
369+
pip install pytest pytest-json-report pytest-asyncio --quiet
364370
if [ -f requirements.txt ]; then
365-
pip install -r requirements.txt
371+
pip install -r requirements.txt --quiet
366372
fi
367373
368374
- name: Check for test collection errors
369375
id: check-collection
370376
run: |
371-
# Create verbose debug file for artifact
372-
exec 3>&1 4>&2
373-
exec 1> >(tee -a debug_target_collection.log) 2>&1
374-
375377
echo "Running pytest collection check..."
378+
379+
# Redirect ALL output to files, including subprocess stderr
376380
python -m pytest --collect-only -v > collection_output.txt 2>&1 || true
377381
378-
# Restore stdout/stderr for GitHub Actions
379-
exec 1>&3 2>&4
382+
# Save to debug file for artifact
383+
echo "=== COLLECTION CHECK OUTPUT ===" >> debug_target_collection.log
384+
cat collection_output.txt >> debug_target_collection.log
380385
381386
# Set default values
382387
HAS_COLLECTION_ERRORS="false"
@@ -447,17 +452,24 @@ jobs:
447452
echo "has_errors=false" >> $GITHUB_OUTPUT
448453
fi
449454
450-
# Save full collection output to debug file for artifact (full details preserved)
451-
echo "=== FULL COLLECTION OUTPUT ===" >> debug_target_collection.log
452-
cat collection_output.txt >> debug_target_collection.log
453-
454455
- name: Run tests on target branch
455456
if: steps.check-collection.outputs.has_collection_errors != 'true'
457+
env:
458+
PYTHONUNBUFFERED: "1"
459+
PYTHONIOENCODING: "utf-8"
460+
PYTHONWARNINGS: "ignore"
461+
MIGRATION_MANAGER_LOG_LEVEL: "ERROR"
462+
MIGRATION_MANAGER_QUIET: "true"
463+
SQLALCHEMY_WARN_20: "false"
464+
SQLALCHEMY_SILENCE_UBER_WARNING: "1"
456465
run: |
457466
echo "Running tests on target branch..."
458467
459-
# Run pytest with minimal console output, redirect everything to files
460-
python -m pytest --json-report --json-report-file=target_results.json > target_test_run_output.log 2>&1 || true
468+
# Suppress Python logging and redirect all output
469+
python -c "import logging; logging.getLogger().setLevel(logging.ERROR); logging.getLogger('migration_manager').setLevel(logging.ERROR)" 2>/dev/null || true
470+
471+
# Run pytest with comprehensive output suppression
472+
python -m pytest --json-report --json-report-file=target_results.json --tb=no -q --disable-warnings --log-level=ERROR > target_test_run_output.log 2>&1 || true
461473
462474
# Save output to debug file for artifact
463475
echo "=== PYTEST RUN OUTPUT ===" >> debug_target_test_run.log
@@ -552,6 +564,7 @@ jobs:
552564
path: |
553565
target_test_data.json
554566
debug_target_*.log
567+
target_test_run_output.log
555568
collection_output.txt
556569
error_details.txt
557570
target_results.json

0 commit comments

Comments
 (0)