Some checks failed
Licence Check / Licence compatibility and copyright header verification (push) Failing after 56s
CI / Security audit (push) Successful in 1m7s
CI / Tests & coverage (push) Successful in 1m18s
Licence Check / Licence compatibility and copyright header verification (pull_request) Failing after 39s
CI / Security audit (pull_request) Successful in 1m13s
CI / Tests & coverage (pull_request) Successful in 1m23s
84 lines
2.6 KiB
YAML
84 lines
2.6 KiB
YAML
name: Licence Check
|
|
|
|
on:
|
|
push:
|
|
branches: ["**", "!main", "!release/**"]
|
|
paths:
|
|
- "package.json"
|
|
- "package-lock.json"
|
|
- ".gitea/workflows/licence-check.yml"
|
|
- "**/*.js"
|
|
- "**/*.ts"
|
|
- "**/*.jsx"
|
|
- "**/*.tsx"
|
|
pull_request:
|
|
branches: ["**", "!main", "!release/**"]
|
|
paths:
|
|
- "package.json"
|
|
- "package-lock.json"
|
|
- ".gitea/workflows/licence-check.yml"
|
|
- "**/*.js"
|
|
- "**/*.ts"
|
|
- "**/*.jsx"
|
|
- "**/*.tsx"
|
|
|
|
jobs:
|
|
licence-check:
|
|
name: Licence compatibility and copyright header verification
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
|
|
- name: Install production dependencies
|
|
run: npm ci --omit=dev
|
|
|
|
- name: Check licence compatibility
|
|
run: |
|
|
npx --yes license-checker --production \
|
|
--onlyAllow "MIT;ISC;MIT-0;BSD-2-Clause;BSD-3-Clause;Apache-2.0;CC0-1.0;BlueOak-1.0.0" \
|
|
--excludePrivatePackages \
|
|
&& echo "All production dependency licences are compatible with MIT."
|
|
|
|
- name: Check copyright headers in source files
|
|
run: |
|
|
#!/bin/bash
|
|
set -e
|
|
|
|
# Find all source files, excluding build artifacts and node_modules
|
|
SOURCE_FILES=$(find . -type f \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" \) \
|
|
! -path "./node_modules/*" \
|
|
! -path "./.git/*" \
|
|
! -path "./dist/*" \
|
|
! -path "./build/*" \
|
|
! -path "./.gitea/*")
|
|
|
|
MISSING_HEADER=0
|
|
|
|
# Check each file for MIT-compliant copyright header
|
|
while IFS= read -r file; do
|
|
if [ -z "$file" ]; then
|
|
continue
|
|
fi
|
|
|
|
# Check if file starts with a copyright header containing: Copyright, year (4 digits), name, and MIT License
|
|
if ! head -n 5 "$file" | grep -qiE "Copyright.*[0-9]{4}.*MIT"; then
|
|
echo "❌ Missing MIT-compliant copyright header in: $file"
|
|
echo " Required format: // Copyright (c) YYYY Name. MIT License."
|
|
MISSING_HEADER=$((MISSING_HEADER + 1))
|
|
fi
|
|
done <<< "$SOURCE_FILES"
|
|
|
|
if [ $MISSING_HEADER -gt 0 ]; then
|
|
echo ""
|
|
echo "⚠️ Found $MISSING_HEADER file(s) with missing or non-compliant copyright headers."
|
|
exit 1
|
|
else
|
|
echo "✅ All source files have MIT-compliant copyright headers."
|
|
fi
|