feature/IVYPORTAL-16678-SPIKE-Setup-Linter #25
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: true | |
VALIDATE_JSON: true | |
VALIDATE_YAML: true | |
VALIDATE_XML: true | |
VALIDATE_CSS: true | |
VALIDATE_GITHUB_ACTIONS: true | |
VALIDATE_DOCKERFILE: true | |
LOG_LEVEL: INFO | |
LOG_FILE: super-linter.log | |
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 ${{ github.workspace }} -name "super-linter.log" || true | |
echo "=== Contents of ${{ github.workspace }} ===" | |
ls -la ${{ github.workspace }} || true | |
- name: Check Log File Existence | |
if: always() | |
run: | | |
LOG_FILE="${{ github.workspace }}/super-linter.log" | |
if [ -f "$LOG_FILE" ]; then | |
echo "Log file exists: $LOG_FILE" | |
else | |
echo "Log file does not exist: $LOG_FILE" | |
fi | |
- name: Change Log File Permissions | |
if: always() | |
run: | | |
LOG_FILE="${{ github.workspace }}/super-linter.log" | |
if [ -f "$LOG_FILE" ]; then | |
sudo chmod 644 "$LOG_FILE" | |
echo "Changed permissions for log file: $LOG_FILE" | |
fi | |
- name: Process Linter Results | |
if: always() | |
run: | | |
mkdir -p /tmp/lint-results | |
# Check directly in the workspace | |
echo "=== Checking ${{ github.workspace }} ===" | |
LOG_FILE="${{ github.workspace }}/super-linter.log" | |
if [ -f "$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 | |
cat /tmp/lint-results/linter.log >> $GITHUB_STEP_SUMMARY || echo "No errors found" | |
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 |