Skip to content

add casting mechanics to skills; implement cast time handling and vis… #131

add casting mechanics to skills; implement cast time handling and vis…

add casting mechanics to skills; implement cast time handling and vis… #131

Workflow file for this run

name: Scala CI with Coverage
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Check out main and run tests
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'sbt'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install npm dependencies (jsdom for ScalaJS tests)
run: npm install
- name: Install sbt
run: |
curl -L https://github.com/sbt/sbt/releases/download/v1.12.1/sbt-1.12.1.tgz | tar xz
echo "$(pwd)/sbt/bin" >> $GITHUB_PATH
- name: Run tests with coverage
run: ENABLE_COVERAGE=true sbt clean coverage test coverageReport
- name: Count Lines of Code
run: |
chmod +x scripts/count-loc.sh
./scripts/count-loc.sh
- name: Parse coverage percentage
id: coverage
run: |
# Extract statement counts from JVM project (includes shared code)
JVM_COVERED=$(grep -oP 'statements-invoked="\K[0-9]+' jvm/target/scala-*/scoverage-report/scoverage.xml | head -1)
JVM_TOTAL=$(grep -oP 'statement-count="\K[0-9]+' jvm/target/scala-*/scoverage-report/scoverage.xml | head -1)
# Calculate coverage percentage
COVERAGE=$(echo "scale=2; $JVM_COVERED * 100 / $JVM_TOTAL" | bc)
echo "JVM Coverage (includes shared code): $JVM_COVERED/$JVM_TOTAL"
echo "Coverage: $COVERAGE%"
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
# Step 2: Overwrite gh-pages with main + coverage report
- name: Deploy Coverage Report to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
# Create a fresh gh-pages branch based on the latest main
git checkout --orphan gh-pages
git reset --hard
# Copy the coverage report from JVM project (includes shared code)
mkdir -p coverage
cp -r jvm/target/scala-*/scoverage-report/* coverage/
# Create a simple index.html wrapper for the coverage report
cat > coverage/coverage-index.html << EOF
<!DOCTYPE html>
<html>
<head>
<title>Project Metrics - Cascade</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; background: #f5f5f5; }
h1 { color: #333; }
h2 { color: #555; margin-top: 30px; }
.metrics-container { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin: 20px 0; }
.metric-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #eee; }
.metric-row:last-child { border-bottom: none; }
.metric-label { color: #666; }
.metric-value { font-weight: bold; color: #333; }
.metric-total { background: #f0f0f0; margin-top: 10px; padding: 10px; border-radius: 4px; }
.coverage-link { margin: 20px 0; }
.coverage-link a { font-size: 18px; color: #0366d6; text-decoration: none; }
.coverage-link a:hover { text-decoration: underline; }
.back-link { margin-top: 30px; }
.back-link a { color: #0366d6; text-decoration: none; }
.back-link a:hover { text-decoration: underline; }
.badges { margin: 20px 0; }
.badges img { margin-right: 10px; }
</style>
</head>
<body>
<h1>Cascade Project Metrics</h1>
<div class="badges">
<img src="coverage-badge.svg" alt="Coverage Badge">
<img src="loc-badge.svg" alt="Lines of Code Badge">
</div>
<div class="metrics-container">
<h2>Code Coverage</h2>
<div class="metric-row">
<span class="metric-label">Overall Coverage:</span>
<span class="metric-value">${COVERAGE}%</span>
</div>
<p style="color: #666; font-size: 14px;">Includes JVM-specific and shared code.</p>
<div class="coverage-link">
<a href="index.html">→ View Detailed Coverage Report</a>
</div>
</div>
<div class="metrics-container">
<h2>Lines of Code</h2>
<div class="metric-row">
<span class="metric-label">Scala (Application):</span>
<span class="metric-value">${LOC_SCALA_APP} lines</span>
</div>
<div class="metric-row">
<span class="metric-label">Scala (Tests):</span>
<span class="metric-value">${LOC_SCALA_TEST} lines</span>
</div>
<div class="metric-row">
<span class="metric-label">HTML:</span>
<span class="metric-value">${LOC_HTML} lines</span>
</div>
<div class="metric-row">
<span class="metric-label">CSS:</span>
<span class="metric-value">${LOC_CSS} lines</span>
</div>
<div class="metric-row">
<span class="metric-label">Build (SBT):</span>
<span class="metric-value">${LOC_BUILD} lines</span>
</div>
<div class="metric-row metric-total">
<span class="metric-label"><strong>Total:</strong></span>
<span class="metric-value">${LOC_TOTAL} lines</span>
</div>
</div>
<div class="back-link">
<a href="https://github.com/epic-64/cascade">← Back to Source Code</a>
</div>
</body>
</html>
EOF
# Generate badges as SVG
COVERAGE_BADGE_URL="https://img.shields.io/badge/coverage-${COVERAGE}%25-brightgreen.svg"
curl -o coverage/coverage-badge.svg "$COVERAGE_BADGE_URL"
LOC_BADGE_URL="https://img.shields.io/badge/lines%20of%20code-${LOC_TOTAL}-blue.svg"
curl -o coverage/loc-badge.svg "$LOC_BADGE_URL"
# Clean up unnecessary files in target folder
rm -rf target jvm/target shared/target js/target
# Commit and force-push to gh-pages
git add coverage/
git commit -m "Update gh-pages with latest coverage report and badge"
git push --force https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages