-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into test_priceinfo_mhlee_240124
- Loading branch information
Showing
71 changed files
with
2,863 additions
and
1,125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# This workflow will make a comment on the pull request | ||
# about the part where Korean was found. | ||
name: Post handler of korean checker | ||
on: | ||
workflow_run: | ||
workflows: ["Korean checker"] | ||
types: | ||
- completed | ||
|
||
env: | ||
ARTIFACT_NAME: results-to-check-korean | ||
FILE_KOREAN_CHECKING_RESULT: "korean-check-results.md" | ||
FILE_REPORT: "checking-report.md" | ||
|
||
jobs: | ||
make-comment-on-the-pr: | ||
name: Make a comment on the PR | ||
|
||
runs-on: ubuntu-latest | ||
if: > | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
# Permissions for the GITHUB_TOKEN | ||
# Ref. https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token | ||
permissions: | ||
# issues: write | ||
pull-requests: write | ||
actions: read | ||
|
||
steps: | ||
- name: Download results | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_NAME }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Display structure of downloaded files for debugging | ||
shell: bash | ||
run: ls -R | ||
|
||
- name: Make a report | ||
shell: bash | ||
run: | | ||
REPORT="${FILE_REPORT}" | ||
if [ -s "${FILE_KOREAN_CHECKING_RESULT}" ]; then | ||
echo "(DEBUG) Korean texts are detected." | ||
echo "**Could you please check and revise Korean texts?**" > $REPORT | ||
echo "Note - All output of print and log statements should be in English. :wink:" >> $REPORT | ||
echo "" >> $REPORT | ||
cat "${FILE_KOREAN_CHECKING_RESULT}" >> "$REPORT" | ||
else | ||
echo "(DEBUG) No Korean texts are detected." | ||
echo "Good news! All print and log statements are in English, as per our guidelines. :blush:" > $REPORT | ||
fi | ||
- name: Comment PR with results | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
// Read PR number | ||
const prNumberPath = path.join(process.env.GITHUB_WORKSPACE, 'pr-number.txt'); | ||
let prNumber = ''; | ||
if (fs.existsSync(prNumberPath)) { | ||
prNumber = fs.readFileSync(prNumberPath, 'utf8').trim(); | ||
} | ||
// Read results to check Korean | ||
const resultsPath = path.join(process.env.GITHUB_WORKSPACE, '${{env.FILE_REPORT}}'); | ||
if (fs.existsSync(resultsPath)) { | ||
const results = fs.readFileSync(resultsPath, 'utf8'); | ||
if (results.trim().length > 0 && prNumber.length > 0) { | ||
github.rest.issues.createComment({ | ||
issue_number: parseInt(prNumber, 10), | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: results | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
name: Korean checker | ||
|
||
# Controls/triggers when the action will run. | ||
on: | ||
pull_request: | ||
branches: | ||
- 'master' | ||
paths: | ||
- '**.go' | ||
|
||
# Environment variables | ||
env: | ||
OUTPUT_DIR: "./output" | ||
OUTPUT_FILE: "korean-check-results.md" | ||
|
||
jobs: | ||
check-if-Korean-is-included: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all branches and tags | ||
|
||
- name: Setup to check Korean and upload the results | ||
run: | | ||
# Make an output directory | ||
if [[ ! -e $OUTPUT_DIR ]]; then | ||
mkdir -p $OUTPUT_DIR | ||
elif [[ ! -d $OUTPUT_DIR ]]; then | ||
echo "$OUTPUT_DIR already exists but is not a directory" 1>&2 | ||
fi | ||
echo ${{ github.event.number }} > ${OUTPUT_DIR}/pr-number.txt | ||
- name: Check Korean in quotes | ||
id: check-korean | ||
run: | | ||
set -x | ||
##### DEBUG section, this will be removed later ########### | ||
ls -al | ||
git status | ||
git branch | ||
# Default environment variables | ||
BASE_BRANCH="origin/${{github.base_ref}}" # origin/master | ||
PR_BRANCH=${GITHUB_REF#refs/} # pull/xx/merge | ||
echo "Base branch: ${BASE_BRANCH}" | ||
echo "Extract branch: ${GITHUB_REF#refs/}" | ||
# `github` context information | ||
echo "(DEBUG) github.ref: ${{github.ref}}" | ||
echo "(DEBUG) github.head_ref: ${{github.head_ref}}" | ||
echo "(DEBUG) github.base_ref: ${{github.base_ref}}" | ||
##################################################### | ||
temp_output="temp.md" | ||
OUTPUT="${OUTPUT_DIR}/${OUTPUT_FILE}" | ||
# Get changed files in the PR | ||
files=$(git diff --name-only ${BASE_BRANCH}...${PR_BRANCH} | grep '\.go$') | ||
# Create a temp file | ||
echo "" > $temp_output | ||
# Process each changed file | ||
for file in $files; do | ||
found_korean=false | ||
# Extract changed lines | ||
changed_lines=$(git diff ${BASE_BRANCH}...${PR_BRANCH} -- $file | grep "^+") | ||
echo "(DEBUG) Changed lines in $file:" | ||
echo "$changed_lines" | ||
# Check Korean characters wrapped in quote (" ") | ||
korean_lines=$(echo "$changed_lines" | grep -n -P "\"([^\"]*[\x{AC00}-\x{D7A3}]+[^\"]*)\"" || true) | ||
# Check all Korean characters, such as Korean wrapped in quote, included in comments, and so on. | ||
# korean_lines=$(echo "$changed_lines" | grep -n -P "[\x{AC00}-\x{D7A3}]" || true) | ||
echo "(DEBUG) Korean lines in $file:" | ||
echo "$korean_lines" | ||
if [ -n "$korean_lines" ]; then | ||
echo "**$file**" >> $temp_output | ||
echo "\`\`\`diff" >> $temp_output | ||
echo "$korean_lines" | sed -e 's/^[+]\s*//' >> $temp_output | ||
echo "\`\`\`" >> $temp_output | ||
echo "" >> $temp_output | ||
fi | ||
done | ||
# Output the results to check if Korean exists | ||
# Check if the temp_output exists and has content | ||
if [ -s "$temp_output" ]; then | ||
# Trim before checking if the file has content | ||
trimmed_temp_outputs=$(cat "$temp_output" | xargs) | ||
echo "(DEBUG) Trimmed temp_output:" | ||
echo "$trimmed_temp_outputs" | ||
if [ -n "$trimmed_temp_outputs" ]; then | ||
echo "(DEBUG) Korean content detected." | ||
cat "$temp_output" > "$OUTPUT" | ||
# echo "KOREAN_EXISTS=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "(DEBUG) No Korean content detected." | ||
# echo "KOREAN_EXISTS=false" >> $GITHUB_OUTPUT | ||
fi | ||
fi | ||
- name: Upload Korean check results | ||
# if: steps.check-korean.outputs.KOREAN_EXISTS == 'true' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: results-to-check-korean | ||
path: ${{ env.OUTPUT_DIR }} | ||
|
||
# - name: Fail on Korean Content | ||
# if: steps.check-korean.outputs.KOREAN_EXISTS == 'true' | ||
# run: | | ||
# echo "Korean content detected. Failing the workflow on purpose." | ||
# exit 1 | ||
|
||
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | ||
# https://github.com/actions/upload-artifact | ||
# https://github.com/actions/download-artifact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.