Created
June 28, 2018 12:23
-
-
Save pvinchon/fae9497690f060bff062e57b7b0c9f1f to your computer and use it in GitHub Desktop.
CI/CD for exercism
This file contains hidden or 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
#!/bin/sh -ex | |
# Configure exercism | |
EXERCISM_DEFAULT_PATH=~/exercism | |
EXERCISM_CONFIG=$PWD/exercism_config | |
exercism --config $EXERCISM_CONFIG configure --silent --dir $PWD | |
exercism --config $EXERCISM_CONFIG configure --silent --key $EXERCISM_API_KEY | |
# Test all exercises | |
for EXERCISE in $PWD/*/*; do | |
LANGUAGE=$(echo $EXERCISE | rev | cut -d'/' -f2 | rev) | |
docker run \ | |
--rm \ | |
--interactive \ | |
--tty \ | |
--volume $EXERCISE:/opt/exercism \ | |
plippe/exercism:$LANGUAGE || break 0 | |
done | |
# If master branch, submit | |
if [ "$(git rev-parse HEAD)" == "$(git rev-parse origin/master)" ]; then | |
# Find updated exercises | |
EXERCISES=$(git log --pretty="format:" -m --name-only -n1 | |
| grep -o '^[^/]\+/[^/]\+' | |
| sort | |
| uniq) | |
# Submit all exercise solutions | |
for EXERCISE in $EXERCISES; do | |
exercism fetch $EXERCISE | |
FILES=$(diff -Nrq $EXERCISM_DEFAULT_PATH/$EXERCISE $EXERCISE | cut -d' ' -f2) | |
exercism --config $EXERCISM_CONFIG submit $FILES | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment