Skip to content

Commit 2ba03b2

Browse files
committed
Update greeting message in InfoController's Get method for clarity
1 parent 9c36787 commit 2ba03b2

File tree

2 files changed

+24
-39
lines changed

2 files changed

+24
-39
lines changed

.github/workflows/code-review.yml

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ jobs:
1919
- name: Checkout Repository
2020
uses: actions/checkout@v4
2121
with:
22-
# Checks out the code from the pull request's head branch, the feature branch with changes.
23-
# ref: ${{ github.event.pull_request.head.ref }}
24-
fetch-depth: 0
25-
26-
# - name: Fetch Base Branch
27-
# run: |
28-
# git fetch origin ${{ github.base_ref }}
22+
fetch-depth: 0 # Fetches all history for the entire branch
2923

3024
- name: Generate Diff
3125
id: generate-diff
@@ -44,48 +38,24 @@ jobs:
4438
with:
4539
name: sanitized-pr-diff
4640
path: sanitized_diff.txt
47-
48-
# Step 6: Install Ollama
41+
4942
- name: Install Ollama
5043
run: |
5144
curl -fsSL https://ollama.com/install.sh | sh
5245
ollama --version
5346
54-
# Step 7: Pull the specified model
5547
- name: Pull Model
5648
run: |
5749
ollama pull ${{ env.MODEL_NAME }} || { echo "Failed to pull model"; exit 1; }
5850
ollama list
5951
60-
# Step 8: Read the diff file and prepare the prompt for Ollama
61-
# - name: Prepare Prompt
62-
# run: |
63-
# DIFF=$(cat sanitized_diff.txt)
64-
# PROMPT=$(echo "Please review the following code changes and provide feedback:\n\n$DIFF\n\nFeedback:" | sed 's/"/\\"/g')
65-
# echo "prompt<<EOF" >> $GITHUB_ENV
66-
# echo "$PROMPT" >> $GITHUB_ENV
67-
# echo "EOF" >> $GITHUB_ENV
68-
# shell: /usr/bin/bash -e {0}
69-
7052
- name: Prepare Prompt
7153
run: |
7254
DIFF=$(cat sanitized_diff.txt)
73-
PROMPT=$(echo "Please review the following code changes and provide feedback:\n\n$DIFF\n\nFeedback:" | jq -sR .)
55+
PROMPT=$(echo "Please review the following code changes, summarize the changes, and provide feedback:\n\n$DIFF\n\nFeedback:" | jq -sR .)
7456
echo "prompt=$PROMPT" >> $GITHUB_ENV
7557
shell: /usr/bin/bash -e {0}
7658

77-
# Step 9: Perform code review using Ollama
78-
# - name: Code Review
79-
# run: |
80-
# RAW_RESPONSE=$(curl -s -X POST http://localhost:11434/api/generate \
81-
# -d '{
82-
# "model": "'"${{ env.MODEL_NAME }}"'",
83-
# "prompt": "'"${{ env.prompt }}"'",
84-
# "temperature": 0.5,
85-
# "stream": false
86-
# }' || { echo "API call failed"; exit 1; })
87-
# echo "RAW RESPONSE:\n$RAW_RESPONSE"
88-
8959
- name: Code Review
9060
run: |
9161
PAYLOAD=$(jq -n \
@@ -101,8 +71,23 @@ jobs:
10171
-d "$PAYLOAD" || { echo "API call failed"; exit 1; })
10272
echo "RAW RESPONSE:\n$RAW_RESPONSE"
10373
104-
# Step 9: Optionally save the response as an artifact
105-
# - name: Save Response as Artifact
106-
# run: |
107-
# echo "$RAW_RESPONSE" > response.json
108-
# if: always()
74+
# Try to extract the response, fallback to a default message if not found
75+
REVIEW=$(echo "$RAW_RESPONSE" | jq -r '.response')
76+
77+
if [ -z "$REVIEW" ]; then
78+
echo "Model did not return a valid review. Check RAW_RESPONSE for errors."
79+
REVIEW="Model did not return a valid review. RAW_RESPONSE: $RAW_RESPONSE"
80+
fi
81+
82+
- name: Post Review Comment
83+
uses: actions/github-script@v6
84+
with:
85+
github-token: ${{ secrets.GITHUB_TOKEN }}
86+
script: |
87+
const review = process.env.REVIEW;
88+
await github.rest.issues.createComment({
89+
owner: context.repo.owner,
90+
repo: context.repo.repo,
91+
issue_number: context.issue.number,
92+
body: `### AI Review\n\n${review}`
93+
});

src/MyWebApi/MyWebApi/Controllers/WeatherForecastController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public InfoController(ILogger<InfoController> logger)
1616
[HttpGet(Name = "Get")]
1717
public IActionResult Get()
1818
{
19-
var hello = "Hello";
19+
var hello = "Hello World";
2020
// Log a message at the Information level
2121
var message = "Hello World from InfoController. This is a sample message.";
2222
_logger.LogInformation(message);

0 commit comments

Comments
 (0)