Skip to content

Commit e4c6367

Browse files
Merge pull request #6412 from ggiguash/analyze-ci-tmp-dir
USHIFT-6760: Update analyze-ci work directory to have a date suffix
2 parents eee75fb + c7c1812 commit e4c6367

File tree

6 files changed

+108
-63
lines changed

6 files changed

+108
-63
lines changed

.claude/commands/analyze-ci-create-bugs.md

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ allowed-tools: Bash, Read, Write, Glob, Grep, Agent, mcp__jira__jira_search, mcp
1515
## Description
1616
Reads individual job analysis reports produced by `analyze-ci-for-release` or `analyze-ci-for-pull-requests` and creates JIRA bugs in USHIFT for legitimate test failures. Operates in **dry-run mode by default** - it shows what bugs would be created without actually creating them. Use `--create` to perform actual issue creation.
1717

18-
This command does NOT re-analyze CI jobs. It consumes existing job analysis files from `/tmp/analyze-ci-claude-workdir/`.
18+
This command does NOT re-analyze CI jobs. It consumes existing job analysis files from `${WORKDIR}/`.
1919

2020
## Arguments
2121
- `$ARGUMENTS` (required): Source identifier, optionally followed by `--create`
@@ -27,7 +27,7 @@ This command does NOT re-analyze CI jobs. It consumes existing job analysis file
2727

2828
## Prerequisites
2929

30-
- Job analysis files must already exist in `/tmp/analyze-ci-claude-workdir/`:
30+
- Job analysis files must already exist in `${WORKDIR}/`:
3131
- For releases: `analyze-ci-release-<release>-job-*.txt` (produced by `/analyze-ci-for-release`)
3232
- For PRs: `analyze-ci-prs-job-*-pr<number>-*.txt` (produced by `/analyze-ci-for-pull-requests`)
3333
- Each job file must contain a `--- STRUCTURED SUMMARY ---` block (see below)
@@ -54,28 +54,35 @@ FINISHED: <job finish date in YYYY-MM-DD format>
5454

5555
If a job file lacks this block, it is skipped with a warning.
5656

57+
## Work Directory
58+
59+
Set once at the start and reference throughout:
60+
```bash
61+
WORKDIR=/tmp/analyze-ci-claude-workdir.$(date +%y%m%d)
62+
```
63+
5764
## Implementation Steps
5865

5966
### Step 1: Parse Arguments and Locate Job Files
6067

6168
**Actions**:
6269
1. Parse `$ARGUMENTS` to extract `<source>` and detect `--create` flag
6370
2. Determine mode: if `--create` is present, set `MODE=create`; otherwise `MODE=dry-run`
64-
3. Run `mkdir -p /tmp/analyze-ci-claude-workdir` using the `Bash` tool
71+
3. Run `WORKDIR=/tmp/analyze-ci-claude-workdir.$(date +%y%m%d) && mkdir -p ${WORKDIR}` using the `Bash` tool
6572
4. Determine source type and locate job files:
6673

6774
**a) Release version** (e.g., `4.22`, `main`, `4.19`):
68-
- Glob for: `/tmp/analyze-ci-claude-workdir/analyze-ci-release-<release>-job-*.txt`
75+
- Glob for: `${WORKDIR}/analyze-ci-release-<release>-job-*.txt`
6976
- Set `SOURCE_TYPE=release`, `SOURCE_LABEL="release <release>"`
7077

7178
**b) PR number** (e.g., `pr-6396`, `pr6396`):
7279
- Extract the numeric PR number (strip `pr-` or `pr` prefix)
73-
- Glob for: `/tmp/analyze-ci-claude-workdir/analyze-ci-prs-job-*-pr<number>-*.txt`
80+
- Glob for: `${WORKDIR}/analyze-ci-prs-job-*-pr<number>-*.txt`
7481
- Set `SOURCE_TYPE=pr`, `SOURCE_LABEL="PR #<number>"`
7582

7683
**c) Rebase PR shorthand** (e.g., `rebase-release-4.22`):
7784
- Extract the release version from the shorthand (e.g., `4.22`)
78-
- Glob for all PR job files: `/tmp/analyze-ci-claude-workdir/analyze-ci-prs-job-*.txt`
85+
- Glob for all PR job files: `${WORKDIR}/analyze-ci-prs-job-*.txt`
7986
- Read each file's STRUCTURED SUMMARY and find files where JOB_NAME contains the release version (e.g., `release-4.22` or `main`) OR where the JOB_URL contains the release branch
8087
- Alternatively, check the PR summary file (`analyze-ci-prs-summary.*.txt`) to find the PR number for the given rebase release
8188
- Set `SOURCE_TYPE=pr`, `SOURCE_LABEL="rebase PR for <release> (PR #<number>)"`
@@ -152,24 +159,26 @@ If a job file lacks this block, it is skipped with a warning.
152159

153160
For each bug candidate, run ALL of the following searches. Each search is MANDATORY — do not skip any.
154161

155-
**Search A — Keyword search**:
162+
**Search A — Keyword search (multiple focused queries)**:
156163
1. Extract 2-4 distinctive keywords from the error signature (avoid generic words like "error", "failed", "test")
157-
2. Run:
164+
2. Run **2-3 separate searches in parallel**, each using 1-2 distinctive keywords. Do NOT put all keywords into a single `text ~` query — Jira requires all terms to match, so queries with 3+ keywords are fragile and miss issues that use slightly different wording. Instead, pick the most distinctive terms (tool names, hyphenated identifiers, error codes) and search for them independently.
158165
```python
159-
mcp__jira__jira_search(
160-
jql='((project = OCPBUGS AND component = MicroShift) OR project = USHIFT) AND text ~ "<keywords>" AND status not in (Closed, Verified) ORDER BY created DESC',
161-
limit=5
162-
)
166+
# Example for error signature: "TLS Scanner image pull failure (ErrImagePull registry.ci.openshift.org/ocp/4.22:tls-scanner-tool on arm64)"
167+
# Search A1: most distinctive identifier
168+
mcp__jira__jira_search(jql='... AND issuetype = Bug AND text ~ "tls-scanner" ...', limit=5)
169+
# Search A2: different distinctive term
170+
mcp__jira__jira_search(jql='... AND issuetype = Bug AND text ~ "tls-scanner-tool" ...', limit=5)
163171
```
172+
3. Merge and deduplicate results from all A-series queries before proceeding
164173

165174
**Search B — Test case ID search (MANDATORY when IDs are present)**:
166175
Extract ALL numeric IDs from the error signature that could be test case references (typically 4-6 digit numbers like `68256`). For EACH numeric ID found, run TWO separate searches:
167176
```text
168177
# Search B1: bare number
169-
jql: ... AND text ~ "68256" AND status not in (Closed, Verified) ...
178+
jql: ... AND issuetype = Bug AND text ~ "68256" AND status not in (Closed, Verified) ...
170179
171180
# Search B2: OCP-prefixed form (OpenShift Polarion convention)
172-
jql: ... AND text ~ "OCP-68256" AND status not in (Closed, Verified) ...
181+
jql: ... AND issuetype = Bug AND text ~ "OCP-68256" AND status not in (Closed, Verified) ...
173182
```
174183
**Why both forms are required**: Jira's text indexer treats `OCP-68256` as a single token, so `text ~ "68256"` will NOT match issues containing `OCP-68256`, and vice versa. Skipping either form WILL cause missed duplicates.
175184

@@ -181,7 +190,7 @@ jql: ... AND text ~ "OCP-68256" AND status not in (Closed, Verified) ...
181190
After completing searches A and B, run an additional keyword search against closed/verified issues to detect potential regressions:
182191
```python
183192
mcp__jira__jira_search(
184-
jql='((project = OCPBUGS AND component = MicroShift) OR project = USHIFT) AND text ~ "<keywords>" AND status in (Closed, Verified) ORDER BY updated DESC',
193+
jql='((project = OCPBUGS AND component = MicroShift) OR project = USHIFT) AND issuetype = Bug AND text ~ "<keywords>" AND status in (Closed, Verified) ORDER BY updated DESC',
185194
limit=5
186195
)
187196
```
@@ -381,7 +390,7 @@ For each candidate where user chose "reopen":
381390
### Step 8: Generate Results Report
382391

