Skip to content

Commit 999264b

Browse files
feat: initial version (#5)
1 parent d6ba80f commit 999264b

File tree

6 files changed

+444
-2
lines changed

6 files changed

+444
-2
lines changed

.github/workflows/ci.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
# lint all markdown files
3+
4+
name: "CI"
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
pull_request:
11+
branches:
12+
- master
13+
types:
14+
- opened
15+
- synchronize
16+
- reopened
17+
18+
concurrency:
19+
group: "${{ github.workflow }}-${{ github.ref }}"
20+
cancel-in-progress: true
21+
22+
jobs:
23+
validate:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Install markdownlint-cli
30+
run: |
31+
npm install -g markdownlint-cli
32+
33+
- name: Lint markdown files
34+
run: |
35+
markdownlint \
36+
-f \
37+
-o markdownlint_report.log \
38+
'**/*.md'
39+
40+
- name: Print summary
41+
if: failure()
42+
run: |
43+
echo "### Linting report:" >> $GITHUB_STEP_SUMMARY
44+
cat markdownlint_report.log >> $GITHUB_STEP_SUMMARY
45+
46+
echo "### Suggested changes:" >> $GITHUB_STEP_SUMMARY
47+
echo '```diff' >> $GITHUB_STEP_SUMMARY
48+
echo "$(git diff)" >> $GITHUB_STEP_SUMMARY
49+
echo '```' >> $GITHUB_STEP_SUMMARY
50+
51+
- name: Additional checks
52+
if: always()
53+
run: |
54+
exit_code=0
55+
56+
# find invalid file names
57+
for file in $(find ./commands -type f -name '*.md'); do
58+
filename=$(basename "$file")
59+
if [[ $filename != 'body.md' && $filename != 'footer.md' ]]; then
60+
echo "Invalid file $file. Only body.md and footer.md are allowed" >> $GITHUB_STEP_SUMMARY
61+
exit_code=1
62+
fi
63+
done
64+
65+
# check character count
66+
for file in $(find ./commands -type f \( -name 'body.md' -o -name 'footer.md' \)); do
67+
echo "Checking $file"
68+
char_count=$(wc -c <"$file")
69+
echo "Character count: $char_count"
70+
filename=$(basename "$file")
71+
echo "Filename: $filename"
72+
if [[ $filename == 'body.md' && $char_count -gt 4096 ]]; then
73+
echo "$file exceeds the 4096 character limit" >> $GITHUB_STEP_SUMMARY
74+
exit_code=1
75+
elif [[ $filename == 'footer.md' && $char_count -gt 2048 ]]; then
76+
echo "$file exceeds the 2048 character limit"
77+
exit_code=1
78+
fi
79+
if [[ $filename == 'body.md' ]]; then
80+
dir=$(dirname "$file")
81+
if [[ -f "$dir/footer.md" ]]; then
82+
footer_char_count=$(wc -c <"$dir/footer.md")
83+
total_char_count=$((char_count + footer_char_count))
84+
if [[ $total_char_count -gt 6000 ]]; then
85+
echo "The combined character count of $file and $dir/footer.md exceeds the 6000 character limit" \
86+
>> $GITHUB_STEP_SUMMARY
87+
exit_code=1
88+
fi
89+
fi
90+
fi
91+
done
92+
93+
exit $exit_code

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ignore JetBrains IDE files
2+
.idea/

0 commit comments

Comments
 (0)