Mercurial > kallithea
annotate scripts/validate-commits @ 7534:b06e1141f20f
model: rename confusing kwargs argument for repo_group update method (Issue #331)
author | Edmund Wong <ewong@crazy-cat.org> |
---|---|
date | Mon, 18 Feb 2019 17:00:51 +0800 |
parents | 69f70de15f26 |
children | d9e37f7fd35b |
rev | line source |
---|---|
7503
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
1 #!/usr/bin/env bash |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
2 # Validate the specified commits against test suite and other checks. |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
3 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
4 if [ -n "$VIRTUAL_ENV" ]; then |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
5 echo "Please run this script from outside a virtualenv." |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
6 exit 1 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
7 fi |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
8 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
9 if ! hg update --check -q .; then |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
10 echo "Working dir is not clean, please commit/revert changes first." |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
11 exit 1 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
12 fi |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
13 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
14 venv=$(mktemp -d kallithea-validatecommits-env-XXXXXX) |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
15 resultfile=$(mktemp kallithea-validatecommits-result-XXXXXX) |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
16 echo > "$resultfile" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
17 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
18 cleanup() |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
19 { |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
20 rm -rf /tmp/kallithea-test* |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
21 rm -rf "$venv" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
22 } |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
23 finish() |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
24 { |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
25 cleanup |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
26 # print (possibly intermediate) results |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
27 cat "$resultfile" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
28 rm "$resultfile" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
29 } |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
30 trap finish EXIT |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
31 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
32 for rev in $(hg log -r "$1" -T '{node}\n'); do |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
33 hg log -r "$rev" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
34 hg update "$rev" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
35 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
36 cleanup |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
37 virtualenv -p "$(command -v python2)" "$venv" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
38 source "$venv/bin/activate" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
39 pip install --upgrade pip setuptools |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
40 pip install -e . |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
41 pip install -r dev_requirements.txt |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
42 pip install python-ldap python-pam |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
43 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
44 # run-all-cleanup |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
45 scripts/run-all-cleanup |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
46 if ! hg update --check -q .; then |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
47 echo "run-all-cleanup did not give clean results!" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
48 result="NOK" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
49 hg diff |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
50 hg revert -a |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
51 else |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
52 result=" OK" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
53 fi |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
54 echo "$result: $rev (run-all-cleanup)" >> "$resultfile" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
55 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
56 # pytest |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
57 if py.test; then |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
58 result=" OK" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
59 else |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
60 result="NOK" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
61 fi |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
62 echo "$result: $rev (pytest)" >> "$resultfile" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
63 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
64 deactivate |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
65 echo |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
66 done |