Improve list indentation validation error reporting (#137)

Refactors the workflow to export a concise error block with invalid list indentation details as an environment variable. Adds a new step to display the error block and fail the workflow if issues are found, improving clarity and output formatting.
This commit is contained in:
Ian Bassi
2026-01-19 11:27:44 -03:00
committed by GitHub
parent 248db79ece
commit af187bbca6

View File

@@ -16,6 +16,8 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
env:
ERROR_BLOCK: ''
steps:
- name: Checkout repository
uses: actions/checkout@v6
@@ -91,17 +93,17 @@ jobs:
}
if (failures.length) {
let errorMessage = 'Invalid list indentation found:\n\n';
failures.forEach(failure => {
errorMessage += `${failure.filePath}:${failure.line} - Indentation: ${failure.indentation} spaces (must be 0 or a multiple of 4)\n`;
errorMessage += ` "${failure.content}"\n\n`;
const lines = failures.map((failure) => {
return `${failure.filePath} line ${failure.line}: indentation is ${failure.indentation} spaces (must be 0 or a multiple of 4)`;
});
core.setFailed(errorMessage);
} else {
core.info(`Validated list indentation in ${filesToCheck.length} file(s). All valid.`);
const block = lines.join('\n');
core.exportVariable('ERROR_BLOCK', block);
return;
}
core.exportVariable('ERROR_BLOCK', '');
core.info(`Validated list indentation in ${filesToCheck.length} file(s). All valid.`);
function collectAllMarkdownFiles(relativeDir) {
const files = [];
const absoluteDir = relativeDir ? path.join(workspace, relativeDir) : workspace;
@@ -129,3 +131,10 @@ jobs:
return files;
}
- name: Show invalid list indentation
if: env.ERROR_BLOCK != ''
run: |
echo 'Invalid list indentation:'
printf "\`\`\`\n%s\n\`\`\`\n" "${{ env.ERROR_BLOCK }}"
exit 1