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

git-action 적용 #162

Merged
merged 13 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: learnsmate-service

permissions:
contents: read
pull-requests: write

on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- "main"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'corretto'

- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: LearnsMate
shell: bash

- name: Build with Gradle
run: ./gradlew clean build -x test
working-directory: LearnsMate
shell: bash

- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00"

- name: Show Current Time
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}"
shell: bash

- name: ChatGPT codeReviewer
uses: anc95/ChatGPT-CodeReview@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

# Optional
LANGUAGE: Korean
OPENAI_API_ENDPOINT: https://api.openai.com/v1
MODEL: gpt-4o # https://platform.openai.com/docs/models
PROMPT: 코드 변경 내용을 검토하고 오류 또는 개선점을 찾아서 한글로 작성해주세요.
top_p: 1 # https://platform.openai.com/docs/api-reference/chat/create#chat/create-top_p
temperature: 1 # https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature
max_tokens: 10000
MAX_PATCH_LENGTH: 1000
Copy link

Choose a reason for hiding this comment

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

Code Review:

  1. Permissions:

    • Ensure that the permissions granted align with security and access control policies.
  2. Event Triggers:

    • Events like push trigger on the "main" branch. Confirm if this is the intended behavior.
  3. Steps:

    • Consider validating the Gradle build output for errors or warnings, enhancing the build step's robustness.
    • Confirm that the JDK version and distribution specified are appropriate for the project's requirements.
  4. Time Handling:

    • Verify that the time format and UTC offset in use meet the project's needs accurately.
  5. Secrets Handling:

    • Check if the GitHub token and OpenAI API key are appropriately secured and used.
  6. Language Model Usage:

    • The use of the ChatGPT model seems reasonable for code reviewing. Ensure that sensitive information isn't inadvertently shared in the review.
  7. Configuration Options:

    • Review and perhaps provide defaults where optional configurations like language, API endpoints, models, etc., are set.
  8. Overall:

    • Add error handling to actions where relevant.
    • Document the purpose of this script and its outcomes clearly for future reference.
    • Test the entire workflow thoroughly to discover any unforeseen issues.

If you have any specific concerns or if there are particular functionalities you want to ensure work correctly, feel free to ask for more detailed suggestions.

7 changes: 1 addition & 6 deletions LearnsMate/.gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
HELP.md
.gradle
gradlew.bat
gradlew
.gradle
settings.gradle
.gitattributes
.gradle/
gradle/
.idea/
build/
.idea/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
Expand All @@ -27,7 +23,7 @@ bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
*.yml
application-test.yml
.idea
*.json
*.iws
Copy link

Choose a reason for hiding this comment

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

Code Review

  1. Risk Assessment:

    • Risk: Changing the exclusion from *.yml to application-test.yml in the IntelliJ IDEA configuration could potentially introduce problems if other YAML files need to be excluded from the version control.
  2. Improvement Suggestions:

    • Consideration: If the intention is only to exclude a specific application-test.yml file while ignoring all other .yml files, it's better to maintain the original wildcard exclusion *.yml and add an explicit exclusion for application-test.yml.
    • Consistency: Ensure consistency in naming and patterns across exclusion rules to improve readability and maintenance.
  3. Suggestion:

    ### IntelliJ IDEA ###
    *.yml
    !application-test.yml
    .idea/
    *.json
    *.iws
    
  4. Overall:

    • The provided patch may introduce potential risks due to the specificity of the exclusion rule for application-test.yml. Consider a more general approach for excluding specific YAML files while maintaining flexibility for future changes.

Final Patch with Suggested Changes

@@ -27,7 +27,7 @@ bin/
 !**/src/test/**/bin/
 
 ### IntelliJ IDEA ###
-*.yml
+!application-test.yml
 .idea/
 *.json
 *.iws

Always ensure to thoroughly test your version control setup after making such changes to prevent unexpected issues in your development workflow.

Expand All @@ -46,4 +42,3 @@ out/

### VS Code ###
.vscode/
/src/main/resources/application.yml
Copy link

Choose a reason for hiding this comment

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

