File tree 32 files changed +154
-130
lines changed
32 files changed +154
-130
lines changed Original file line number Diff line number Diff line change 31
31
# ###############################################################################
32
32
33
33
# Get the working directory to the repo root.
34
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
35
- cd " $( git rev-parse --show-toplevel) "
34
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
35
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
36
+ cd " ${topdir} " || exit $?
36
37
37
38
# Parse arguments.
38
39
apply_arg=" "
@@ -44,7 +45,7 @@ for arg in "$@"; do
44
45
elif [[ " ${arg} " == " --apply-format-changes" ]]; then
45
46
apply_arg=" --apply"
46
47
elif [ -z " ${rev} " ]; then
47
- if [ " $( git cat-file -t ${arg} 2> /dev/null) " != " commit" ]; then
48
+ if [ " $( git cat-file -t " ${arg} " 2> /dev/null) " != " commit" ]; then
48
49
echo -e " \033[31mNo revision '${arg} '.\033[0m" >&2
49
50
exit 1
50
51
fi
Original file line number Diff line number Diff line change 8
8
# ###############################################################################
9
9
10
10
# Get the working directory to the repo root.
11
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
12
- cd " $( git rev-parse --show-toplevel) "
11
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
12
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
13
+ cd " ${topdir} " || exit $?
13
14
14
15
asv run " $@ "
Original file line number Diff line number Diff line change 26
26
# ###############################################################################
27
27
28
28
# Get the working directory to the repo root.
29
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
30
- cd " $( git rev-parse --show-toplevel) "
29
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
30
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
31
+ cd " ${topdir} " || exit $?
31
32
32
33
# Figure out which revision to compare against.
33
- if [ ! -z " $1 " ] && [[ $1 != -* ]]; then
34
- if [ " $( git cat-file -t $1 2> /dev/null) " != " commit" ]; then
34
+ if [ -n " $1 " ] && [[ $1 != -* ]]; then
35
+ if [ " $( git cat-file -t " $1 " 2> /dev/null) " != " commit" ]; then
35
36
echo -e " \033[31mNo revision '$1 '.\033[0m" >&2
36
37
exit 1
37
38
fi
@@ -63,7 +64,7 @@ dev_tools/build-protos.sh
63
64
# but the error logic will still work.
64
65
uncommitted=$( git status --porcelain 2> /dev/null | grep -E " ^?? cirq-google" | cut -d " " -f 3)
65
66
66
- if [[ ! -z " $uncommitted " ]]; then
67
+ if [[ -n " $uncommitted " ]]; then
67
68
echo -e " \033[31mERROR: Uncommitted generated files found! Please generate and commit these files using dev_tools/build-protos.sh:\033[0m"
68
69
for generated in $uncommitted
69
70
do
Original file line number Diff line number Diff line change 14
14
# ###############################################################################
15
15
16
16
# Get the working directory to the repo root.
17
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
18
- cd " $( git rev-parse --show-toplevel) "
17
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
18
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
19
+ cd " ${topdir} " || exit $?
19
20
20
21
source dev_tools/pypath
21
22
Original file line number Diff line number Diff line change 32
32
# ###############################################################################
33
33
34
34
# Get the working directory to the repo root.
35
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
36
- cd " $( git rev-parse --show-toplevel) "
35
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
36
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
37
+ cd " ${topdir} " || exit $?
37
38
38
39
39
40
# Parse arguments.
@@ -46,7 +47,7 @@ for arg in "$@"; do
46
47
elif [[ " ${arg} " == " --all" ]]; then
47
48
only_changed=0
48
49
elif [ -z " ${rev} " ]; then
49
- if [ " $( git cat-file -t ${arg} 2> /dev/null) " != " commit" ]; then
50
+ if [ " $( git cat-file -t " ${arg} " 2> /dev/null) " != " commit" ]; then
50
51
echo -e " \033[31mNo revision '${arg} '.\033[0m" >&2
51
52
exit 1
52
53
fi
@@ -82,7 +83,7 @@ if (( only_changed == 1 )); then
82
83
83
84
# Get the modified, added and moved python files.
84
85
IFS=$' \n ' read -r -d ' ' -a format_files < \
85
- <( git diff --name-only --diff-filter=MAR ${rev} -- ' *.py' ' :(exclude)cirq-google/cirq_google/cloud/*' ' :(exclude)*_pb2.py' )
86
+ <( git diff --name-only --diff-filter=MAR " ${rev} " -- ' *.py' ' :(exclude)cirq-google/cirq_google/cloud/*' ' :(exclude)*_pb2.py' )
86
87
else
87
88
echo -e " Formatting all python files." >&2
88
89
IFS=$' \n ' read -r -d ' ' -a format_files < \
Original file line number Diff line number Diff line change 8
8
# ###############################################################################
9
9
10
10
# Get the working directory to the repo root.
11
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
12
- cd " $( git rev-parse --show-toplevel) "
11
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
12
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
13
+ cd " ${topdir} " || exit $?
13
14
14
15
# Check for non-contrib references to contrib.
15
16
results=$( grep -Rl " \bcirq\.contrib\b" cirq-core | grep -v " cirq/contrib" | grep -v " __" )
Original file line number Diff line number Diff line change 8
8
# ###############################################################################
9
9
10
10
# Get the working directory to the repo root.
11
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
12
- cd " $( git rev-parse --show-toplevel) "
11
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
12
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
13
+ cd " ${topdir} " || exit $?
13
14
14
15
CONFIG_FILE=' mypy.ini'
15
16
16
- CIRQ_PACKAGES=$( env PYTHONPATH=. python dev_tools/modules.py list --mode package-path)
17
+ read -r -a CIRQ_PACKAGES < \
18
+ <( env PYTHONPATH=. python dev_tools/modules.py list --mode package-path)
17
19
18
20
echo -e -n " \033[31m"
19
- mypy --config-file=dev_tools/conf/$CONFIG_FILE " $@ " $ CIRQ_PACKAGES dev_tools examples
21
+ mypy --config-file=dev_tools/conf/$CONFIG_FILE " $@ " " ${ CIRQ_PACKAGES[@]} " dev_tools examples
20
22
result=$?
21
23
echo -e -n " \033[0m"
22
24
Original file line number Diff line number Diff line change @@ -25,8 +25,9 @@ for arg in "$@"; do
25
25
done
26
26
27
27
# Get the working directory to the repo root.
28
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
29
- cd " $( git rev-parse --show-toplevel) "
28
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
29
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
30
+ cd " ${topdir} " || exit $?
30
31
31
32
pip show tensorflow-docs > /dev/null || exit 1
32
33
@@ -35,7 +36,7 @@ FORMAT_CMD="python3 -m tensorflow_docs.tools.nbfmt --indent=1"
35
36
# Test the notebooks
36
37
unformatted=$( $FORMAT_CMD --test docs 2>&1 | grep " \- docs" || true)
37
38
needed_changes=0
38
- if [ ! -z " ${unformatted} " ]; then
39
+ if [ -n " ${unformatted} " ]; then
39
40
needed_changes=1
40
41
if (( only_print == 0 )) ; then
41
42
$FORMAT_CMD docs
Original file line number Diff line number Diff line change 23
23
# ###############################################################################
24
24
25
25
# Get the working directory to the repo root.
26
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
27
- cd " $( git rev-parse --show-toplevel) "
26
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
27
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
28
+ cd " ${topdir} " || exit $?
28
29
29
30
npm --prefix ' cirq-web/cirq_ts' " $@ "
Original file line number Diff line number Diff line change 22
22
# ###############################################################################
23
23
24
24
# Get the working directory to the repo root.
25
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
26
- cd " $( git rev-parse --show-toplevel) "
25
+ thisdir= " $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
26
+ topdir= " $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
27
27
28
- cd ' cirq-web/cirq_ts'
28
+ cd " ${topdir} / cirq-web/cirq_ts" || exit $?
29
29
npx " $@ "
Original file line number Diff line number Diff line change 8
8
# ###############################################################################
9
9
10
10
# Get the working directory to the repo root.
11
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
12
- cd " $( git rev-parse --show-toplevel) "
11
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
12
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
13
+ cd " ${topdir} " || exit $?
13
14
14
- CIRQ_MODULES=$( env PYTHONPATH=. python dev_tools/modules.py list --mode package-path)
15
+ read -r -a CIRQ_MODULES < \
16
+ <( env PYTHONPATH=. python dev_tools/modules.py list --mode package-path)
15
17
16
18
# Add dev_tools to $PYTHONPATH so that pylint can find custom checkers
17
- env PYTHONPATH=dev_tools pylint --jobs=0 --rcfile=dev_tools/conf/.pylintrc " $@ " $ CIRQ_MODULES dev_tools examples
19
+ env PYTHONPATH=dev_tools pylint --jobs=0 --rcfile=dev_tools/conf/.pylintrc " $@ " " ${ CIRQ_MODULES[@]} " dev_tools examples
Original file line number Diff line number Diff line change 25
25
# ###############################################################################
26
26
27
27
# Get the working directory to the repo root.
28
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
29
- cd " $( git rev-parse --show-toplevel) "
28
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
29
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
30
+ cd " ${topdir} " || exit $?
30
31
31
32
# Figure out which revision to compare against.
32
- if [ ! -z " $1 " ] && [[ $1 != -* ]]; then
33
- if [ " $( git cat-file -t $1 2> /dev/null) " != " commit" ]; then
33
+ if [ -n " $1 " ] && [[ $1 != -* ]]; then
34
+ if [ " $( git cat-file -t " $1 " 2> /dev/null) " != " commit" ]; then
34
35
echo -e " \033[31mNo revision '$1 '.\033[0m" >&2
35
36
exit 1
36
37
fi
55
56
56
57
typeset -a changed
57
58
IFS=$' \n ' read -r -d ' ' -a changed < \
58
- <( git diff --name-only ${rev} -- ' *.py' ' :(exclude)cirq-google/cirq_google/cloud/*' ' :(exclude)*_pb2.py' \
59
+ <( git diff --name-only " ${rev} " -- ' *.py' ' :(exclude)cirq-google/cirq_google/cloud/*' ' :(exclude)*_pb2.py' \
59
60
| grep -E " ^(cirq|dev_tools|examples).*.py$"
60
61
)
61
62
Original file line number Diff line number Diff line change 12
12
# ###############################################################################
13
13
14
14
# Get the working directory to the repo root.
15
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
16
- cd " $( git rev-parse --show-toplevel) "
15
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
16
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
17
+ cd " ${topdir} " || exit $?
17
18
18
19
# Run in parallel by default. Pass the `-n0` option for a single-process run.
19
20
# (the last `-n` option wins)
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ pytest_result=$?
79
79
80
80
# assume successful cover_result in case coverage is not run
81
81
cover_result=0
82
- if (( $ ANALYZE_COV )) ; then
82
+ if (( ANALYZE_COV )) ; then
83
83
# Convert to .py,cover files.
84
84
coverage annotate
85
85
@@ -92,7 +92,7 @@ if (( $ANALYZE_COV )); then
92
92
fi
93
93
94
94
# Report result.
95
- if (( ${ pytest_result} || ${ cover_result} )) ; then
95
+ if (( pytest_result || cover_result )) ; then
96
96
exit 1
97
97
fi
98
98
exit 0
Original file line number Diff line number Diff line change 28
28
# ###############################################################################
29
29
30
30
# Get the working directory to the repo root.
31
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
32
- cd " $( git rev-parse --show-toplevel) "
31
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
32
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
33
+ cd " ${topdir} " || exit $?
33
34
34
35
# Figure out which branch to compare against.
35
- rest=$@
36
- if [ ! -z " $1 " ] && [[ $1 != -* ]]; then
37
- if [ " $( git cat-file -t $1 2> /dev/null) " != " commit" ]; then
36
+ rest=( " $@ " )
37
+ if [ -n " $1 " ] && [[ $1 != -* ]]; then
38
+ if [ " $( git cat-file -t " $1 " 2> /dev/null) " != " commit" ]; then
38
39
echo -e " \033[31mNo revision '$1 '.\033[0m" >&2
39
40
exit 1
40
41
fi
41
42
rev=$1
42
- rest=${@: 2}
43
+ rest=( " ${@: 2} " )
43
44
elif [ " $( git cat-file -t upstream/master 2> /dev/null) " == " commit" ]; then
44
45
rev=upstream/master
45
46
elif [ " $( git cat-file -t origin/master 2> /dev/null) " == " commit" ]; then
77
78
78
79
source dev_tools/pypath
79
80
80
- pytest ${rest} " ${changed[@]} "
81
+ pytest " ${rest[@]} " " ${changed[@]} "
Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ cd "$( dirname "${BASH_SOURCE[0]}" )" || exit 1
33
33
cd " $( git rev-parse --show-toplevel) " || exit 1
34
34
35
35
# Figure out which revision to compare against.
36
- if [ ! -z " $1 " ] && [[ $1 != -* ]]; then
37
- if [ " $( git cat-file -t $1 2> /dev/null) " != " commit" ]; then
36
+ if [ -n " $1 " ] && [[ $1 != -* ]]; then
37
+ if [ " $( git cat-file -t " $1 " 2> /dev/null) " != " commit" ]; then
38
38
echo -e " \033[31mNo revision '$1 '.\033[0m" >&2
39
39
exit 1
40
40
fi
Original file line number Diff line number Diff line change 22
22
# ###############################################################################
23
23
24
24
# Get the working directory to the repo root.
25
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
26
- cd " $( git rev-parse --show-toplevel) "
25
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
26
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
27
+ cd " ${topdir} " || exit $?
27
28
28
29
check/npx webpack --mode production " $@ "
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ check/ts-build
26
26
# Find the changed bundle.js files, if any
27
27
untracked=$( git status --porcelain 2> /dev/null | grep " cirq-web/cirq_ts/dist/" | cut -d " " -f 3)
28
28
29
- if [[ ! -z " $untracked " ]]; then
29
+ if [[ -n " $untracked " ]]; then
30
30
echo -e " \033[31mERROR: Uncommitted changes to bundle file(s) found! Please commit these files:\033[0m"
31
31
for generated in $untracked
32
32
do
@@ -35,4 +35,4 @@ if [[ ! -z "$untracked" ]]; then
35
35
exit 1
36
36
fi
37
37
38
- exit 0
38
+ exit 0
Original file line number Diff line number Diff line change 22
22
# ###############################################################################
23
23
24
24
# Get the working directory to the repo root.
25
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
26
- cd " $( git rev-parse --show-toplevel) "
25
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
26
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
27
+ cd " ${topdir} " || exit $?
27
28
28
29
check/npm run coverage " $@ "
Original file line number Diff line number Diff line change 22
22
# ###############################################################################
23
23
24
24
# Get the working directory to the repo root.
25
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
26
- cd " $( git rev-parse --show-toplevel) "
25
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
26
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
27
+ cd " ${topdir} " || exit $?
27
28
28
29
check/npm run lint " $@ "
Original file line number Diff line number Diff line change 22
22
# ###############################################################################
23
23
24
24
# Get the working directory to the repo root.
25
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
26
- cd " $( git rev-parse --show-toplevel) "
25
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
26
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
27
+ cd " ${topdir} " || exit $?
27
28
28
29
check/npm run fix " $@ "
Original file line number Diff line number Diff line change 24
24
# ###############################################################################
25
25
26
26
# Get the working directory to the repo root.
27
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
28
- cd " $( git rev-parse --show-toplevel) "
27
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
28
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
29
+ cd " ${topdir} " || exit $?
29
30
30
31
check/npm run test " $@ "
Original file line number Diff line number Diff line change 24
24
# ###############################################################################
25
25
26
26
# Get the working directory to the repo root.
27
- cd " $( dirname " ${BASH_SOURCE[0]} " ) "
28
- cd " $( git rev-parse --show-toplevel) "
27
+ thisdir=" $( dirname " ${BASH_SOURCE[0]} " ) " || exit $?
28
+ topdir=" $( git -C " ${thisdir} " rev-parse --show-toplevel) " || exit $?
29
+ cd " ${topdir} " || exit $?
29
30
30
31
check/npm run test-e2e " $@ "
Original file line number Diff line number Diff line change @@ -20,10 +20,10 @@ set -e
20
20
cd " $( dirname " ${BASH_SOURCE[0]} " ) "
21
21
cd " $( git rev-parse --show-toplevel) "
22
22
23
- REQS= " -r dev_tools/requirements/pytest-minimal.env.txt"
23
+ reqs=( -r dev_tools/requirements/pytest-minimal.env.txt )
24
24
25
25
# Install contrib requirements only if needed.
26
26
changed=$( git diff --name-only origin/master | grep " cirq/contrib" || true)
27
- [ " ${changed} " = " " ] || REQS= " $REQS -r cirq-core/cirq/contrib/requirements.txt"
27
+ [ " ${changed} " = " " ] || reqs+=( -r cirq-core/cirq/contrib/requirements.txt )
28
28
29
- pip install $REQS
29
+ pip install " ${reqs[@]} "
You can’t perform that action at this time.
0 commit comments