Skip to content

Commit

Permalink
feat: initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Apr 28, 2024
1 parent d6ba80f commit 50be3ad
Show file tree
Hide file tree
Showing 8 changed files with 571 additions and 2 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
# lint all markdown files

name: "CI"

on:
push:
branches:
- master
pull_request:
branches:
- master
types:
- opened
- synchronize
- reopened

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install markdownlint-cli
run: |
npm install -g markdownlint-cli
- name: Lint markdown files
run: |
markdownlint \
-f \
-o markdownlint_report.log \
'**/*.md'
- name: Print summary
if: failure()
run: |
echo "### Linting report:" >> $GITHUB_STEP_SUMMARY
cat markdownlint_report.log >> $GITHUB_STEP_SUMMARY
echo "### Suggested changes:" >> $GITHUB_STEP_SUMMARY
echo '```diff' >> $GITHUB_STEP_SUMMARY
echo "$(git diff)" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Additional checks
if: always()
run: |
exit_code=0
# find invalid file names
for file in $(find ./commands -type f -name '*.md'); do
filename=$(basename "$file")
if [[ $filename != 'body.md' && $filename != 'footer.md' ]]; then
echo "Invalid file $file. Only body.md and footer.md are allowed" >> $GITHUB_STEP_SUMMARY
exit_code=1
fi
done
# check character count
for file in $(find ./commands -type f \( -name 'body.md' -o -name 'footer.md' \)); do
echo "Checking $file"
char_count=$(wc -c <"$file")
echo "Character count: $char_count"
filename=$(basename "$file")
echo "Filename: $filename"
if [[ $filename == 'body.md' && $char_count -gt 4096 ]]; then
echo "$file exceeds the 4096 character limit" >> $GITHUB_STEP_SUMMARY
exit_code=1
elif [[ $filename == 'footer.md' && $char_count -gt 2048 ]]; then
echo "$file exceeds the 2048 character limit"
exit_code=1
fi
echo "Exit code after checking character count: $exit_code"
if [[ $filename == 'body.md' ]]; then
dir=$(dirname "$file")
if [[ -f "$dir/footer.md" ]]; then
footer_char_count=$(wc -c <"$dir/footer.md")
total_char_count=$((char_count + footer_char_count))
if [[ $total_char_count -gt 6000 ]]; then
echo "The combined character count of $file and $dir/footer.md exceeds the 6000 character limit" \
>> $GITHUB_STEP_SUMMARY
exit_code=1
fi
fi
fi
done
exit $exit_code
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ignore JetBrains IDE files
.idea/
Loading

0 comments on commit 50be3ad

Please sign in to comment.