Skip to content

CI check to verify required exercises files exist. #458

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

Merged
merged 8 commits into from
Dec 29, 2016
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ addons:

script:
- bin/jsonlint
- bin/check_required_files_present
55 changes: 55 additions & 0 deletions bin/check_required_files_present
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
MISSING_FILES=0
SHOW_PROGRESS='false'

if [ ! -d exercises ] ; then
echo "\"exercises\" directory not found, make sure you're running from the repository root" >&2
exit 1
fi

function show_progress {
if [ $SHOW_PROGRESS == 'true' ]; then
echo -n '.'
fi
}

function require_file {
filename=$1
if [ ! -f $filename ]; then
echo "required file missing: $filename" >&2
let "MISSING_FILES+=1"
fi
}

function check_directory {
directory=$1
for exercise_directory in $directory/* ; do
show_progress
require_file "$exercise_directory/description.md"
require_file "$exercise_directory/metadata.yml"
done

}

while :
do
case "$1" in
-p | --progress)
SHOW_PROGRESS="true"
shift 1
;;
*)
check_directory 'exercises'
if [ $SHOW_PROGRESS == 'true' ]; then
echo
echo Done: $MISSING_FILES files missing.
fi
if (( $MISSING_FILES > 0 )); then
exit 1
else
exit 0
fi
;;
esac
done