383392
**Actions**:
384-
1. Save report to `/tmp/analyze-ci-claude-workdir/analyze-ci-create-bugs-<source>.<timestamp>.txt`
393+
1. Save report to `${WORKDIR}/analyze-ci-create-bugs-<source>.<timestamp>.txt`
385394
2. Display summary to user:
386395

387396
**Dry-run report format**:
@@ -418,7 +427,7 @@ CANDIDATES
418427
To create these bugs, run:
419428
/analyze-ci-create-bugs <source> --create
420429
421-
Report saved: /tmp/analyze-ci-claude-workdir/analyze-ci-create-bugs-<source>.<timestamp>.txt
430+
Report saved: ${WORKDIR}/analyze-ci-create-bugs-<source>.<timestamp>.txt
422431
═══════════════════════════════════════════════════════════════
423432
```
424433

@@ -456,7 +465,7 @@ SUMMARY
456465
Reopened: N
457466
Failed: N
458467
459-
Report saved: /tmp/analyze-ci-claude-workdir/analyze-ci-create-bugs-<source>.<timestamp>.txt
468+
Report saved: ${WORKDIR}/analyze-ci-create-bugs-<source>.<timestamp>.txt
460469
═══════════════════════════════════════════════════════════════
461470
```
462471

@@ -491,7 +500,7 @@ Resolves the rebase PR for release 4.22, then interactively creates bugs.
491500
/analyze-ci-create-bugs 4.19
492501
```
493502
```text
494-
Error: No job analysis files found at /tmp/analyze-ci-claude-workdir/analyze-ci-release-4.19-job-*.txt
503+
Error: No job analysis files found at ${WORKDIR}/analyze-ci-release-4.19-job-*.txt
495504
496505
Run the analysis first:
497506
/analyze-ci-for-release 4.19
@@ -502,15 +511,15 @@ Run the analysis first:
502511
/analyze-ci-create-bugs pr-9999
503512
```
504513
```text
505-
Error: No job analysis files found at /tmp/analyze-ci-claude-workdir/analyze-ci-prs-job-*-pr9999-*.txt
514+
Error: No job analysis files found at ${WORKDIR}/analyze-ci-prs-job-*-pr9999-*.txt
506515
507516
Run the analysis first:
508517
/analyze-ci-for-pull-requests
509518
```
510519

511520
## Notes
512521

513-
- This command does NOT run CI analysis — it only consumes existing analysis files from `/tmp/analyze-ci-claude-workdir`
522+
- This command does NOT run CI analysis — it only consumes existing analysis files from `${WORKDIR}`
514523
- Supports two file naming patterns:
515524
- Release jobs: `analyze-ci-release-<release>-job-*.txt` (from `/analyze-ci-for-release`)
516525
- PR jobs: `analyze-ci-prs-job-*-pr<number>-*.txt` (from `/analyze-ci-for-pull-requests`)

.claude/commands/analyze-ci-for-prow-job.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Analyze CI for a Prow Job
33
argument-hint: <prow-job-url>
4-
description: Analyze a MicroShift Prow CI Test Job execution
4+
description: Download Prow job artifacts, identify root cause of failure, and produce a structured error report
55
allowed-tools: Skill, Bash, Read, Write, Glob, Grep, Agent
66
---
77

@@ -75,12 +75,19 @@ ${TMP}/artifacts/${TEST_NAME}/openshift-microshift-infra-sos-aws/artifacts/sosre
7575
```
7676
Where `${TEST_NAME}` is the test name directory (e.g., `e2e-aws-tests`, `e2e-aws-ovn-ocp-conformance-serial`). Use `find ${TMP}/artifacts -name 'sosreport-*.tar.xz'` to locate it.
7777

