Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/actions/bot-ci-failure/test_analyze_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import tempfile
import unittest
from pathlib import Path
from unittest.mock import MagicMock, mock_open, patch

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
Expand All @@ -21,6 +22,19 @@
)


class TestReusableWorkflow(unittest.TestCase):
def test_allows_escape_sequences_when_fetching_job_logs(self):
workflow = (
Path(__file__).resolve().parents[3]
/ ".github/workflows/reusable-bot-ci-failure.yml"
)
fetch_command = (
"gh api --allow-escape-sequences "
"repos/$REPO/actions/jobs/$JOB_ID/logs > job_logs.txt"
)
self.assertIn(fetch_command, workflow.read_text())


class TestGetErrorLogs(unittest.TestCase):
"""Tests for get_error_logs function."""

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-bot-ci-failure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
> failed_logs.txt
for JOB_ID in $JOB_IDS; do
echo "Processing job $JOB_ID"
if ! gh api repos/$REPO/actions/jobs/$JOB_ID/logs > job_logs.txt; then
if ! gh api --allow-escape-sequences repos/$REPO/actions/jobs/$JOB_ID/logs > job_logs.txt; then
echo "Could not fetch logs for job $JOB_ID; skipping." >> failed_logs.txt
continue
fi
Expand Down
Loading