feature/IVYPORTAL-16678-SPIKE-Setup-Linter #16
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 the entire codebase | |
# Enable specific linters | |
VALIDATE_JAVA: true | |
VALIDATE_JAVASCRIPT_ES: true | |
VALIDATE_JSON: true | |
VALIDATE_YAML: true | |
VALIDATE_XML: true | |
VALIDATE_CSS: true | |
# Add linter configurations | |
JAVA_FILE_NAME: checkstyle.xml | |
JAVASCRIPT_ES_CONFIG_FILE: .eslintrc.json | |
# Debug and output settings | |
LOG_LEVEL: DEBUG | |
LOG_FILE: true | |
REPORT_OUTPUT: true | |
CREATE_LOG_FILE: true | |
OUTPUT_FOLDER: /tmp/lint-results | |
OUTPUT_DETAILS: detailed | |
OUTPUT_FORMAT: text | |
- name: Process Linter Results | |
if: always() | |
run: | | |
# Create results directory | |
mkdir -p /tmp/lint-results | |
# 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 | |
# First try direct file | |
if [ -f "/tmp/lint-results/super-linter.log" ]; then | |
LOG_FILE="/tmp/lint-results/super-linter.log" | |
else | |
# Try to find in specific directories with proper permissions | |
LOG_FILE=$(find /tmp/lint-results /github/workspace -name "super-linter.log" 2>/dev/null | head -1) | |
fi | |
if [ -n "$LOG_FILE" ]; then | |
echo "Found log file: $LOG_FILE" | |
# 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 "./linter-report/linter.log" ] && grep -E "ERROR" ./linter-report/linter.log > /dev/null; then | |
exit 1 | |
fi |