Skip to content
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

test: Add github action to test code graph #471

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

dexters1
Copy link
Collaborator

@dexters1 dexters1 commented Jan 24, 2025

Description

  • Add github action for code graph
  • Fix profiler
  • Change profiler to run on HEAD instead of base branch

DCO Affirmation

I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin

Summary by CodeRabbit

Release Notes

  • GitHub Actions

    • Added new workflow for code graph example testing
    • Updated profiling workflow to focus on head branch
    • Enhanced reusable Python workflow with optional arguments
  • Dependencies

    • Added optional dependencies for code analysis:
      • parso
      • jedi
  • Code Changes

    • Removed unused import in repository processing task

Copy link
Contributor

coderabbitai bot commented Jan 24, 2025

Walkthrough

This pull request introduces several workflow and configuration changes across GitHub Actions and project dependencies. The modifications include a new profiling workflow configuration, an enhancement to a reusable Python workflow to support optional arguments, a new code graph example test workflow, removal of an unused import in a repository processing task, and the addition of optional dependencies for code analysis in the project's dependency management.

Changes

File Change Summary
.github/workflows/profiling.yaml Modified profiling workflow to focus on head branch profiling
.github/workflows/reusable_python_example.yml Added optional arguments input for script execution
.github/workflows/test_code_graph_example.yml New workflow for testing code graph example with secrets and reusable workflow
cognee/tasks/repo_processor/get_non_code_files.py Removed write_metadata import
pyproject.toml Added optional dependencies parso and jedi, created codegraph extra

Sequence Diagram

sequenceDiagram
    participant Workflow as GitHub Actions
    participant Script as Python Script
    participant Secrets as Secret Manager

    Workflow->>Secrets: Retrieve API Keys
    Secrets-->>Workflow: Return Secrets
    Workflow->>Script: Execute with Arguments
    Script->>Script: Process Repository
Loading

Poem

🐰 In workflows of code and might,
Rabbits dance with pure delight!
Arguments flow, secrets secure,
Dependencies added, our path is pure
Hopping through changes, swift and bright! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dexters1 dexters1 marked this pull request as ready for review January 24, 2025 17:23
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
.github/workflows/test_code_graph_example.yml (1)

4-6: Consider adding a label filter for PR triggers.

The workflow currently runs on any labeled PR event. To prevent unnecessary runs, consider filtering for specific labels related to code graph testing.

 pull_request:
   types: [labeled, synchronize]
+  if: contains(github.event.pull_request.labels.*.name, 'code-graph')
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8793e48 and ae016d4.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • .github/workflows/profiling.yaml (1 hunks)
  • .github/workflows/reusable_python_example.yml (2 hunks)
  • .github/workflows/test_code_graph_example.yml (1 hunks)
  • cognee/tasks/repo_processor/get_non_code_files.py (0 hunks)
  • pyproject.toml (2 hunks)
💤 Files with no reviewable changes (1)
  • cognee/tasks/repo_processor/get_non_code_files.py
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/profiling.yaml

88-88: shellcheck reported issue in this script: SC2086:info:3:14: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (4)
.github/workflows/test_code_graph_example.yml (1)

17-18: Verify the repository path argument.

The --repo_path ./evals argument assumes the existence of an evals directory. This path should be verified to ensure it exists in the repository.

✅ Verification successful

The repository path argument is valid and correct

The --repo_path ./evals argument points to an existing directory that contains the necessary evaluation-related files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the evals directory
# Expected: Directory exists and contains relevant files

echo "Checking for evals directory..."
if [ -d "./evals" ]; then
    echo "Directory exists. Listing contents:"
    ls -la ./evals
else
    echo "Directory ./evals not found!"
fi

Length of output: 1767

.github/workflows/reusable_python_example.yml (1)

10-13: LGTM! Well-structured optional input parameter.

The addition of the optional arguments parameter is well-defined with clear description and appropriate required flag.

pyproject.toml (2)

80-81: LGTM! Dependencies align with code analysis requirements.

The addition of parso and jedi as optional dependencies is appropriate for code analysis functionality.


99-99: LGTM! Well-organized extra group.

The new codegraph extra properly groups the related dependencies.

