diff --git a/.github/actions/bot-ci-failure/test_analyze_failure.py b/.github/actions/bot-ci-failure/test_analyze_failure.py index fdb728dc..540f82b8 100644 --- a/.github/actions/bot-ci-failure/test_analyze_failure.py +++ b/.github/actions/bot-ci-failure/test_analyze_failure.py @@ -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__))) @@ -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.""" diff --git a/.github/workflows/reusable-bot-ci-failure.yml b/.github/workflows/reusable-bot-ci-failure.yml index 457762c9..3f3e119b 100644 --- a/.github/workflows/reusable-bot-ci-failure.yml +++ b/.github/workflows/reusable-bot-ci-failure.yml @@ -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