103 lines
3.0 KiB
YAML
103 lines
3.0 KiB
YAML
name: License Compliance Check
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'package.json'
|
|
- 'pnpm-lock.yaml'
|
|
- 'frontend/package.json'
|
|
- 'main/package.json'
|
|
- 'scripts/generate-notices.js'
|
|
- '.github/workflows/license-compliance.yml'
|
|
- 'NOTICES'
|
|
push:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'package.json'
|
|
- 'pnpm-lock.yaml'
|
|
- 'frontend/package.json'
|
|
- 'main/package.json'
|
|
- 'scripts/generate-notices.js'
|
|
- '.github/workflows/license-compliance.yml'
|
|
- 'NOTICES'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
check-licenses:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22.15.1'
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Generate NOTICES file
|
|
run: pnpm run generate-notices
|
|
|
|
- name: Check if NOTICES file is up-to-date
|
|
run: |
|
|
# Check if NOTICES file exists
|
|
if [ ! -f "NOTICES" ]; then
|
|
echo "Error: NOTICES file was not generated"
|
|
exit 1
|
|
fi
|
|
|
|
# Generate a fresh NOTICES file to compare
|
|
cp NOTICES NOTICES.original
|
|
pnpm run generate-notices
|
|
|
|
# Compare the files
|
|
if ! diff -q NOTICES.original NOTICES > /dev/null; then
|
|
echo "::error::NOTICES file is out of date. Please run 'pnpm run generate-notices' and commit the changes."
|
|
echo ""
|
|
echo "Differences found:"
|
|
diff -u NOTICES.original NOTICES || true
|
|
exit 1
|
|
else
|
|
echo "✅ NOTICES file is up-to-date"
|
|
fi
|
|
|
|
echo "File size: $(ls -lh NOTICES | awk '{print $5}')"
|
|
echo "License count: $(grep -c "^Package:" NOTICES)"
|
|
|
|
- name: Check for problematic licenses
|
|
run: |
|
|
# Check for licenses that might require special attention
|
|
echo "Checking for copyleft licenses..."
|
|
|
|
# Common copyleft licenses to watch for
|
|
COPYLEFT_LICENSES="GPL|LGPL|AGPL|MPL|EPL|CDDL"
|
|
|
|
if grep -E -i "$COPYLEFT_LICENSES" NOTICES; then
|
|
echo "::warning::Found potential copyleft licenses. Please review the NOTICES file."
|
|
else
|
|
echo "No copyleft licenses found."
|
|
fi
|
|
|
|
# Check for missing licenses
|
|
echo ""
|
|
echo "Checking for missing licenses..."
|
|
MISSING=$(grep -B2 "No license found" NOTICES || true)
|
|
if [ -n "$MISSING" ]; then
|
|
echo "::warning::Some packages are missing license information:"
|
|
echo "$MISSING"
|
|
else
|
|
echo "All packages have license information."
|
|
fi
|
|
|
|
- name: Validate license compatibility
|
|
run: |
|
|
# Use our more sophisticated license compatibility check
|
|
chmod +x ./check-license-compatibility.sh
|
|
./check-license-compatibility.sh |