forked from EFForg/https-everywhere
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtravis.sh
More file actions
executable file
·60 lines (50 loc) · 2.27 KB
/
travis.sh
File metadata and controls
executable file
·60 lines (50 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Wrapper for travis tests
# Folder paths, relative to parent
RULESETFOLDER="src/chrome/content/rules"
# Go to git repo root; taken from ../test.sh. Note that
# $GIT_DIR is .git in this case.
if [ -n "$GIT_DIR" ]
then
# $GIT_DIR is set, so we're running as a hook.
cd $GIT_DIR
cd ..
else
# Git command exists? Cool, let's CD to the right place.
git rev-parse && cd "$(git rev-parse --show-toplevel)"
fi
# Fetch the current GitHub version of HTTPS-E to compare to its master
git remote add upstream-for-travis https://github.com/EFForg/https-everywhere.git
trap 'git remote remove upstream-for-travis' EXIT
# Only do a shallow fetch if we're in Travis. No need otherwise.
if [ $TRAVIS ]; then
git fetch --depth=50 upstream-for-travis master
else
git fetch upstream-for-travis master
fi
COMMON_BASE_COMMIT=$(git merge-base upstream-for-travis/master HEAD)
RULESETS_CHANGED=$(git diff --name-only $COMMON_BASE_COMMIT | grep $RULESETFOLDER | grep '.xml')
if [ "$(git diff --name-only $COMMON_BASE_COMMIT)" != "$RULESETS_CHANGED" ]; then
ONLY_RULESETS_CHANGED=false
fi
# At this point, if anything fails, the test should fail
set -e
if [ "$TEST" == "rules" ]; then
echo >&2 "Performing comprehensive coverage test."
docker run --rm -ti -v $(pwd):/opt httpse python utils/ruleset_filenames_validate.py
docker run --rm -ti -v $(pwd):/opt httpse bash -c "utils/remove-obsolete-references.sh"
docker run --rm -ti -v $(pwd):/opt httpse bash -c "utils/validate.sh"
docker run --rm -ti -v $(pwd):/opt httpse bash -c "test/rules.sh"
docker run --rm -ti -v $(pwd):/opt httpse python utils/normalize-securecookie.py
fi
if [ "$TEST" == "fetch" ]; then
echo >&2 "Testing test URLs in all changed rulesets."
# --privileged is required here for miredo to create a network tunnel
docker run --rm -ti -v $(pwd):/opt -e RULESETS_CHANGED="$RULESETS_CHANGED" --privileged httpse bash -c "service miredo start && service tor start && test/fetch.sh"
fi
if [ "$TEST" == "preloaded" ]; then
echo >&2 "Ensuring rulesets do not introduce targets which are already HSTS preloaded."
docker run --rm -ti -v $(pwd):/opt -e RULESETS_CHANGED="$RULESETS_CHANGED" node bash -c "cd /opt/utils/hsts-prune && npm install && node index.js"
[ `git diff --name-only $RULESETFOLDER | wc -l` -eq 0 ]
fi
exit 0