name: NekoCode PR Impact Analysis on: pull_request: types: [opened, synchronize, reopened] branches: [main, dev] jobs: nekocode-analysis: runs-on: ubuntu-latest name: Code Impact Analysis permissions: contents: read pull-requests: write steps: - name: Checkout PR uses: actions/checkout@v4 with: fetch-depth: 0 - name: Download NekoCode run: | mkdir -p bin curl -L https://github.com/moe-charm/nekocode-rust/raw/main/releases/nekocode-rust -o bin/nekocode-rust chmod +x bin/nekocode-rust - name: Analyze Current PR id: analyze-pr run: | echo "🔍 Analyzing PR changes..." ./bin/nekocode-rust analyze src/ --stats-only > pr_analysis.txt 2>&1 || true echo "📊 Analysis Results:" cat pr_analysis.txt FILES_COUNT=$(grep -o "found [0-9]* files" pr_analysis.txt | grep -o "[0-9]*" || echo "0") ANALYSIS_TIME=$(grep -o "Total directory analysis took: [0-9.]*s" pr_analysis.txt | grep -o "[0-9.]*s" || echo "N/A") echo "files_analyzed=$FILES_COUNT" >> $GITHUB_OUTPUT echo "analysis_time=$ANALYSIS_TIME" >> $GITHUB_OUTPUT - name: Generate Impact Report run: | PR_FILES=${{ steps.analyze-pr.outputs.files_analyzed }} ANALYSIS_TIME=${{ steps.analyze-pr.outputs.analysis_time }} cat > impact_report.md << EOF ## 🦀 NekoCode Analysis Report ### 📊 Code Impact Summary | Metric | Value | |--------|-------| | **Files Analyzed** | ${PR_FILES} files | | **Analysis Time** | ${ANALYSIS_TIME} | | **Languages Detected** | Rust | ### ✅ Analysis Status - **Code Quality**: NekoCode analysis completed successfully - **Performance**: Analysis completed in ${ANALYSIS_TIME} - **Compatibility**: All detected files processed without errors --- *🚀 Analysis powered by [NekoCode](https://github.com/moe-charm/nekocode-rust)* EOF - name: Comment PR uses: actions/github-script@v7 with: script: | const fs = require('fs'); const report = fs.readFileSync('impact_report.md', 'utf8'); const comments = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, }); const nekocodeComment = comments.data.find(comment => comment.body.includes('🦀 NekoCode Analysis Report') ); if (nekocodeComment) { await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: nekocodeComment.id, body: report }); } else { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: report }); }