Skip to content

Monkey Catch Food

Monkey Catch Food #87

name: Plagiarism Checker
on:
pull_request:
paths:
- "games/**/*.js"
jobs:
plagiarism-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Compare50 && beautifulsoup4
run: pip install compare50 beautifulsoup4
- name: Get list of changed files
id: changed-files
run: |
echo "Pull Request Base SHA: ${{ github.event.pull_request.base.sha }}"
echo "Pull Request Head SHA: ${{ github.event.pull_request.head.sha }}"
echo "Running git diff..."
git diff --name-only --diff-filter=AM --find-renames --find-copies ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
echo "Filtering JS files in games/ directory..."
js_files=$(git diff --name-only --diff-filter=AM --find-renames --find-copies ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | grep 'games/.*\.js$' | xargs)
echo "Found JS files: $js_files"
if [ -z "$js_files" ]; then
echo "No JavaScript files found in the changes."
else
echo "FILES=$js_files" >> $GITHUB_ENV
fi
- name: Run Plagiarism Detection Script
if: env.FILES != ''
run: python .github/scripts/plagiarism_check.py ${{ env.FILES }} games output_dir saved_dir
- name: Extract and Display Similarity Percentages
run: python .github/scripts/extract_percentages.py saved_dir/
id: extract-percentages
- name: Upload Compare50 Results as Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: compare50-results
path: saved_dir/
- name: Save PR number to file
run: echo ${{ github.event.pull_request.number }} > pr_number.txt
- name: Upload PR Number as Artifact
uses: actions/upload-artifact@v4
with:
name: pr-number
path: pr_number.txt
- name: Upload Plagiarism Report as Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: plagiarism-report
path: plagiarism-report.md
- name: Check for High Plagiarism Percentages
if: steps.extract-percentages.outcome == 'failure'
run: echo "Plagiarism percentage over threshold detected."