Skip to content

Memory Optimization - Refactor TWCC (#1934) #1324

Memory Optimization - Refactor TWCC (#1934)

Memory Optimization - Refactor TWCC (#1934) #1324

Workflow file for this run

name: PR Description Check
on:
pull_request:
branches:
- develop
- main
types:
- opened
- synchronize
- reopened
- edited
jobs:
check-description:
runs-on: macos-latest
steps:
- name: Install GitHub CLI
run: |
brew install gh
- name: Check PR Description
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pr_link="https://github.com/${GITHUB_REPOSITORY}/pull/${{ github.event.pull_request.number }}"
echo "$pr_link"
pr_description=$(gh pr view $pr_link --json body -q ".body")
if [ -z "$pr_description" ]; then
echo "Failed to fetch the PR description"
exit 1
fi
# Define minimum character count for each section
MIN_CHARS=10
# Extract contents
what_changed=$(echo "$pr_description" | sed -n -e '/\*What was changed?\*/,/\*Why was it changed?\*/p' | sed '$d' | sed '1d')
why_changed=$(echo "$pr_description" | sed -n -e '/\*Why was it changed?\*/,/\*How was it changed?\*/p' | sed '$d' | sed '1d')
how_changed=$(echo "$pr_description" | sed -n -e '/\*How was it changed?\*/,/\*What testing was done for the changes?\*/p' | sed '$d' | sed '1d')
testing_done=$(echo "$pr_description" | sed -n -e '/\*What testing was done for the changes?\*/,/By submitting this pull request/p' | sed '$d' | sed '1d')
error_occurred=0
if [[ ${#what_changed} -lt $MIN_CHARS ]]; then
echo "PR description for what changed section is either missing or too short. Required: ${MIN_CHARS}, Current: ${what_changed}"
error_occurred=1
fi
if [[ ${#why_changed} -lt $MIN_CHARS ]]; then
echo "PR description for why it changed section is either missing or too short. Required: ${MIN_CHARS}, Current: ${why_changed}"
error_occurred=1
fi
if [[ ${#how_changed} -lt $MIN_CHARS ]]; then
echo "PR description for how was it changed section is either missing or too short. Required: ${MIN_CHARS}, Current: ${how_changed}"
error_occurred=1
fi
if [[ ${#testing_done} -lt $MIN_CHARS ]]; then
echo "PR description for testing section are either missing or too short. Required: ${MIN_CHARS}, Current: ${testing_done}"
error_occurred=1
fi
if [[ $error_occurred -eq 1 ]]; then
exit 1
fi