@@ -53,4 +57,4 @@ jobs:
LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GRAPHISTRY_USERNAME: ${{ secrets.GRAPHISTRY_USERNAME }}
GRAPHISTRY_PASSWORD: ${{ secrets.GRAPHISTRY_PASSWORD }}
run: poetry run python ${{ inputs.example-location }}
run: poetry run python ${{ inputs.example-location }} ${{ inputs.arguments }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Quote the input arguments to handle spaces.

The command should quote the arguments to handle cases where they contain spaces.

-        run: poetry run python ${{ inputs.example-location }} ${{ inputs.arguments }}
+        run: poetry run python "${{ inputs.example-location }}" ${{ inputs.arguments != '' && format('"{0}"', inputs.arguments) || '' }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: poetry run python ${{ inputs.example-location }} ${{ inputs.arguments }}
run: poetry run python "${{ inputs.example-location }}" ${{ inputs.arguments != '' && format('"{0}"', inputs.arguments) || '' }}

Comment on lines +71 to +83
# - name: Run profiler on base branch
# env:
# HEAD_SHA: ${{ env.HEAD_SHA }}
# BASE_SHA: ${{ env.BASE_SHA }}
# run: |
# echo "Profiling the head branch for code_graph_pipeline.py"
# echo "Checking out head SHA: $HEAD_SHA"
# git checkout $HEAD_SHA
# echo "Profiling the base branch for code_graph_pipeline.py"
# echo "Checking out base SHA: $BASE_SHA"
# git checkout $BASE_SHA
# echo "This is the working directory: $PWD"
# # Ensure the script is executable
# chmod +x cognee/api/v1/cognify/code_graph_pipeline.py
# # Run Scalene
# poetry run pyinstrument --renderer json -o head_results.json cognee/api/v1/cognify/code_graph_pipeline.py
# poetry run pyinstrument --renderer json -o base_results.json cognee/api/v1/cognify/code_graph_pipeline.py

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider keeping base branch profiling for comparison.

While the PR objective is to run profiling on HEAD, removing the base branch profiling eliminates the ability to compare performance changes. Consider keeping both for meaningful performance analysis.

Comment on lines +91 to +92
git checkout $HEAD_SHA
echo "This is the working directory: $PWD"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Quote the SHA variable to prevent word splitting.

The git checkout command should quote the SHA variable to handle special characters safely.

-        git checkout $HEAD_SHA
+        git checkout "$HEAD_SHA"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
git checkout $HEAD_SHA
echo "This is the working directory: $PWD"
git checkout "$HEAD_SHA"
echo "This is the working directory: $PWD"

Comment on lines +94 to +96
chmod +x cognee/api/v1/cognify/code_graph_pipeline.py
# Run Scalene
poetry run pyinstrument --renderer json -o head_results.json cognee/api/v1/cognify/code_graph_pipeline.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Verify script existence and add error handling.

The workflow assumes the script exists and is executable. Add checks and error handling.

-        chmod +x cognee/api/v1/cognify/code_graph_pipeline.py
-        poetry run pyinstrument --renderer json -o head_results.json cognee/api/v1/cognify/code_graph_pipeline.py
+        SCRIPT_PATH="cognee/api/v1/cognify/code_graph_pipeline.py"
+        if [ ! -f "$SCRIPT_PATH" ]; then
+            echo "Error: Script not found at $SCRIPT_PATH"
+            exit 1
+        fi
+        chmod +x "$SCRIPT_PATH"
+        if ! poetry run pyinstrument --renderer json -o head_results.json "$SCRIPT_PATH"; then
+            echo "Error: Profiling failed"
+            exit 1
+        fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
chmod +x cognee/api/v1/cognify/code_graph_pipeline.py
# Run Scalene
poetry run pyinstrument --renderer json -o head_results.json cognee/api/v1/cognify/code_graph_pipeline.py
SCRIPT_PATH="cognee/api/v1/cognify/code_graph_pipeline.py"
if [ ! -f "$SCRIPT_PATH" ]; then
echo "Error: Script not found at $SCRIPT_PATH"
exit 1
fi
chmod +x "$SCRIPT_PATH"
if ! poetry run pyinstrument --renderer json -o head_results.json "$SCRIPT_PATH"; then
echo "Error: Profiling failed"
exit 1
fi

@Vasilije1990 Vasilije1990 merged commit 72e332f into dev Jan 24, 2025
31 checks passed
@Vasilije1990 Vasilije1990 deleted the add-code-graph-gh-action branch January 24, 2025 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants