Skip to content

Commit daf5838

Browse files
authored
Tests
1 parent a146286 commit daf5838

File tree

3 files changed

+147
-10
lines changed

3 files changed

+147
-10
lines changed

.github/workflows/gemini-assistant.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,37 +144,53 @@ jobs:
144144
SECURITY NOTICE: This analysis is performed safely without accessing untrusted code.
145145
Always be helpful, specific, and focus on WordPress best practices.
146146
If you need more information to provide a complete answer, ask clarifying questions.
147-
"
147+
" > assistant-response.txt
148148
149-
- name: Post AI Response
149+
- name: Post AI Assistant Response
150150
uses: actions/github-script@v7
151151
env:
152152
# SECURITY: Use environment variables for safe handling
153153
COMMENT_USER: ${{ github.event.comment.user.login }}
154154
USER_COMMAND: ${{ steps.extract-command.outputs.command }}
155+
ISSUE_NUMBER: ${{ github.event.issue.number }}
155156
with:
156157
script: |
158+
const fs = require('fs');
157159
const commentUser = process.env.COMMENT_USER;
158160
const userCommand = process.env.USER_COMMAND;
161+
const issueNumber = process.env.ISSUE_NUMBER;
159162
160163
// SECURITY: Validate inputs
161164
if (!commentUser || !userCommand) {
162165
throw new Error('Missing required environment variables');
163166
}
164167
168+
let assistantResponse = 'No response generated.';
169+
try {
170+
if (fs.existsSync('assistant-response.txt')) {
171+
assistantResponse = fs.readFileSync('assistant-response.txt', 'utf8');
172+
}
173+
} catch (error) {
174+
console.log('Error reading assistant response file:', error);
175+
assistantResponse = 'Error reading AI assistant response.';
176+
}
177+
165178
const aiResponse = `
166-
## 🤖 AI Assistant Response
179+
## 🤖 AI WordPress Assistant Response
167180
168-
Hi @${commentUser}! I've analyzed your request: "${userCommand}"
181+
Hi @${commentUser}! I've analyzed your request: **"${userCommand}"**
169182
170-
### 📝 Analysis & Recommendations
183+
### 📝 Expert Analysis & Recommendations
171184
172-
[The actual Gemini response would appear here from the action output]
185+
${assistantResponse}
186+
187+
---
173188
174189
### 🔗 Helpful Resources
175190
- [WordPress Plugin Developer Handbook](https://developer.wordpress.org/plugins/)
176191
- [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/)
177192
- [Plugin Security Guidelines](https://developer.wordpress.org/plugins/security/)
193+
- [WooCommerce Developer Documentation](https://woocommerce.com/document/create-a-plugin/)
178194
179195
### 💡 Available Commands
180196
Try these commands with @gemini-cli:
@@ -185,11 +201,13 @@ jobs:
185201
- \`@gemini-cli write tests for X\` - Test implementation guidance
186202
- \`@gemini-cli debug this issue\` - Bug investigation and resolution
187203
188-
> 🔄 **Note:** This is an AI-generated response. Please review suggestions carefully and test thoroughly.
204+
> 🔄 **Note:** This is an AI-generated response for Optimizations ACE MC v1.0.5. Please review suggestions carefully and test thoroughly.
205+
206+
**Analysis Date:** ${new Date().toISOString()}
189207
`;
190208
191209
await github.rest.issues.createComment({
192-
issue_number: context.issue.number,
210+
issue_number: issueNumber,
193211
owner: context.repo.owner,
194212
repo: context.repo.repo,
195213
body: aiResponse

.github/workflows/gemini-security-scan.yml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,62 @@ jobs:
8787
8888
FILES TO ANALYZE:
8989
$CHANGED_FILES
90-
"
90+
" > security-analysis.txt
91+
92+
- name: Post Security Analysis Summary
93+
if: steps.changed-files.outputs.any_changed == 'true'
94+
uses: actions/github-script@v7
95+
env:
96+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
97+
with:
98+
script: |
99+
const fs = require('fs');
100+
const changedFiles = process.env.CHANGED_FILES;
101+
102+
let analysisContent = 'No analysis output found.';
103+
try {
104+
if (fs.existsSync('security-analysis.txt')) {
105+
analysisContent = fs.readFileSync('security-analysis.txt', 'utf8');
106+
}
107+
} catch (error) {
108+
console.log('Error reading analysis file:', error);
109+
analysisContent = 'Error reading security analysis results.';
110+
}
111+
112+
const title = `🔒 Security Analysis Report - ${context.sha.substring(0, 7)}`;
113+
const body = `
114+
## 🛡️ WordPress Security Analysis Results
115+
116+
**Repository:** ${context.repo.owner}/${context.repo.repo}
117+
**Commit:** ${context.sha}
118+
**Branch:** ${context.ref}
119+
**Files Analyzed:** ${changedFiles}
120+
**Analysis Date:** ${new Date().toISOString()}
121+
122+
---
123+
124+
### 🤖 AI Security Expert Findings
125+
126+
${analysisContent}
127+
128+
---
129+
130+
### 📋 Next Steps
131+
- Review any security issues identified above
132+
- Address critical and high-severity findings immediately
133+
- Test all security-related changes thoroughly
134+
- Consider implementing additional security measures if recommended
135+
136+
**Workflow Run:** ${context.payload.repository.html_url}/actions/runs/${context.runId}
137+
`;
138+
139+
await github.rest.issues.create({
140+
owner: context.repo.owner,
141+
repo: context.repo.repo,
142+
title: title,
143+
body: body,
144+
labels: ['security-analysis', 'ai-generated', 'needs-review']
145+
});
91146
92147
- name: Create Security Issue on Critical Findings
93148
if: failure()

.github/workflows/wordpress-standards-check.yml

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,71 @@ jobs:
110110
111111
FILES TO ANALYZE:
112112
$CHANGED_FILES
113-
"
113+
" > standards-analysis.txt
114+
115+
- name: Post Standards Analysis Summary
116+
if: steps.changed-files.outputs.any_changed == 'true'
117+
uses: actions/github-script@v7
118+
env:
119+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
120+
FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
121+
with:
122+
script: |
123+
const fs = require('fs');
124+
const changedFiles = process.env.CHANGED_FILES;
125+
const filesCount = process.env.FILES_COUNT;
126+
127+
let analysisContent = 'No analysis output found.';
128+
try {
129+
if (fs.existsSync('standards-analysis.txt')) {
130+
analysisContent = fs.readFileSync('standards-analysis.txt', 'utf8');
131+
}
132+
} catch (error) {
133+
console.log('Error reading analysis file:', error);
134+
analysisContent = 'Error reading standards analysis results.';
135+
}
136+
137+
const title = `📋 WordPress Standards Review - ${context.sha.substring(0, 7)}`;
138+
const body = `
139+
## 🎯 WordPress Best Practices Analysis Results
140+
141+
**Repository:** ${context.repo.owner}/${context.repo.repo}
142+
**Commit:** ${context.sha}
143+
**Branch:** ${context.ref}
144+
**Files Analyzed:** ${filesCount}
145+
**Analysis Date:** ${new Date().toISOString()}
146+
147+
### 📁 Files Reviewed
148+
\`\`\`
149+
${changedFiles}
150+
\`\`\`
151+
152+
---
153+
154+
### 🤖 WordPress Expert Findings
155+
156+
${analysisContent}
157+
158+
---
159+
160+
### 📋 Recommended Actions
161+
- Review all findings marked as CRITICAL or HIGH priority
162+
- Implement suggested WordPress coding standards improvements
163+
- Test changes to ensure compatibility with WordPress 6.5+ and PHP 7.4+
164+
- Consider performance optimizations where recommended
165+
- Update documentation if architectural changes are suggested
166+
167+
**Workflow Run:** ${context.payload.repository.html_url}/actions/runs/${context.runId}
168+
`;
169+
170+
// Create issue for standards review
171+
await github.rest.issues.create({
172+
owner: context.repo.owner,
173+
repo: context.repo.repo,
174+
title: title,
175+
body: body,
176+
labels: ['code-standards', 'wordpress', 'ai-generated', 'needs-review']
177+
});
114178
115179
- name: Comment on PR with Findings
116180
if: github.event_name == 'pull_request'

0 commit comments

Comments
 (0)