Add license check task for CI · Entire
Add license check task for CI
093d893→main·
Soph·3mo ago·2 files·+94 added/-0 removed
Adds mise lint:licenses task and .allowed-licenses baseline, matching the CLI repo's license check pattern. Required by the shared entireio/shared license-check-reusable workflow.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Sessions
52e0c0e2ab5eView transcript
Changes
2
- A.allowed-licenses+10
- mise-tasks/lint
Allowed licenses for git-sync
One license type per line
Comments start with
MIT BSD-2-Clause BSD-3-Clause Apache-2.0 MPL-2.0 CC0-1.0
#!/bin/bash
#MISE description="Check dependency licenses"
set -e
# Colors for output
RED='\033[0;31m'\
GREEN='\033[0;32m'\
YELLOW='\033[1;33m'\
NC='\033[0m' # No Color\
\
echo "Checking dependency licenses..."\
\
# Install go-licenses if not available\
if ! command -v go-licenses &> /dev/null; then\
echo "Installing go-licenses tool..."\
go install github.com/google/go-licenses@latest\
GOPATH=$(go env GOPATH)\
export PATH="$GOPATH/bin:$PATH"\
fi\
\
# Load allowed licenses\
ALLOWED_LICENSES_FILE=".allowed-licenses"\
if [ ! -f "$ALLOWED_LICENSES_FILE" ]; then\
echo -e "${RED}ERROR: .allowed-licenses file not found${NC}"\
exit 1\
fi\
\
# Read allowed licenses into array (skip comments and empty lines)\
ALLOWED_LICENSES=()\
while IFS= read -r line; do\
# Skip comments and empty lines\
if [[ ! "$line" =~ ^[[:space:]]*# ]] && [[ -n "$line" ]]; then\
ALLOWED_LICENSES+=("$line")\
fi\
done < "$ALLOWED_LICENSES_FILE"\
\
echo "Allowed licenses: ${ALLOWED_LICENSES[*]}"\
echo ""\
\
# Get licenses from dependencies\
TEMP_FILE=$(mktemp)\
# shellcheck disable=SC2312\
go-licenses csv ./cmd/git-sync 2>/dev/null | sort | uniq > "$TEMP_FILE"\
\
# Check each dependency\
VIOLATIONS=()\
while IFS=',' read -r package _url license; do\
# Skip internal packages\
if [[ "$package" == github.com/entirehq/git-sync/* ]]; then\
continue\
fi\
\
# Check if license is allowed\
ALLOWED=false\
for allowed in "${ALLOWED_LICENSES[@]}"; do\
if [ "$license" == "$allowed" ]; then\
ALLOWED=true\
break\
fi\
done\
\
if [ "$ALLOWED" = false ]; then\
VIOLATIONS+=("$package,$license")\
fi\
done < "$TEMP_FILE"\
\
# Report results\
if [ ${#VIOLATIONS[@]} -eq 0 ]; then\
echo -e "${GREEN}✓ All dependency licenses are allowed${NC}"\
rm "$TEMP_FILE"\
exit 0\
else\
echo -e "${RED}✗ Found ${#VIOLATIONS[@]} dependency(ies) with non-allowed licenses:${NC}"\
echo ""\
for violation in "${VIOLATIONS[@]}"; do\
IFS=',' read -r pkg lic <<< "$violation"\
echo -e "${YELLOW} - $pkg${NC}"\
echo -e " License: ${RED}$lic${NC}"\
done\
echo ""\
echo "If these licenses are acceptable, add them to .allowed-licenses"\
rm "$TEMP_FILE"\
exit 1\
fi
Amise-tasks/lint/licenses+84