Skip to content

Commit feb2d05

Browse files
classabbyampthe-maldridge
authored andcommitted
res/ci: split CI steps into separate scripts
also various other improvements
1 parent efefdbf commit feb2d05

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

res/ci/check-summary.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
ERROR=0
44

5+
printf "\n\033[37;1m=> Checking SUMMARY.md\033[m\n"
6+
57
cd src/ || exit 2
68

79
# summary is the list of files taken from SUMMARY.md - unused for now
@@ -11,8 +13,8 @@ files="$( find . -type f -name '*.md' -not -name "SUMMARY.md" )"
1113

1214
for file in $files
1315
do
14-
if ! grep "$file" ./SUMMARY.md >/dev/null ; then
15-
printf "\033[31;1m=> $file not in SUMMARY\033[m\n"
16+
if ! grep -q "$file" ./SUMMARY.md ; then
17+
printf "::error title=Summary Lint,file=src/SUMMARY.md::$file not in SUMMARY.md\n"
1618
ERROR=1
1719
fi
1820
done

res/ci/format.sh

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
11
#!/bin/sh
22

3-
git config --global --add safe.directory "$PWD"
4-
5-
printf "\033[37;1m=> Checking links\033[m\n"
6-
RUST_LOG=linkcheck=debug mdbook-linkcheck -s
7-
LINKCHECK=$?
8-
9-
# Format them
103
printf "\n\033[37;1m=> Formatting tree\033[m\n"
114
vmdfmt -l -w src/
125

136
# Check Status
147
if [ ! -z "$(git status --porcelain)" ] ; then
15-
git diff
16-
printf "\033[31;1m=> Working directory not clean, files to be formatted:\033[m\n"
17-
git status
18-
VMDFMT=1
19-
fi
20-
21-
# Check SUMMARY.md
22-
printf "\n\033[37;1m=> Checking SUMMARY.md\033[m\n"
23-
res/ci/check-summary.sh
24-
SUMMARY=$?
25-
26-
# Generate exit value
27-
if [ ! -z $VMDFMT ] || [ ! $LINKCHECK -eq 0 ] || [ ! $SUMMARY -eq 0 ] ; then
28-
exit 2
8+
git diff --color=always
9+
printf "\033[31;1m=> Files which need to be formatted:\033[m\n"
10+
for f in $(git status | grep -Po 'modified:\K.*$'); do
11+
printf "$f\n"
12+
printf "::error title=Formatting Lint,file=$f,line=1::File has improper formatting\n"
13+
done
14+
exit 1
2915
fi

res/ci/linkcheck.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
# only show all the debug messages if ci is run with debug
4+
if [ "$RUNNER_DEBUG" ]; then
5+
loglevel=debug
6+
else
7+
loglevel=error
8+
fi
9+
10+
printf "\033[37;1m=> Checking links\033[m\n"
11+
RUST_LOG="linkcheck=$loglevel" mdbook-linkcheck -s -c always

0 commit comments

Comments
 (0)