Skip to content

Commit

Permalink
for test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatthan-kim committed Sep 24, 2024
1 parent 26b3c1f commit 7dd38ae
Showing 1 changed file with 71 additions and 71 deletions.
142 changes: 71 additions & 71 deletions .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,81 +26,81 @@ jobs:
DIFF=$(git diff origin/${{ github.base_ref }} ${{ github.sha }} | base64 -w 0)
echo "::set-output name=diff::$DIFF"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Get diff
run: |
git diff --no-prefix ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > pr_diff.txt
- name: List directory contents
run: ls -la

- name: Check if diff file exists
run: |
if [ ! -f pr_diff.txt ]; then
echo "pr_diff.txt does not exist"
exit 1
fi
- name: Upload diff to S3
id: upload-diff
run: |
DIFF_S3_KEY="diffs/pr-${{ github.event.pull_request.number }}-${{ github.sha }}.txt"
if [ -f pr_diff.txt ]; then
aws s3 cp pr_diff.txt s3://llm-code-review-test/$DIFF_S3_KEY
echo "::set-output name=diff_s3_key::$DIFF_S3_KEY"
else
echo "pr_diff.txt not found. Current directory contents:"
ls -la
exit 1
fi
- name: Invoke Lambda function and get Batch job ID
id: invoke-lambda
run: |
DIFF_S3_KEY="diffs/pr-${{ github.event.pull_request.number }}-${{ github.sha }}.txt"
PR_NUMBER="${{ github.event.pull_request.number }}"
HUGGINGFACE_TOKEN="${{ secrets.HUGGINGFACE_TOKEN }}"
PAYLOAD=$(echo -n "{\"diff_s3_key\": \"$DIFF_S3_KEY\", \"pr_number\": \"$PR_NUMBER\", \"huggingface_token\": \"$HUGGINGFACE_TOKEN\"}" | jq -c .)
JOB_ID=$(aws lambda invoke \
--function-name code-review-lambda-dev-codeReview \
--payload "$PAYLOAD" \
--cli-binary-format raw-in-base64-out \
output.json > /dev/null && cat output.json | jq -r '.body | fromjson | .jobId')
echo "job_id=$JOB_ID" >> $GITHUB_OUTPUT
- name: Wait for Batch job completion
run: |
job_id="${{ steps.invoke-lambda.outputs.job_id }}"
if [ -z "$job_id" ]; then
echo "No job ID received from Lambda function"
exit 1
fi
while true; do
status=$(aws batch describe-jobs --jobs $job_id --query 'jobs[0].status' --output text)
if [ "$status" = "SUCCEEDED" ]; then
echo "Job completed successfully"
break
elif [ "$status" = "FAILED" ]; then
echo "Job failed"
exit 1
else
echo "Job is still running. Current status: $status"
sleep 30
fi
done
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ap-northeast-2
#
# - name: Get diff
# run: |
# git diff --no-prefix ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > pr_diff.txt
#
# - name: List directory contents
# run: ls -la
#
# - name: Check if diff file exists
# run: |
# if [ ! -f pr_diff.txt ]; then
# echo "pr_diff.txt does not exist"
# exit 1
# fi
#
# - name: Upload diff to S3
# id: upload-diff
# run: |
# DIFF_S3_KEY="diffs/pr-${{ github.event.pull_request.number }}-${{ github.sha }}.txt"
# if [ -f pr_diff.txt ]; then
# aws s3 cp pr_diff.txt s3://llm-code-review-test/$DIFF_S3_KEY
# echo "::set-output name=diff_s3_key::$DIFF_S3_KEY"
# else
# echo "pr_diff.txt not found. Current directory contents:"
# ls -la
# exit 1
# fi
#
# - name: Invoke Lambda function and get Batch job ID
# id: invoke-lambda
# run: |
# DIFF_S3_KEY="diffs/pr-${{ github.event.pull_request.number }}-${{ github.sha }}.txt"
# PR_NUMBER="${{ github.event.pull_request.number }}"
# HUGGINGFACE_TOKEN="${{ secrets.HUGGINGFACE_TOKEN }}"
# PAYLOAD=$(echo -n "{\"diff_s3_key\": \"$DIFF_S3_KEY\", \"pr_number\": \"$PR_NUMBER\", \"huggingface_token\": \"$HUGGINGFACE_TOKEN\"}" | jq -c .)
# JOB_ID=$(aws lambda invoke \
# --function-name code-review-lambda-dev-codeReview \
# --payload "$PAYLOAD" \
# --cli-binary-format raw-in-base64-out \
# output.json > /dev/null && cat output.json | jq -r '.body | fromjson | .jobId')
# echo "job_id=$JOB_ID" >> $GITHUB_OUTPUT
#
# - name: Wait for Batch job completion
# run: |
# job_id="${{ steps.invoke-lambda.outputs.job_id }}"
# if [ -z "$job_id" ]; then
# echo "No job ID received from Lambda function"
# exit 1
# fi
# while true; do
# status=$(aws batch describe-jobs --jobs $job_id --query 'jobs[0].status' --output text)
# if [ "$status" = "SUCCEEDED" ]; then
# echo "Job completed successfully"
# break
# elif [ "$status" = "FAILED" ]; then
# echo "Job failed"
# exit 1
# else
# echo "Job is still running. Current status: $status"
# sleep 30
# fi
# done

- name: Get Review Result from S3
id: get-review
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
# env:
# PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
aws s3 cp s3://llm-code-review-test/review_result/result_${PR_NUMBER}.json result.json
aws s3 cp s3://llm-code-review-test/review_result/result_1.json result.json
echo "review_result=$(cat result.json)" >> $GITHUB_OUTPUT
- name: Comment PR
Expand Down

0 comments on commit 7dd38ae

Please sign in to comment.