Skip to content

Commit

Permalink
ci: fix ci linter scripts (cncf#1223)
Browse files Browse the repository at this point in the history
Signed-off-by: Mariusz Sabath <[email protected]>
  • Loading branch information
tuminoid authored and mrsabath committed Mar 27, 2024
1 parent c596951 commit e01a634
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
14 changes: 10 additions & 4 deletions ci/links.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#!/usr/bin/env bash

set -e
shopt -s globstar

FAILURE=0

git config --global --add safe.directory /usr/src/app
npm install -g markdown-link-check
git fetch origin main:main
# To run this on the entire repo, replace the following command with `$(find ./ -type f | grep .md)`
for file_name in $(git diff --name-only $HEAD main); do
if [[ $file_name == *".md" ]]; then
npx markdown-link-check --config ./ci/link-config.json --progress --verbose "$file_name"
fi
for file_name in $(git diff --name-only $HEAD main -- ./**/*.md); do
npx markdown-link-check --config ./ci/link-config.json --progress --verbose "$file_name" || FAILURE=1
done

exit $FAILURE
14 changes: 10 additions & 4 deletions ci/lint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#!/usr/bin/env bash

set -e
shopt -s globstar

FAILURE=0

git config --global --add safe.directory /usr/src/app
npm install -g markdownlint-cli
git fetch origin main:main
# To run this on the entire repo, replace the following command with `$(find ./ -type f | grep .md)`
for file_name in $(git diff --name-only $HEAD main); do
if [[ $file_name == *".md" ]]; then
markdownlint -c ./ci/lint-config.json "$file_name"
fi
for file_name in $(git diff --name-only $HEAD main -- ./**/*.md); do
markdownlint -c ./ci/lint-config.json "$file_name" || FAILURE=1
done

exit $FAILURE
3 changes: 3 additions & 0 deletions ci/setup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

set -e

git config --global --add safe.directory /usr/src/app
git fetch origin main:main
git diff --name-only main $HEAD > modified
echo "these files have changed"
Expand Down
9 changes: 8 additions & 1 deletion ci/spelling.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/usr/bin/env bash

set -eo pipefail
shopt -s globstar

function spellcheck () {
git diff --name-only --diff-filter=AM main $HEAD | grep '\.md$' | xargs --no-run-if-empty -L1 npx cspell --show-suggestions -c ./ci/spelling-config.json
FAILURE=0
git diff --name-only --diff-filter=AM main $HEAD -- ./**/*.md | \
xargs --no-run-if-empty -L1 npx cspell --show-suggestions -c ./ci/spelling-config.json || FAILURE=1
return $FAILURE
}

function printhelp () {
Expand All @@ -21,6 +27,7 @@ function printhelp () {
}


git config --global --add safe.directory /usr/src/app
npm install -g cspell
git fetch origin main:main
# Print help if spellcheck fails
Expand Down

0 comments on commit e01a634

Please sign in to comment.