Skip to content

Commit

Permalink
update airflow step
Browse files Browse the repository at this point in the history
  • Loading branch information
Noel Gomez committed Dec 22, 2024
1 parent 375592c commit eb22dea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
1 change: 0 additions & 1 deletion .github/workflows/integration_airflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ jobs:
run: |
cd "$AIRFLOW__ARTIFACTS_PATH/test_dags" && \
pytest validate_dags.py \
-p custom_reporter \
--output-file "$OUTPUT_FILE"
echo $? > /tmp/exit_code
cat "$OUTPUT_FILE"
Expand Down
2 changes: 2 additions & 0 deletions orchestrate/test_dags/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# conftest.py
from custom_reporter import *
22 changes: 12 additions & 10 deletions orchestrate/test_dags/custom_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ def __init__(self, config: Config):
self.config = config
self.stats = {}
self.warnings = []
self._tw = config.get_terminal_writer()

def pytest_runtest_logreport(self, report: TestReport):
if report.when == 'call':
self.stats.setdefault(report.outcome, []).append(report)

# Capture warnings
if hasattr(report, 'warnings'):
self.warnings.extend(report.warnings)
def pytest_warning_recorded(self, warning_message):
self.warnings.append(warning_message)

def pytest_sessionfinish(self):
# Create the markdown output
with open(self.config.option.output_file, 'w') as f:
f.write("⚠️ **Test Warnings Detected:**\n\n")
output_file = self.config.getoption('output_file')
if not output_file:
return

with open(output_file, 'w') as f:
if self.warnings:
f.write("⚠️ **Test Warnings Detected:**\n\n")

f.write("```\n")

# Write test summary
Expand All @@ -42,13 +45,12 @@ def pytest_sessionfinish(self):
if self.warnings:
f.write("\nWarnings:\n")
for warning in self.warnings:
f.write(f"- {str(warning.message)}\n")
f.write(f"- {str(warning.message)} \n at {warning.filename}:{warning.lineno}\n")

f.write("```\n")

def pytest_configure(config):
# Get output file from command line option
output_file = getattr(config.option, 'output_file', None)
output_file = config.getoption('output_file', None)
if output_file:
reporter = CustomReporter(config)
config.pluginmanager.register(reporter)
Expand Down

0 comments on commit eb22dea

Please sign in to comment.