Skip to content

tasneem

tasneem #41

name: Score Submission
on:
pull_request_target:
paths:
- "submissions/**"
permissions:
contents: write
jobs:
score:
runs-on: ubuntu-latest
steps:
# Checkout the PR branch
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout PR code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check token exists
run: |
if [ -z "${{ secrets.PRIVATE_REPO_TOKEN }}" ]; then
echo "TOKEN IS EMPTY ❌"
exit 1
else
echo "TOKEN EXISTS ✅"
fi
# Checkout private evaluation repo
- name: Checkout private evaluation repo
uses: actions/checkout@v4
with:
repository: El-Ikram/Help_repo
token: ${{ secrets.PRIVATE_REPO_TOKEN }}
path: private_eval
- name: Debug private repo
run: |
echo "Listing private_eval:"
ls -R private_eval
# Setup Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
# Install dependencies
- name: Install dependencies
run: pip install -r requirements.txt
# List repo structure for debugging
- name: Debug repo structure
run: |
echo "Listing all files recursively:"
ls -R
# Find all .enc files recursively
- name: Find submission files
id: files
run: |
FILES=$(find submissions -type f -name "*.enc")
echo "All .enc files found:"
echo "$FILES"
FIRST_FILE=$(echo "$FILES" | head -n 1)
echo "First file to process: $FIRST_FILE"
echo "file=$FIRST_FILE" >> $GITHUB_OUTPUT
# Check submission file exists
- name: Check submission file
run: |
if [ -z "${{ steps.files.outputs.file }}" ]; then
echo "ERROR: No .enc submission file found in submissions/"
exit 1
fi
echo "Submission file exists: ${{ steps.files.outputs.file }}"
# Check that private key secret is set
- name: Check private key secret
run: |
if [ -z "$SUBMISSION_PRIVATE_KEY" ]; then
echo "ERROR: SUBMISSION_PRIVATE_KEY is not set!"
exit 1
fi
echo "Private key secret is set."
env:
SUBMISSION_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
# Decrypt submission
- name: Decrypt submission
env:
SUBMISSION_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
run: |
python encryption/decrypt.py "${{ steps.files.outputs.file }}"
# Evaluate submission
# - name: Evaluate submission
# id: eval
# run: |
# CSV_FILE="${{ steps.files.outputs.file }}"
# CSV_FILE="${CSV_FILE%.enc}.csv"
# SCORE=$(python competition/evaluate.py \
# "$CSV_FILE" \
# private_eval/test_labels.csv | grep SCORE | cut -d "=" -f2)
# echo "score=$SCORE" >> $GITHUB_OUTPUT
# Append to leaderboard
# - name: Append to leaderboard
# run: |
# echo "${{ github.actor }},${{ steps.eval.outputs.score }},$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> docs/leaderboard.csv
# Evaluate submission
- name: Evaluate submission
id: eval
run: |
CSV_FILE="${{ steps.files.outputs.file }}"
CSV_FILE="${CSV_FILE%.enc}.csv"
echo "Running evaluation..."
OUTPUT=$(python competition/evaluate.py \
"$CSV_FILE" \
private_eval/test_target_labels.csv)
echo "===== Evaluation Output ====="
echo "$OUTPUT"
echo "============================="
# Extract SCORE safely
SCORE=$(echo "$OUTPUT" | sed -n 's/^SCORE=//p')
echo "Extracted SCORE: $SCORE"
# Fail if score is empty
if [ -z "$SCORE" ]; then
echo "ERROR: Score extraction failed!"
exit 1
fi
echo "score=$SCORE" >> $GITHUB_OUTPUT
# Commit leaderboard
- name: Commit leaderboard
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Always start from latest main
git fetch origin main
git checkout main
git reset --hard origin/main
# Now apply your change
echo "${{ github.actor }},${{ steps.eval.outputs.score }},$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> docs/leaderboard.csv
git add docs/leaderboard.csv
git commit -m "Leaderboard update for ${{ github.actor }}" || exit 0
git push origin main