Mercurial > kallithea
annotate scripts/validate-commits @ 8708:3fb80ff77bda
diffs: simplify trick to avoid "trailing space" markup of empty diff lines
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Wed, 28 Oct 2020 14:51:26 +0100 |
parents | 68861940ee1e |
children | 0a9ddb8cd8c1 |
rev | line source |
---|---|
7902
37ac2ac0a9ae
scripts/validate-commits: use direct /bin/bash interpreter
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
7841
diff
changeset
|
1 #!/bin/bash |
7503
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 |
8436
68861940ee1e
scripts: let validate-commits default to testing the draft changes upto current
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8340
diff
changeset
|
14 revset=$1 |
68861940ee1e
scripts: let validate-commits default to testing the draft changes upto current
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8340
diff
changeset
|
15 if [ -z "$revset" ]; then |
68861940ee1e
scripts: let validate-commits default to testing the draft changes upto current
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8340
diff
changeset
|
16 echo "Warning: no revisions specified, checking draft changes up to the current one." |
68861940ee1e
scripts: let validate-commits default to testing the draft changes upto current
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8340
diff
changeset
|
17 revset='draft() and ancestors(.)' |
68861940ee1e
scripts: let validate-commits default to testing the draft changes upto current
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8340
diff
changeset
|
18 fi |
68861940ee1e
scripts: let validate-commits default to testing the draft changes upto current
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8340
diff
changeset
|
19 |
7503
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
20 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
|
21 resultfile=$(mktemp kallithea-validatecommits-result-XXXXXX) |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
22 echo > "$resultfile" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
23 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
24 cleanup() |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
25 { |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
26 rm -rf /tmp/kallithea-test* |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
27 rm -rf "$venv" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
28 } |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
29 finish() |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
30 { |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
31 cleanup |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
32 # print (possibly intermediate) results |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
33 cat "$resultfile" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
34 rm "$resultfile" |
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 trap finish EXIT |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
37 |
8436
68861940ee1e
scripts: let validate-commits default to testing the draft changes upto current
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8340
diff
changeset
|
38 for rev in $(hg log -r "$revset" -T '{node}\n'); do |
7503
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
39 hg log -r "$rev" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
40 hg update "$rev" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
41 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
42 cleanup |
8193
89e9aef9b983
py3: use "python3 -m venv" instead of virtualenv package
Mads Kiilerich <mads@kiilerich.com>
parents:
8173
diff
changeset
|
43 python3 -m venv "$venv" |
7503
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
44 source "$venv/bin/activate" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
45 pip install --upgrade pip setuptools |
7841
d9e37f7fd35b
docs: always use dev_requirements.txt together with main version constraints in setup.py
Mads Kiilerich <mads@kiilerich.com>
parents:
7503
diff
changeset
|
46 pip install -e . -r dev_requirements.txt python-ldap python-pam |
7503
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
47 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
48 # run-all-cleanup |
8340
bf85e6018daa
scripts: properly check for errors in whitespacecleanup/run-all-cleanup
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8193
diff
changeset
|
49 if ! scripts/run-all-cleanup ; then |
bf85e6018daa
scripts: properly check for errors in whitespacecleanup/run-all-cleanup
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8193
diff
changeset
|
50 echo "run-all-cleanup encountered errors!" |
7503
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
51 result="NOK" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
52 else |
8340
bf85e6018daa
scripts: properly check for errors in whitespacecleanup/run-all-cleanup
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8193
diff
changeset
|
53 if ! hg update --check -q .; then |
bf85e6018daa
scripts: properly check for errors in whitespacecleanup/run-all-cleanup
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8193
diff
changeset
|
54 echo "run-all-cleanup did not give clean results!" |
bf85e6018daa
scripts: properly check for errors in whitespacecleanup/run-all-cleanup
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8193
diff
changeset
|
55 result="NOK" |
bf85e6018daa
scripts: properly check for errors in whitespacecleanup/run-all-cleanup
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8193
diff
changeset
|
56 hg diff |
bf85e6018daa
scripts: properly check for errors in whitespacecleanup/run-all-cleanup
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8193
diff
changeset
|
57 hg revert -a |
bf85e6018daa
scripts: properly check for errors in whitespacecleanup/run-all-cleanup
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8193
diff
changeset
|
58 else |
bf85e6018daa
scripts: properly check for errors in whitespacecleanup/run-all-cleanup
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8193
diff
changeset
|
59 result=" OK" |
bf85e6018daa
scripts: properly check for errors in whitespacecleanup/run-all-cleanup
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
8193
diff
changeset
|
60 fi |
7503
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 (run-all-cleanup)" >> "$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 # pytest |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
65 if py.test; then |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
66 result=" OK" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
67 else |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
68 result="NOK" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
69 fi |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
70 echo "$result: $rev (pytest)" >> "$resultfile" |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
71 |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
72 deactivate |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
73 echo |
69f70de15f26
scripts: add developer script validate-commits
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
74 done |