78+
## Work Directory
79+
80+
Set once at the start and reference throughout:
81+
```bash
82+
WORKDIR=/tmp/analyze-ci-claude-workdir.$(date +%y%m%d)
83+
mkdir -p ${WORKDIR}
84+
```
85+
7886
## Common Commands
7987

8088
Create a temporary working directory to store artifacts for the current job:
8189
```bash
82-
mkdir -p /tmp/analyze-ci-claude-workdir
83-
mktemp -d /tmp/analyze-ci-claude-workdir/openshift-ci-analysis-XXXX
90+
mktemp -d ${WORKDIR}/openshift-ci-analysis-XXXX
8491
```
8592

8693
Fetch the high level summary of the failed prow job:

.claude/commands/analyze-ci-for-pull-requests.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@ This command orchestrates the analysis workflow by:
2020
1. Fetching the list of open PRs and their failed jobs using `.claude/scripts/microshift-prow-jobs-for-pull-requests.sh --mode detail`
2121
2. Filtering to only PRs that have at least one failed job
2222
3. Analyzing each failed job individually using the `/analyze-ci-for-prow-job` command
23-
4. Aggregating results into a summary report saved to `/tmp/analyze-ci-claude-workdir`
23+
4. Aggregating results into a summary report saved to `${WORKDIR}`
2424

2525
## Arguments
2626
- `--rebase` (optional): Only analyze rebase PRs (titles containing `NO-ISSUE: rebase-release-`)
2727

28+
## Work Directory
29+
30+
Set once at the start and reference throughout:
31+
```bash
32+
WORKDIR=/tmp/analyze-ci-claude-workdir.$(date +%y%m%d)
33+
```
34+
2835
## Implementation Steps
2936