Code Review and Suggestions:

  1. Redundant Entries:

    • Redundant entries like gradlew.bat, gradlew, and duplicate .gradle are listed in the patch. Ensure these are correctly omitted.
  2. Directory Structure:

    • The patch has exclusions for various build directories, which helps maintain a clean repository. Ensure these paths align with the project's structure.
  3. Filename Constraints:

    • Addition of application-test.yml implies a new file to be included while excluding *.yml. Verify if this is intentional given the context of the project.
  4. Exclusion Justification:

    • Clarify the reasons behind excluding application-test.yml and /src/main/resources/application.yml from version control. Double-check if they should indeed be omitted.
  5. IDE-Specific Configurations:

    • Ensure that IDE-specific configurations like VS Code settings are appropriately excluded or included based on project requirements.
  6. Directory References:

    • Check if the directory references align with the actual project structure and that no important directories or files are inadvertently excluded.
  7. Document Changes:

    • It's essential to document the rationale behind these changes, especially if they deviate from standard versions or if certain files are being handled uniquely.
  8. Review by Team:

    • It's advisable to have the team review these changes to ensure they align with the overall project needs and coding standards.

By addressing these points, you can enhance the quality and consistency of your codebase while mitigating any potential risks that might arise from inaccurate exclusions or inclusions.

Copy link

Choose a reason for hiding this comment

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

Code Review Comments:

  1. File Organization:

    • Ensure consistency in excluding build directories. Some exclusions for specific paths are mention in comments but not reflected in exclusion patterns. Double-check these to make sure they work as intended.
  2. IDE Settings:

    • Review exclusion/inclusion of IDE settings files to ensure sensitive information is not leaked inadvertently.
    • Exclude sensitive files like .springBeans, .apt_generated.
  3. Gradle-related Files:

    • Fine, exclude unnecessary gradle files explicitly.
  4. Version Control Files:

    • Properly excluding Git, Gradle wrapper, and IDE related files from version control.
  5. Comments:

    • Consider removing commented-out sections or update them if they serve a purpose.
  6. Potential Additions:

    • Check for any other autogenerated files that should be excluded.
    • Include setup instructions or documentation files if necessary.
  7. Risk/Bug Concerns:

    • No glaring bugs, focus on file exclusions to avoid accidentally tracking sensitive data or generated artifacts.
  8. Improvement Suggestions:

    • Maintain a changelog file or versioning system for better code management.
    • Consistently format the document to enhance readability.

Overall, focus on maintaining a clean directory structure, ensure all necessary files are being tracked while avoiding tracking unnecessary files. Regularly review and update the exclusion/inclusion patterns as the project evolves.

Copy link

Choose a reason for hiding this comment

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

Code Review:

  1. File Structure:

    • Ensure consistency in ignoring files across platforms (.gitignore rules).
    • Consider maintaining a single standard for naming conventions (Gradle vs. gradle; IDEA vs. IntelliJ IDEA).
  2. Git Rules:

    • Verify if the rules excluding certain directories or types of files are correctly defined.
    • Double-check rules regarding excluded build artifacts and IDE-specific files.
  3. Build Artifacts:

    • Excluding build directories like build/ seems appropriate to avoid repository bloat.
    • Ensure that only necessary files are included while omitting binaries and build-specific content.
  4. IDE Configuration Files:

    • Review the rules for excluding IDE-specific files to prevent unnecessary commits and conflicts.
    • Confirm exclusion patterns for project metadata, cache files, and temporary files.
  5. Improvements:

    • Add comments or documentation to clarify the purpose behind specific rules.
    • Regularly update and revisit the .gitignore file to adapt to changing project requirements.
  6. Specific Suggestions:

    • Correct some rules like /src/main/resources/application.yml which are listed but not acted upon.
    • Minimize overlapping rules (e.g., *.iml is covered under both IntelliJ IDEA and general IDE settings).
    • Consistently use full directory paths when necessary.

Bug Risks:

  • Potential risks include accidentally committing sensitive data, ignoring critical configuration files, or failing to exclude build artifacts properly.
  • Overlooked rules may lead to unwanted files being tracked by version control, increasing repository size and causing conflicts.

Considering refinements according to these suggestions can improve maintainability, enhance team collaboration, and minimize potential risks associated with version control.

249 changes: 249 additions & 0 deletions LearnsMate/gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################

# Attempt to set APP_HOME

# Resolve links: $0 may be a link
app_path=$0

# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done

# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

warn () {
echo "$*"
} >&2

die () {
echo
echo "$*"
echo
exit 1
} >&2

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi

# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.

# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )

JAVACMD=$( cygpath --unix "$JAVACMD" )

# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#

eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'

exec "$JAVACMD" "$@"
Loading
Loading