Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit]Add shared kuttl pre-commit rules #105

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- id: kuttl-single-test-assert
name: kuttl-single-test-assert
language: script
pass_filenames: false
entry: pre-commit-hooks/kuttl-single-test-assert.sh

14 changes: 14 additions & 0 deletions pre-commit-hooks/kuttl-single-test-assert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -euxo pipefail

# Ensure that there are no assert files with more than one TestAssert
# as the extra TestAsserts are silently ignored by kuttl
KUTTL_DIR=${1:-"./test/kuttl"}
! egrep -c --include='*.y*ml' -R -e 'kind: TestAssert' "$KUTTL_DIR" \
| grep -v ':0' | grep -v ':1'
ret=$?
if [ $ret -ne 0 ]; then
echo Kuttl only executes the last TestAssert in an assert file.
echo Combine the TestAsserts into a single one with a list of commands.
fi
exit $ret
Loading