3037
### Step 1: Fetch Open PRs and Their Job Results
@@ -76,13 +83,13 @@ Each job MUST be analyzed by launching a **separate Agent** (using the `Agent` t
7683
3. The file MUST contain the full report including the `--- STRUCTURED SUMMARY ---` block
7784

7885
**Actions**:
79-
1. Run `mkdir -p /tmp/analyze-ci-claude-workdir` using the `Bash` tool
86+
1. Run `WORKDIR=/tmp/analyze-ci-claude-workdir.$(date +%y%m%d) && mkdir -p ${WORKDIR}` using the `Bash` tool
8087
2. For each failed job URL, launch a separate **Agent** with this exact prompt template:
8188
```
8289
Agent: subagent_type=general_purpose, prompt="Analyze this Prow job and save the report:
8390
1. Run /analyze-ci-for-prow-job <JOB_URL>
8491
2. After the analysis completes, save the FULL report output (including the --- STRUCTURED SUMMARY --- block) to:
85-
/tmp/analyze-ci-claude-workdir/analyze-ci-prs-job-<N>-pr<PR>-<JOB_NAME_SUFFIX>.txt
92+
${WORKDIR}/analyze-ci-prs-job-<N>-pr<PR>-<JOB_NAME_SUFFIX>.txt
8693
Use the Write tool to save the file. The file must contain the complete analysis report."
8794
```
8895
Replace `<JOB_URL>`, `<N>` (1-based job index), `<PR>` (PR number), and `<JOB_NAME_SUFFIX>` (last segment of job name) with actual values.
@@ -108,7 +115,7 @@ For each job analysis, extract:
108115

109116
**File Storage**:
110117
All per-job report files MUST be saved at this exact path:
111-
- `/tmp/analyze-ci-claude-workdir/analyze-ci-prs-job-<N>-pr<PR>-<job-name-suffix>.txt`
118+
- `${WORKDIR}/analyze-ci-prs-job-<N>-pr<PR>-<job-name-suffix>.txt`
112119

113120
Where:
114121
- `<N>` is the 1-based job index
@@ -117,7 +124,7 @@ Where:
117124

118125
**Verification**: After all agents complete, verify that per-job files exist:
119126
```bash
120-
ls /tmp/analyze-ci-claude-workdir/analyze-ci-prs-job-*.txt
127+
ls ${WORKDIR}/analyze-ci-prs-job-*.txt
121128
```
122129
If any files are missing, note the gap in the summary report but do NOT re-run the analysis.
123130

@@ -127,7 +134,7 @@ If any files are missing, note the gap in the summary report but do NOT re-run t
127134

128135
**Actions**:
129136
1. Collect results from all parallel job analyses
130-
- Read each per-job file from `/tmp/analyze-ci-claude-workdir`
137+
- Read each per-job file from `${WORKDIR}`
131138
- Extract the `--- STRUCTURED SUMMARY ---` block from each file for pattern detection (including the `FINISHED` field for job date tracking)
132139
- Extract key findings from each analysis
133140

@@ -145,7 +152,7 @@ If any files are missing, note the gap in the summary report but do NOT re-run t
145152
**Actions**:
146153
1. Aggregate all job analysis results from parallel execution
147154
2. Identify common patterns and group by PR and failure type
148-
3. Generate summary report and save to `/tmp/analyze-ci-claude-workdir/analyze-ci-prs-summary.<timestamp>.txt`
155+
3. Generate summary report and save to `${WORKDIR}/analyze-ci-prs-summary.<timestamp>.txt`
149156
4. Display the summary to the user
150157

151158
**Important**: Each failed job MUST include the finish date in `[YYYY-MM-DD]` format (from the per-job `FINISHED` field) after the job name. This ensures the HTML report generator can extract dates without reading per-job files.
@@ -162,7 +169,7 @@ OVERVIEW
162169
PRs with Failures: 2
163170
Total Failed Jobs: 9
164171
Analysis Date: 2026-03-15
165-
Report: /tmp/analyze-ci-claude-workdir/analyze-ci-prs-summary.20260315-143022.txt
172+
Report: ${WORKDIR}/analyze-ci-prs-summary.20260315-143022.txt
166173
167174
PER-PR BREAKDOWN
168175
@@ -199,7 +206,7 @@ COMMON PATTERNS (across PRs)
199206
200207
═══════════════════════════════════════════════════════════════
201208
202-
Individual job reports: /tmp/analyze-ci-claude-workdir/analyze-ci-prs-job-*.txt
209+
Individual job reports: ${WORKDIR}/analyze-ci-prs-job-*.txt
203210
```
204211

205212
## Examples
@@ -231,7 +238,7 @@ Individual job reports: /tmp/analyze-ci-claude-workdir/analyze-ci-prs-job-*.txt
231238
- **Execution Time**: Depends on number of failed jobs; parallel execution helps significantly
232239
- **Network Usage**: Each job analysis fetches logs from GCS
233240
- **Parallelization**: All job analyses run in parallel for maximum efficiency
234-
- **File Storage**: All intermediate and report files are stored in `/tmp/analyze-ci-claude-workdir` directory
241+
- **File Storage**: All intermediate and report files are stored in `${WORKDIR}` directory
235242

236243
## Prerequisites
237244

@@ -272,7 +279,7 @@ Please ensure you're in the microshift project directory.
272279

273280
- This skill focuses on **presubmit** PR jobs (not periodic/postsubmit)
274281
- Analysis is read-only - no modifications to CI data or PRs
275-
- Results are saved in files in /tmp/analyze-ci-claude-workdir directory with a timestamp
282+
- Results are saved in files in ${WORKDIR} directory with a timestamp
276283
- Provide links to the jobs in the summary
277284
- Only present a concise analysis summary for each job
278285
- PRs with no Prow jobs (e.g., drafts without triggered tests) are skipped

.claude/commands/analyze-ci-for-release-manager.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,23 @@ Accepts a comma-separated list of MicroShift release versions, runs the `analyze
1818
## Arguments
1919
- `$ARGUMENTS` (required): Comma-separated list of release versions (e.g., `4.19,4.20,4.21,4.22`)
2020

21+
## Work Directory
22+
23+
Set once at the start and reference throughout:
24+
```bash
25+
WORKDIR=/tmp/analyze-ci-claude-workdir.$(date +%y%m%d)
26+
```
27+
2128
## Implementation Steps
2229

2330
### Step 1: Parse and Validate Arguments
2431

2532
**Actions**:
26-
1. Split `$ARGUMENTS` by comma to get a list of release versions
27-
2. Trim whitespace from each version
28-
3. Validate that at least one release version is provided
29-
4. If no arguments provided, show usage and stop
33+
1. Run `WORKDIR=/tmp/analyze-ci-claude-workdir.$(date +%y%m%d) && mkdir -p ${WORKDIR}` using the `Bash` tool
34+
2. Split `$ARGUMENTS` by comma to get a list of release versions
35+
3. Trim whitespace from each version
36+
4. Validate that at least one release version is provided
37+
5. If no arguments provided, show usage and stop
3038

3139
**Error Handling**:
3240
- If `$ARGUMENTS` is empty, display: "Usage: /analyze-ci-for-release-manager <release1,release2,...>" and stop
@@ -39,7 +47,7 @@ Accepts a comma-separated list of MicroShift release versions, runs the `analyze
3947
Agent: subagent_type=general_purpose, prompt="Run /analyze-ci-for-release <version>"
4048
```
4149
2. Launch all releases **in parallel** as separate agents — do NOT wait for one to finish before starting the next
42-
3. After each agent completes, note the summary report file path it produced (typically `/tmp/analyze-ci-claude-workdir/analyze-ci-release-<version>-summary.*.txt`)
50+
3. After each agent completes, note the summary report file path it produced (typically `${WORKDIR}/analyze-ci-release-<version>-summary.*.txt`)
4351
4. Wait until all the parallel agents are complete
4452
5. Track which releases succeeded and which failed
4553

@@ -56,7 +64,7 @@ Analyzing release X/Y: <version>
5664
Agent: subagent_type=general_purpose, prompt="Run /analyze-ci-for-pull-requests --rebase"
5765
```
5866
2. This agent can be launched in parallel with the release agents in Step 2
59-
3. After the agent completes, note the summary report file path (typically `/tmp/analyze-ci-claude-workdir/analyze-ci-prs-summary.*.txt`)
67+
3. After the agent completes, note the summary report file path (typically `${WORKDIR}/analyze-ci-prs-summary.*.txt`)
6068
4. If no rebase PRs are found, note "No open rebase PRs" for the report
6169

6270
**Progress Reporting**:
@@ -93,7 +101,7 @@ Summary:
93101
Pull Requests:
94102
2 rebase PRs with 5 total failed jobs
95103
96-
HTML report generated: /tmp/analyze-ci-claude-workdir/microshift-ci-release-manager-20260315-143022.html
104+
HTML report generated: ${WORKDIR}/microshift-ci-release-manager-20260315-143022.html
97105
```
98106

99107
## Examples
@@ -136,7 +144,7 @@ HTML report generated: /tmp/analyze-ci-claude-workdir/microshift-ci-release-mana
136144
- All agents (releases + PR analysis) are launched in parallel for maximum efficiency
137145
- HTML generation is delegated to `analyze-ci-generate-html-report` running as a separate agent — it only reads summary files (not per-job files), keeping context usage minimal
138146
- The HTML report is self-contained (no external CSS/JS dependencies)
139-
- All intermediate files from `analyze-ci-for-release` and `analyze-ci-for-pull-requests` remain available in `/tmp/analyze-ci-claude-workdir`
147+
- All intermediate files from `analyze-ci-for-release` and `analyze-ci-for-pull-requests` remain available in `${WORKDIR}`
140148
- The HTML file can be opened in any browser for convenient examination
141149
- If a release analysis fails, it is noted in the report but does not block other releases
142150
- If no rebase PRs are open, the Pull Requests tab shows "No open rebase pull requests found"

0 commit comments

Comments
 (0)