diff --git a/.github/workflows/similar-issues.yml b/.github/workflows/similar-issues.yml index 343982af8..9873a0585 100644 --- a/.github/workflows/similar-issues.yml +++ b/.github/workflows/similar-issues.yml @@ -7,6 +7,8 @@ on: jobs: analyze: + # Disabling for now due to bugs + if: false runs-on: ubuntu-latest permissions: issues: write @@ -16,28 +18,28 @@ jobs: - name: Checkout deja-view uses: actions/checkout@v5 with: - repository: 'bdougie/deja-view' + repository: "bdougie/deja-view" # Option 1: Pin to specific commit (most secure) - ref: '45e7696' # Pin to specific commit for stability - + ref: "45e7696" # Pin to specific commit for stability + # Option 2: Use a tag (recommended after creating releases) # ref: 'v1.0.0' - + # Option 3: Use main branch (least secure, gets latest changes) # ref: 'main' - + path: deja-view - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: "3.11" - name: Install dependencies run: | cd deja-view pip install -r requirements.txt - + - name: Index repository if needed env: CHROMA_API_KEY: ${{ secrets.CHROMA_CLOUD_API_KEY }} @@ -46,10 +48,10 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | cd deja-view - + # Index the repository (this will update existing index) python cli.py index "${{ github.repository }}" --max-issues 200 || true - + - name: Search for similar issues id: search env: @@ -59,7 +61,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | cd deja-view - + # Determine if this is an issue or PR if [ "${{ github.event_name }}" = "pull_request" ]; then ISSUE_URL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}" @@ -70,26 +72,26 @@ jobs: THRESHOLD="0.7" TOP_K="5" fi - + # Create a Python script to search and format as JSON cat << 'PYTHON_SCRIPT' > search_similar.py import sys import json import os from github_similarity_service import SimilarityService - + issue_url = sys.argv[1] threshold = float(sys.argv[2]) top_k = int(sys.argv[3]) - + # Parse issue number from URL issue_number = int(issue_url.split('/')[-1]) repo_parts = issue_url.split('/') owner = repo_parts[3] repo = repo_parts[4] - + service = SimilarityService() - + # Find similar issues similar = service.find_similar_issues( owner=owner, @@ -98,26 +100,26 @@ jobs: top_k=top_k, min_similarity=threshold ) - + # Format as JSON print(json.dumps(similar)) PYTHON_SCRIPT - + # Search for similar issues SIMILAR_ISSUES=$(python search_similar.py "$ISSUE_URL" "$THRESHOLD" "$TOP_K") - + # Save to output echo "similar_issues<> $GITHUB_OUTPUT echo "$SIMILAR_ISSUES" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - + # Check if any similar issues found if [ "$(echo "$SIMILAR_ISSUES" | jq '. | length')" -gt 0 ]; then echo "has_similar=true" >> $GITHUB_OUTPUT else echo "has_similar=false" >> $GITHUB_OUTPUT fi - + - name: Check if issue should be a discussion id: discussion_check if: github.event_name == 'issues' @@ -128,19 +130,19 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | cd deja-view - + # Create a Python script to analyze the issue cat << 'PYTHON_SCRIPT' > check_discussion.py import os import json import re from github_similarity_service import SimilarityService - + # Get issue details from environment issue_title = os.environ.get('ISSUE_TITLE', '') issue_body = os.environ.get('ISSUE_BODY', '') issue_labels = json.loads(os.environ.get('ISSUE_LABELS', '[]')) - + # Mock Issue object for analysis class MockIssue: def __init__(self): @@ -152,41 +154,41 @@ jobs: self.created_at = '' self.updated_at = '' self.url = '' - + service = SimilarityService() issue = MockIssue() - + score, reasons = service._calculate_discussion_score(issue) - + result = { 'score': score, 'reasons': reasons, 'should_be_discussion': score >= 0.5, 'confidence': 'high' if score >= 0.7 else 'medium' if score >= 0.5 else 'low' } - + print(json.dumps(result)) PYTHON_SCRIPT - + # Run the analysis DISCUSSION_ANALYSIS=$(ISSUE_TITLE="${{ github.event.issue.title }}" \ ISSUE_BODY='${{ github.event.issue.body }}' \ ISSUE_LABELS='${{ toJson(github.event.issue.labels.*.name) }}' \ ISSUE_NUMBER="${{ github.event.issue.number }}" \ python check_discussion.py) - + echo "analysis<> $GITHUB_OUTPUT echo "$DISCUSSION_ANALYSIS" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - + # Extract whether it should be a discussion SHOULD_BE_DISCUSSION=$(echo "$DISCUSSION_ANALYSIS" | jq -r '.should_be_discussion') echo "should_be_discussion=$SHOULD_BE_DISCUSSION" >> $GITHUB_OUTPUT - + # Extract confidence level CONFIDENCE=$(echo "$DISCUSSION_ANALYSIS" | jq -r '.confidence') echo "confidence=$CONFIDENCE" >> $GITHUB_OUTPUT - + - name: Comment with analysis uses: actions/github-script@v7 with: @@ -195,7 +197,7 @@ jobs: const hasSimilar = '${{ steps.search.outputs.has_similar }}' === 'true'; const isPR = '${{ github.event_name }}' === 'pull_request'; const shouldBeDiscussion = !isPR && '${{ steps.discussion_check.outputs.should_be_discussion }}' === 'true'; - + // Add similar issues section if found if (hasSimilar) { const similarIssues = JSON.parse(`${{ steps.search.outputs.similar_issues }}`); @@ -243,7 +245,7 @@ jobs: comment += '\n'; } } - + // Add discussion suggestion if applicable if (shouldBeDiscussion) { const analysis = JSON.parse(`${{ steps.discussion_check.outputs.analysis }}`); @@ -280,7 +282,7 @@ jobs: comment += '_Consider converting this to a discussion if it\'s not a bug report or actionable task._\n'; } - + // Only comment if we have something to say if (comment) { comment += '\n---\n'; @@ -302,14 +304,14 @@ jobs: }); } } - + - name: Add labels if: github.event_name == 'issues' uses: actions/github-script@v7 with: script: | const labels = []; - + // Check for duplicate if ('${{ steps.search.outputs.has_similar }}' === 'true') { const similarIssues = JSON.parse(`${{ steps.search.outputs.similar_issues }}`); @@ -319,7 +321,7 @@ jobs: labels.push('potential-duplicate'); } } - + // Check for discussion suggestion if ('${{ steps.discussion_check.outputs.should_be_discussion }}' === 'true') { const confidence = '${{ steps.discussion_check.outputs.confidence }}'; @@ -330,7 +332,7 @@ jobs: labels.push('discussion'); } } - + // Add labels if any if (labels.length > 0) { await github.rest.issues.addLabels({