Skip to content

Commit 128055a

Browse files
icyrockcomlpil
authored andcommitted
Add bower checker, update travis to use it and add separate testing script
1 parent facd844 commit 128055a

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ install:
1010
script:
1111
- bin/fetch-configlet
1212
- bin/configlet lint .
13+
- bin/check-bower.sh
1314
- bin/test.sh
1415

1516
cache:

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ As a first step we recommend you read the [contributing guide][cont-guide].
2929

3030
[cont-guide]: https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md
3131

32+
Due to Travis builds taking too long and timing out, the current build plan compiles and runs the tests for all exercises in a single run. This requires the following:
33+
34+
- A master bower is given in `etc/bower.json`. Test scripts assure this one is used when they are run
35+
* Please only update the master one and then run `bin/update-bower.sh` to sync them up.
36+
* After editing `etc/bower.json`, it is advisable to run `bin/check-bower.sh`. This checks for any discrepancies between various bower scripts.
37+
- Make sure exercises have a single module in `examples/src`
38+
39+
See [this PR](https://github.com/exercism/purescript/pull/71) for more details and the background.
40+
3241
#### Reporting or fixing bugs
3342

3443
Typical examples for a bug: A typo, a missing test case, an unclear or

bin/check-bower.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
# This script will check bower.json of all exercises
4+
# to confirm there are no discrepancies between them
5+
# and the master bower.json in etc/bower.json
6+
7+
xpurescript=$(dirname "$BASH_SOURCE")
8+
xpurescript=$(readlink -f "$xpurescript/..")
9+
cd "$xpurescript/exercises"
10+
11+
bower_master="$xpurescript/etc/bower.json"
12+
md5_master=$(md5sum $bower_master | awk '{print $1}')
13+
14+
check_result_all=0
15+
16+
for exercise in *; do
17+
bower=$exercise/bower.json
18+
19+
if [[ -f $bower ]]; then
20+
md5=$(sed -r 's/"name": "'$exercise'",/"name": "purescript-exercise",/' $bower | md5sum | awk '{print $1}')
21+
22+
check_result=0
23+
if [[ $md5_master != $md5 ]]; then
24+
check_result=1
25+
check_result_all=1
26+
fi
27+
28+
if [[ $check_result == 0 ]]; then
29+
echo -e "\e[1;32mOK $bower\e[0;39m"
30+
else
31+
echo -e "\e[1;31mNOT OK $bower\e[0;39m"
32+
fi
33+
fi
34+
done
35+
36+
if [[ $check_result_all != 0 ]]; then
37+
echo -e "\e[1;31m"
38+
echo -e "Please check Contributing section in README for more information about fixing the above issues."
39+
echo -e "\e[0;39m"
40+
fi
41+
42+
exit $check_result_all

bin/test-separate.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
xpurescript=$(dirname "$BASH_SOURCE")
4+
xpurescript=$(readlink -f "$xpurescript/..")
5+
cd "$xpurescript/exercises"
6+
7+
# Calling the script with 'clean' as the first argument
8+
# will cause a fully clean build
9+
10+
clean=no
11+
if [[ "$1" == clean ]]; then
12+
clean=yes
13+
fi
14+
15+
# Run for all exercises
16+
17+
for exercise in *; do
18+
if [[ -f $exercise/bower.json ]]; then
19+
cd $exercise
20+
21+
echo
22+
echo -e "\e[1;32m--- [ $exercise ]\e[0;39m"
23+
echo
24+
25+
# Clean local caches if clean build was requested
26+
if [[ $clean == yes ]]; then
27+
rm -rf bower_components output .pulp-cache
28+
fi
29+
30+
# Move the example solution temporarily
31+
if [[ ! -d src.tmp ]]; then
32+
mv src src.tmp
33+
mv examples/src src
34+
fi
35+
36+
# Install and test
37+
bower install
38+
pulp test
39+
40+
# Revert to the previous state
41+
mv src examples/src
42+
mv src.tmp src
43+
44+
cd ..
45+
fi
46+
done

0 commit comments

Comments
 (0)