-
-
Notifications
You must be signed in to change notification settings - Fork 0
ENH: Implement QuantEcon Style Guide Action for AI-powered content review #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: mmcky <[email protected]>
Co-authored-by: mmcky <[email protected]>
|
@copilot how do I configure this action in one of our repositories to monitor issues for the |
To configure this action in one of your repositories to monitor for 1. Copy the Workflow FileCreate name: QuantEcon Style Guide Check
"on":
issue_comment:
types: [created]
jobs:
style-check:
if: contains(github.event.comment.body, '@qe-style-check')
runs-on: ubuntu-latest
name: Process style guide check request
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.issue.pull_request && github.event.pull_request.head.ref || github.sha }}
- name: Check if user has permissions
id: check-permissions
uses: actions/github-script@v7
with:
script: |
const { data: permissions } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: context.payload.comment.user.login
});
const hasPermissions = ['write', 'admin', 'maintain'].includes(permissions.permission);
if (!hasPermissions) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: '⚠️ Sorry, only collaborators with write access can trigger style guide checks.'
});
core.setFailed('User does not have sufficient permissions');
return;
}
core.setOutput('has-permissions', 'true');
- name: React to comment
if: steps.check-permissions.outputs.has-permissions == 'true'
uses: actions/github-script@v7
with:
script: |
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'eyes'
});
- name: Run style guide check
if: steps.check-permissions.outputs.has-permissions == 'true'
id: style-check
uses: QuantEcon/meta/.github/actions/qe-style-guide@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
style-guide: '.github/copilot-qe-style-guide.md'
docs: 'lectures/' # Adjust this to your content directory
extensions: 'md' # Adjust file extensions as needed
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
model: 'gpt-4'
max-suggestions: '20'
confidence-threshold: '0.8'2. Customize ConfigurationUpdate the
3. Optional: Add OpenAI API KeyFor enhanced AI analysis, add 4. Copy Style Guide (Optional)Copy the style guide file UsageOnce configured, users with write access can comment:
The action will automatically check permissions and only allow authorized users to trigger reviews. |
|
@copilot the |
Yes, that's correct! The In the action implementation, the code checks if the value starts with 'http' and then fetches the content via HTTP request: if self.style_guide_path.startswith('http'):
# Load from URL
response = requests.get(self.style_guide_path)
response.raise_for_status()
return response.textSo you can use it in several ways:
This allows repositories to either maintain their own local style guide or reference a centralized one from a URL. |
This PR implements a comprehensive GitHub Action that provides AI-powered style guide checking and automated suggestions for QuantEcon content. The action can be triggered via comments on issues and pull requests to automatically review and improve content according to the QuantEcon style guidelines.
Key Features
Comment-Triggered Workflow
@qe-style-check filename.mdto create a new PR with comprehensive style suggestions@qe-style-checkto apply high-confidence style improvements directly to the existing PRAI-Powered Analysis
Style Guide Enforcement
The action enforces QuantEcon style rules including:
α, β, γ, δ, ε, σ, θ, ρ) instead of spelled-out versions in Python codeA^\top), matrix brackets, sequence notationFlexible Configuration
Implementation Details
Components Added
.github/actions/qe-style-guide/- Complete GitHub Action implementation.github/workflows/qe-style-guide.yml- Comment-triggered workflow.github/workflows/test-qe-style-guide.yml- Comprehensive test suitetest/qe-style-guide/- Test files and validation scriptsTechnical Architecture
Testing & Validation
Usage Examples
Direct Workflow Integration
Comment Triggers
This implementation provides QuantEcon with a powerful tool for maintaining consistent, high-quality content across all repositories while reducing manual review overhead and ensuring adherence to established style guidelines.
Fixes #228.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.