-
Notifications
You must be signed in to change notification settings - Fork 48
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
feat: reduce the number of input parameters to action #88
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary by GPT-4
This commit removes several input options from the GitHub action and sets their default values directly in the env
section of the action. The removed input options are:
- GIT_COMMIT_HASH
- PR_NUMBER
- PR_TITLE
- REPOSITORY_NAME
- FULL_SUMMARY
- FILE_SUMMARY
- FILE_SUMMARY_FULL
- TEST_SUMMARY
- BUG_SUMMARY
- RISK_SUMMARY
- RISK_BREAKING
The default values for these options are now hardcoded in the env
section, and some of them are replaced with dynamic values from the GitHub context, such as github.event.pull_request.head.sha
, github.repository
, and github.event.pull_request.number
.
Additionally, this commit adds a step to checkout the repository using actions/checkout@v3
with a specified ref and fetch-depth.
Suggestions
Here are some suggestions for improving the changes in this PR:
- Remove unnecessary input variables and use GitHub context variables instead.
- Use the
actions/checkout@v3
action to fetch the pull request's head commit. - Set default values for summary options directly in the environment variables.
The updated action.yml
file would look like this:
name: 'GPT-3 Review'
description: 'Automatically generate a code review summary using GPT-3'
branding:
icon: 'eye'
color: 'gray-dark'
inputs:
GITHUB_TOKEN:
description: 'Derivative token for using the GitHub REST API'
required: true
OPENAI_API_KEY:
description: 'API key for OpenAI GPT-3'
required: true
OPENAI_ORG_KEY:
description: 'OpenAI Organization ID'
required: true
AZURE_OPENAI_API:
description: 'URL of custom Azure Open AI API'
required: false
AZURE_OPENAI_API_KEY:
description: 'Key of custom Azure Open AI API'
required: false
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install gpt-review
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y git-lfs python-dev libssl-dev libffi-dev build-essential python3-distutils python3-pip jq curl unzip git-lfs libcurl4-openssl-dev libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev liblzma-dev patchelf gettext cmake g++ pkg-config re2c bison autoconf-archive icu4c-data icu4c-doc icu4c-localedata icu4c-src icu4c-tests icu-config icu-docs icu-locales libc6-i386-cross libc6-x32-cross libc6-x32-dbg-cross libc6-x32-dbg-cross libc6-x32-dbg-cross libc6-x32-dbg-cross libc6-x32-dbg-cross libc6-x32-dbg-cross libc6-x32-dbg-cross libc6-x32-dbg-cross libc6-x32-dbg-cross libc6-x32-dbg-cross libc6-x32-dbg-cross libsctp1 libsctp1-dbgsym libsctp1-dbgsym libsctp1-dbgsym libsctp1-dbgsym libsctp1-dbgsym libsctp1-dbgsym libsctp1-dbgsym libsctp1-dbgsym libsctp1-dbgsym libsctp1-dbgsym lksctp-tools lksctp-tools-doc lksctp-tools-doc lksctp-tools-doc lksctp-tools-doc lksct...
pip install --upgrade pip setuptools wheel
- name : Run gpt-review on PR changes
shell : bash
run : |
python -m gpt_review \
--api_key $OPENAI_API_KEY \
--org_key $OPENAI_ORG_KEY \
--pr_title "$PR_TITLE" \
--link "$LINK" \
--git_commit_hash $GIT_COMMIT_HASH \
--full_summary $FULL_SUMMARY \
--file_summary $FILE_SUMMARY \
--test_summary $TEST_SUMMARY \
--bug_summary $BUG_SUMMARY \
--risk_summary $RISK_SUMMARY \
--risk_breaking $RISK_BREAKING \
--azure_openai_api_key "$AZURE_OPENAI_API_KEY" \
--azure_openai_api "$AZURE_OPENAI_API" \
--patch_pr_number "$PATCH_PR" \
--repository $PATCH_REPO
env:
ACTION_REF : "${{ github.action_ref || env.BRANCH }}"
GIT_COMMIT_HASH : "${{ github.event.pull_request.head.sha }}"
GITHUB_TOKEN : "${{ inputs.GITHUB_TOKEN }}"
LINK : "https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
OPENAI_API_KEY : "${{ inputs.OPENAI_API_KEY }}"
OPENAI_ORG_KEY : "${{ inputs.OPENAI_ORG_KEY }}"
PR_TITLE : "${{ github.event.pull_request.title }}"
BRANCH : "${{ env.BRANCH }}"
AZURE_OPENAI_API_KEY : "${{ inputs.AZURE_OPENAI_API_KEY || '' }}"
AZURE_OPENAI_API : "${{ inputs.AZURE_OPENAI_API || '' }}"
PATCH_PR : "${{ github.event.pull_request.number }}"
PATCH_REPO : "${{ github.repository }}"
# Set default values for summary options here.
FULL_SUMMARY = "true"
FILE_SUMMARY = "false"
TEST_SUMMARY = "false"
BUG_SUMMARY = "false"
RISK_SUMMARY = "false"
RISK_BREAKING = "false"
These changes simplify the action configuration and make it easier to maintain and understand.
Codecov Report
@@ Coverage Diff @@
## main #88 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 13 13
Lines 462 462
Branches 67 67
=========================================
Hits 462 462
Flags with carried forward coverage won't be shown. Click here to find out more. |
Description
Testing
Additional context