Skip to content

Commit 3b524b1

Browse files
authored
Merge pull request #33 from codecae/travis-ci
Added Travis CI scripts
2 parents 57453f9 + 7c5d255 commit 3b524b1

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
dist: trusty
2+
sudo: false
3+
4+
language: node_js
5+
6+
before_install:
7+
- npm install -g luamin
8+
- git checkout ./bin/travis-minify.sh
9+
- git checkout ./bin/travis-test.sh
10+
after_success:
11+
- ./bin/travis-minify.sh
12+
install:
13+
- ./bin/travis-test.sh

bin/travis-minify.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
if [ ${TRAVIS_PULL_REQUEST} == false ]; then
4+
SHORT_HASH=`git rev-parse --short HEAD`
5+
GITHUB_OWNER=`echo "${TRAVIS_REPO_SLUG}" | cut -d "/" -f 1`
6+
SUBJECT=`git log -n 1 --pretty=format:%s`
7+
rm Makefile
8+
git config --global user.email "travis@travis-ci.org"
9+
git config --global user.name "Travis CI"
10+
git remote rm origin
11+
git remote add origin https://${GITHUB_OWNER}:${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git > /dev/null
12+
git add .
13+
git stash
14+
git checkout ${TRAVIS_BRANCH}
15+
git stash pop
16+
git add .
17+
git commit -am "Minified: ${SUBJECT} [${SHORT_HASH}] [skip ci]"
18+
git push --set-upstream origin ${TRAVIS_BRANCH}
19+
echo "Done!"
20+
else
21+
echo "Pull requests are not minified...Exiting."
22+
fi

bin/travis-test.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
echo "test: ;" > Makefile
4+
5+
if [ -d sdcard ]; then
6+
rm -fR sdcard
7+
fi
8+
9+
cp -fR src sdcard
10+
11+
MANIFEST=(`find sdcard/ -iname *.lua -type f`);
12+
FAIL=0
13+
14+
chmod +x ./bin/travis-minify.sh
15+
16+
if [ ${#MANIFEST[@]} -eq 0 ]; then
17+
echo -e "\e[1m\e[39m[\e[31mTEST FAILED\e[39m]\e[21m No scripts could be found!."
18+
exit 1
19+
fi
20+
21+
for f in ${MANIFEST[@]};
22+
do
23+
luamin -f $f > $f.mini
24+
mv $f.mini $f
25+
if [ `cat $f | wc -l` -ne 1 ]; then
26+
FAIL=1
27+
echo -e "\e[1m\e[39m[\e[31mFAIL\e[39m]\e[21m ${f}"
28+
cat $f
29+
else
30+
echo -e "\e[1m\e[39m[\e[32mPASS\e[39m]\e[21m ${f}"
31+
fi
32+
done
33+
34+
if [ $FAIL -ne 0 ]; then
35+
echo -e "\e[1m\e[39m[\e[31mTEST FAILED\e[39m]\e[21m Please review your code and amend changes to the current branch."
36+
exit 1
37+
fi
38+

0 commit comments

Comments
 (0)