-
Notifications
You must be signed in to change notification settings - Fork 520
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
Add CI test to ensure that README.md files are present and correct #386
Merged
coriolinus
merged 6 commits into
exercism:master
from
coriolinus:ensure-readmes-are-updated
Nov 7, 2017
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
28d4a17
Add CI test to ensure that README.md files are present and correct
coriolinus 99242c6
Add CI test to ensure that README.md files are present and correct
coriolinus 7aae551
Clone the problem specifications into a subdirectory if it doesn't al…
coriolinus be9df7c
Merge branch 'ensure-readmes-are-updated' of github.com:coriolinus/ex…
coriolinus cf66a28
Redo updates to script.
coriolinus 7923464
Use https instead of ssh git path for problem-specifications
coriolinus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
if [ ! -x bin/configlet ]; then | ||
echo "Improper configuration; configlet should exist in bin/ when this script is run" | ||
echo "Ping a Rust track maintainer to fix this" | ||
exit 1 | ||
fi | ||
|
||
newline=$'\n ' | ||
|
||
missing_readmes="" | ||
wrong_readmes="" | ||
for exercise in $(git diff --name-only master..$(git rev-parse --abbrev-ref HEAD) | grep exercises/ | cut -d'/' -f2 -s | sort -fu); do | ||
echo "Checking readme for $exercise" | ||
readme_path="exercises/${exercise}/README.md" | ||
if [ ! -f $readme_path ]; then | ||
missing_readmes="$missing_readmes$newline$exercise" | ||
else | ||
existing_readme_checksum=$(md5sum $readme_path | cut -d' ' -f1) | ||
# generate the new README | ||
bin/configlet generate . --only "$exercise" | ||
generated_readme_checksum=$(md5sum $readme_path | cut -d' ' -f1) | ||
|
||
if [ $existing_readme_checksum != $generated_readme_checksum ]; then | ||
wrong_readmes="$wrong_readmes$newline$exercise" | ||
fi | ||
fi | ||
done | ||
|
||
if [ -n "$missing_readmes" ]; then | ||
echo "Exercises missing README.md:$missing_readmes" | ||
fi | ||
if [ -n "$wrong_readmes" ]; then | ||
echo "Exercises with out-of-date README.md:$wrong_readmes" | ||
fi | ||
if [ -n "$missing_readmes" -o -n "$wrong_readmes" ]; then | ||
exit 1 | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: I imagine you can check the exit code of
diff
rather than comparing the checksums against one another, if you find that easier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't actually have both files in place at the same time; the configlet command to regenerate it overwrites the existing README.md, if any. For this reason, I thought it easier to just keep the md5sum in memory and compare that.