travis: verify READMEs contain latest .meta contents (#1637)

* travis: verify READMEs contain latest .meta contents

* use -gt instead of -ge

* Verify new check fails correctly.

* Revert "Verify new check fails correctly."

This reverts commit 22bee6c9708fbdae2fc6014a1e91e1e5b8629a39.

* add newline to end of file
This commit is contained in:
Corey McCandless
2018-12-20 15:51:12 -05:00
committed by GitHub
parent 2fa629d91c
commit 32706f8cc0
2 changed files with 23 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ before_script:
- flake8
- ./bin/fetch-configlet
- ./bin/configlet lint .
- ./bin/check-readmes.sh
script:
- ./test/check-exercises.py

22
bin/check-readmes.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
get_timestamp()
{
path="$1"
git log -n1 --pretty=format:%ct -- "$path"
}
ret=0
for exercise in $(ls -d exercises/*/); do
meta_dir="${exercise}.meta"
if [ -d "$meta_dir" ]; then
meta_timestamp="$(get_timestamp "$meta_dir")"
readme_timestamp="$(get_timestamp "${exercise}README.md")"
if [ "$meta_timestamp" -gt "$readme_timestamp" ]; then
ret=1
echo "$(basename "$exercise"): .meta/ contents newer than README. Please regenerate it with configlet."
fi
fi
done
exit $ret