feature/IVYPORTAL-16678-SPIKE-Setup-Linter #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Super-Linter | |
on: | |
push: | |
branches: | |
- feature/IVYPORTAL-16678-SPIKE-Setup-Linter | |
pull_request: | |
branches: | |
- master | |
jobs: | |
lint: | |
name: Lint Code Base | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: read | |
statuses: write | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Create Report Directory | |
run: mkdir -p /tmp/lint-results | |
- name: Run Super-Linter | |
uses: super-linter/[email protected] | |
continue-on-error: true | |
id: linter | |
env: | |
DEFAULT_BRANCH: master | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
VALIDATE_ALL_CODEBASE: true | |
VALIDATE_JAVA: true | |
VALIDATE_JAVASCRIPT_ES: true | |
VALIDATE_JSON: true | |
VALIDATE_YAML: true | |
VALIDATE_XML: true | |
VALIDATE_CSS: true | |
LOG_LEVEL: DEBUG | |
LOG_FILE: true | |
REPORT_OUTPUT: true | |
CREATE_LOG_FILE: true | |
OUTPUT_FOLDER: /tmp/lint-results | |
OUTPUT_FORMAT: text | |
OUTPUT_DETAILS: detailed | |
- name: Debug Linter Output | |
if: always() | |
run: | | |
echo "=== Checking for linter output files ===" | |
find /tmp/lint-results -name "*lint*.log" -o -name "super-linter.log" || true | |
echo "=== Contents of /tmp/lint-results ===" | |
ls -la /tmp/lint-results || true | |
- name: Process Linter Results | |
if: always() | |
run: | | |
mkdir -p /tmp/lint-results | |
# Check directly in /tmp/lint-results | |
echo "=== Checking /tmp/lint-results ===" | |
LOG_FILE=$(find /tmp/lint-results -name "super-linter.log" 2>/dev/null | head -1) | |
if [ -n "$LOG_FILE" ]; then | |
echo "Found log file: $LOG_FILE" | |
# Initialize summary file | |
echo "### Super-Linter Results" > /tmp/lint-results/summary.md | |
echo "" >> /tmp/lint-results/summary.md | |
echo "| Language | Status | Details |" >> /tmp/lint-results/summary.md | |
echo "|----------|--------|----------|" >> /tmp/lint-results/summary.md | |
# Process the log file | |
while IFS= read -r line; do | |
if echo "$line" | grep -q ".*Linter:.*status:.*"; then | |
LINTER=$(echo "$line" | sed -n 's/.*Linter:\([^,]*\).*/\1/p') | |
STATUS=$(echo "$line" | sed -n 's/.*status:\([^,]*\).*/\1/p') | |
DETAILS=$(echo "$line" | sed -n 's/.*errors:\([^|]*\).*/\1/p' || echo "No details") | |
echo "| $LINTER | $STATUS | $DETAILS |" >> /tmp/lint-results/summary.md | |
fi | |
echo "$line" >> /tmp/lint-results/linter.log | |
done < "$LOG_FILE" | |
else | |
echo "No linter log file found" | |
echo "| No linting results found | - | - |" >> /tmp/lint-results/summary.md | |
fi | |
# Ensure we have a linter.log file even if empty | |
touch /tmp/lint-results/linter.log | |
- name: Upload Linter Report | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linter-report | |
path: | | |
/tmp/lint-results/linter.log | |
/tmp/lint-results/summary.md | |
retention-days: 1 | |
- name: Generate Summary | |
if: always() | |
run: | | |
if [ -f "/tmp/lint-results/summary.md" ]; then | |
cat /tmp/lint-results/summary.md > $GITHUB_STEP_SUMMARY | |
if [ -f "/tmp/lint-results/linter.log" ]; then | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "### Detailed Errors" >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
grep -E "ERROR:|WARNING:" /tmp/lint-results/linter.log >> $GITHUB_STEP_SUMMARY || true | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
fi | |
else | |
echo "### No Linter Results Available" > $GITHUB_STEP_SUMMARY | |
fi | |
- name: Check Linter Status | |
if: always() | |
run: | | |
if [ -f "/tmp/lint-results/linter.log" ] && grep -E "ERROR" /tmp/lint-results/linter.log > /dev/null; then | |
exit 1 | |
fi |