You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance workflow error script with options and defaults
This commit updates the `print_workflow_run_errors.py` script:
- Workflow name and branch are now optional arguments:
- `--workflow` (or `--workflow-name`) defaults to "integration_test.yml".
- `--branch` defaults to the current Git branch.
- Changed default log lines printed from 500 to 100 (`--log-lines`).
- Added `--all-failed-steps` flag:
- If false (default), only logs for the first failed step in a job are printed.
- If true, logs for all failed steps in a job are printed.
These changes provide more flexibility and sensible defaults for common use cases.
description="Fetch and display failed steps and their logs from a GitHub workflow run.",
94
109
formatter_class=argparse.RawTextHelpFormatter
95
110
)
96
111
parser.add_argument(
97
-
"workflow_name",
112
+
"--workflow", "--workflow-name",
98
113
type=str,
99
-
help="Name of the workflow file (e.g., 'main.yml' or 'build-test.yml')."
114
+
default="integration_test.yml",
115
+
help="Name of the workflow file (e.g., 'main.yml' or 'build-test.yml'). Default: 'integration_test.yml'."
100
116
)
101
117
parser.add_argument(
102
-
"branch",
118
+
"--branch",
103
119
type=str,
104
-
help="GitHub branch name to check for the workflow run."
120
+
default=current_branch,
121
+
help=f"GitHub branch name to check for the workflow run. {'Default: '+current_branchifcurrent_branchelse'Required if not determinable from current git branch.'}"
sys.stderr.write(f"Error: Could not set repository info to {final_owner}/{final_repo}. Ensure owner/repo are correct.{error_suffix}\n")
211
234
sys.exit(1)
212
235
213
-
sys.stderr.write(f"Processing workflow '{args.workflow_name}' on branch '{args.branch}' for repo {OWNER}/{REPO}\n")
236
+
ifnotargs.branch:
237
+
sys.stderr.write(f"Error: Branch name is required. Please specify --branch or ensure it can be detected from your current git repository.{error_suffix}\n")
238
+
sys.exit(1)
239
+
240
+
sys.stderr.write(f"Processing workflow '{args.workflow}' on branch '{args.branch}' for repo {OWNER}/{REPO}\n")
0 commit comments