public-apis/build/main.sh

55 lines
1.3 KiB
Bash
Raw Normal View History

2017-07-10 07:01:47 +02:00
#!/bin/bash
2017-07-27 04:38:17 +02:00
FORMAT_FILE=../README.md
2017-07-27 04:38:17 +02:00
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
2017-10-26 18:19:07 +02:00
echo "running on $TRAVIS_BRANCH branch"
LINK_FILE=../README.md
2017-07-27 04:38:17 +02:00
else
2017-10-26 18:19:07 +02:00
echo "running on Pull Request #$TRAVIS_PULL_REQUEST"
DIFF_URL="https://patch-diff.githubusercontent.com/raw/toddmotto/public-apis/pull/$TRAVIS_PULL_REQUEST.diff"
curl $DIFF_URL > diff.txt
echo "------- BEGIN DIFF -------"
cat diff.txt
echo "-------- END DIFF --------"
cat diff.txt | egrep "\+" > additions.txt
echo "------ BEGIN ADDITIONS -----"
cat additions.txt
echo "------- END ADDITIONS ------"
LINK_FILE=additions.txt
2017-10-26 18:19:07 +02:00
echo "checking if /json was changed..."
if egrep "\+{3}\s.\/json\/" diff.txt > json.txt; then
2017-10-26 17:14:21 +02:00
echo "JSON files are auto-generated! Please do not update these files:"
cat json.txt
exit 1
2017-10-26 18:19:07 +02:00
else
2017-10-26 17:14:21 +02:00
echo "/json check passed!"
rm json.txt
2017-10-26 18:19:07 +02:00
fi
fi
2017-12-23 02:21:43 +01:00
echo "running format validation..."
./validate_format.py $FORMAT_FILE
if [[ $? != 0 ]]; then
2017-10-26 18:19:07 +02:00
echo "format validation failed!"
exit 1
2017-07-10 07:41:50 +02:00
else
2017-10-26 18:19:07 +02:00
echo "format validation passed!"
./build.sh && ./deploy.sh
if [[ $? != 0 ]]; then
echo "JSON build and deploy failed!"
else
echo "JSON build and deploy success!"
fi
2017-07-10 07:41:50 +02:00
fi
echo "running link validation..."
2017-12-29 04:43:29 +01:00
./validate_links.py $LINK_FILE
if [[ $? != 0 ]]; then
2017-10-26 18:19:07 +02:00
echo "link validation failed!"
exit 1
else
2017-10-26 18:19:07 +02:00
echo "link validation passed!"
2017-07-10 07:01:47 +02:00
fi