Skip to content

Commit adbc8db

Browse files
Fix(CI): Remove pip caching from issue_explainer workflow
1 parent 29933ec commit adbc8db

1 file changed

Lines changed: 18 additions & 57 deletions

File tree

.github/workflows/issue_explainer.yml

Lines changed: 18 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,106 @@
11
# .github/workflows/issue_explainer.yml
22
name: Codex CLI Explain Issue
33

4-
# Trigger when an issue is labeled with 'ask-cstudio-explain'
54
on:
65
issues:
76
types: [labeled]
87

9-
# Permissions needed by the workflow
108
permissions:
11-
issues: write # Allows writing comments to issues
12-
contents: read # Allows checking out the repository code (needed for setup-python cache)
9+
issues: write
10+
contents: read # Keep read permission just in case checkout needs it explicitly
1311

1412
jobs:
1513
explain_code_in_issue:
16-
# Run job only if the triggering label name matches
1714
if: github.event.label.name == 'ask-cstudio-explain'
18-
# Use the latest Ubuntu runner environment
1915
runs-on: ubuntu-latest
2016

2117
steps:
22-
# Step 1: Check out the repository code
23-
# Needed for setup-python to find pyproject.toml for caching
2418
- name: Check out repository code
2519
uses: actions/checkout@v4
2620

27-
# Step 2: Set up Python environment
21+
# --- FIX: Completely remove cache parameters ---
2822
- name: Set up Python
2923
uses: actions/setup-python@v5
3024
with:
31-
python-version: '3.13' # Specify Python version
32-
cache: 'pip' # Enable pip caching
33-
cache-dependency-path: 'pyproject.toml' # Explicitly point to the dependency file
25+
python-version: '3.13' # Or your preferred version (3.12, 3.13)
26+
# No 'cache' or 'cache-dependency-path' here
3427

35-
# Step 3: Install the CLI tool from PyPI
3628
- name: Install Codex CLI Studio
3729
run: |
3830
python -m pip install --upgrade pip
39-
pip install codex-cli-studio # Install the latest published version
31+
# Install directly from PyPI, no local build needed here
32+
pip install codex-cli-studio
4033
41-
# Step 4: Extract code snippet from the issue body
34+
# ... (Rest of the steps remain the same) ...
4235
- name: Extract Code Snippet from Issue Body
43-
id: extract_code # Assign an ID to reference outputs later
36+
id: extract_code
4437
run: |
45-
# Get issue body, remove potential carriage returns
4638
ISSUE_BODY=$(echo "${{ github.event.issue.body }}" | sed 's/\\r//g')
47-
# Extract content between the first pair of ``` fences using awk
4839
CODE_SNIPPET=$(echo "$ISSUE_BODY" | awk '/^```(\w*)/{f=1;next} /^```/{f=0; exit} f{print}')
49-
# Check if code snippet is empty
5040
if [[ -z "$CODE_SNIPPET" ]]; then
5141
echo "No code block found in issue body. Setting error message."
52-
# Set an output variable to indicate the error
5342
echo "error_message=No fenced code block (\`\`\` ... \`\`\`) found in the issue body." >> $GITHUB_OUTPUT
54-
# Exit step gracefully (job continues based on 'if' conditions later)
55-
exit 0
43+
exit 0 # Gracefully exit step
5644
else
57-
echo "Code snippet extracted successfully."
58-
# Save the multiline code snippet to a step output variable safely
45+
echo "Code snippet extracted."
5946
echo "code_snippet<<EOF" >> $GITHUB_OUTPUT
6047
echo "$CODE_SNIPPET" >> $GITHUB_OUTPUT
6148
echo "EOF" >> $GITHUB_OUTPUT
6249
fi
6350
64-
# Step 5: Run 'cstudio explain' command if code was extracted
6551
- name: Run cstudio explain
66-
id: cstudio # Assign an ID
67-
# Only run if the previous step did not set an error message
52+
id: cstudio
6853
if: steps.extract_code.outputs.error_message == null
6954
env:
70-
# Provide the OpenAI API key from repository secrets
7155
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
72-
# Set environment variables to potentially simplify terminal output for parsing
7356
TERM: dumb
7457
NO_COLOR: 1
7558
run: |
76-
# Execute the command using process substitution for multiline input
77-
# Capture the full output (stdout and potentially stderr if redirected)
7859
EXPLANATION=$(cstudio explain <(echo "${{ steps.extract_code.outputs.code_snippet }}") 2>&1)
79-
# Check the exit code of the command
8060
EXIT_CODE=$?
8161
if [ $EXIT_CODE -ne 0 ]; then
8262
echo "cstudio explain command failed with exit code $EXIT_CODE."
83-
# Save the error output
8463
echo "output<<EOF" >> $GITHUB_OUTPUT
8564
echo "Error running cstudio explain. Output:" >> $GITHUB_OUTPUT
86-
echo "$EXPLANATION" >> $GITHUB_OUTPUT # Include the command's output/error
65+
echo "$EXPLANATION" >> $GITHUB_OUTPUT
8766
echo "EOF" >> $GITHUB_OUTPUT
88-
exit 0 # Exit step gracefully to allow comment posting
67+
exit 0
8968
fi
9069
echo "Explanation generated."
91-
# Save the successful explanation output
9270
echo "output<<EOF" >> $GITHUB_OUTPUT
9371
echo "$EXPLANATION" >> $GITHUB_OUTPUT
9472
echo "EOF" >> $GITHUB_OUTPUT
9573
96-
# Step 6: Post the result (explanation or error) as a comment on the issue
9774
- name: Create Comment on Issue
98-
# Use the official GitHub Script action for API interactions
9975
uses: actions/github-script@v7
10076
with:
101-
# Use the default GITHUB_TOKEN which has necessary permissions
10277
github-token: ${{ secrets.GITHUB_TOKEN }}
103-
# The JavaScript code to run
10478
script: |
105-
// Get context for the issue and repository
79+
// ... (JavaScript code remains the same) ...
10680
const issue_number = context.issue.number;
10781
const repo = context.repo.repo;
10882
const owner = context.repo.owner;
109-
let body; // Variable to hold the comment body
110-
111-
// Get outputs from previous steps
83+
let body;
11284
const extraction_error = `${{ steps.extract_code.outputs.error_message }}`;
113-
const raw_output = `${{ steps.cstudio.outputs.output }}`; // Use raw_output for clarity
114-
115-
// Attempt basic cleanup of potential status lines from the CLI output
85+
const raw_output = `${{ steps.cstudio.outputs.output }}`;
11686
const output_lines = raw_output.split('\n');
11787
const first_line = output_lines[0] || '';
118-
// Remove known status/debug lines if present
11988
const explanation_content = (first_line.includes('Analyzing') || first_line.includes('Generating'))
12089
? output_lines.slice(1).join('\n')
12190
: raw_output;
12291
123-
// Construct the comment body based on step outcomes
12492
if (extraction_error) {
125-
// If code extraction failed
12693
body = `🤖 **Codex CLI Studio:**\n\n${extraction_error}`;
12794
} else if (explanation_content && !explanation_content.includes('Error running cstudio explain')) {
128-
// If explanation seems successful
12995
const formatted_explanation = explanation_content
130-
// Standardize headers potentially added by the explain module
13196
.replace(/^✨ Configuration File Explanation:/gm, '**Explanation:**')
13297
.replace(/^✨ Explanation:/gm, '**Explanation:**')
133-
.trim(); // Remove leading/trailing whitespace
98+
.trim();
13499
body = `🤖 **Codex CLI Studio Explanation:**\n\n---\n\n${formatted_explanation || "_(AI generated an empty explanation)_"}`;
135100
} else {
136-
// If cstudio command failed or returned empty/error output
137101
body = `🤖 **Codex CLI Studio:**\n\nSorry, I couldn't generate an explanation. There might have been an API issue or an internal error executing the command.`;
138-
// Log the raw output for debugging purposes in the Actions console
139102
console.log("Raw output from cstudio step:", raw_output);
140103
}
141-
142-
// Use GitHub REST API client provided by github-script to create the comment
143104
await github.rest.issues.createComment({
144105
owner: owner,
145106
repo: repo,

0 commit comments

Comments
 (0)