Skip to content

Commit 79882d5

Browse files
committed
Run examples before pushing to remote
1 parent f58c3a9 commit 79882d5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tools/git/hooks/pre-push

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ run_tests() {
8888

8989
# Main execution sequence.
9090
main() {
91+
local changed_files
92+
local files
93+
9194
has_commits
9295
if [[ "$?" -ne 0 ]]; then
9396
on_error 1
@@ -96,11 +99,28 @@ main() {
9699
if [[ "$?" -ne 0 ]]; then
97100
on_error 1
98101
fi
102+
103+
# Get the set of changed files (added and modified):
104+
changed_files=$(git diff --name-only --diff-filter AM origin/${GIT_CURRENT_BRANCH})
105+
106+
# Run JavaScript example files:
107+
files=$(echo "${changed_files}" | grep 'examples/.*\.js$' | tr '\n' ' ')
108+
if [[ -n "${files}" ]]; then
109+
echo 'Running JavaScript example files...' >&2
110+
make FILES="${files}" examples-files > /dev/null >&2
111+
if [[ "$?" -ne 0 ]]; then
112+
echo '' >&2
113+
echo 'Encountered an error when running examples.' >&2
114+
return 1
115+
fi
116+
fi
117+
99118
# FIXME: re-enable once we have written tooling to support running only those tests involving affected packages.
100119
# run_tests
101120
# if [[ "$?" -ne 0 ]]; then
102121
# on_error 1
103122
# fi
123+
104124
cleanup
105125
exit 0
106126
}

0 commit comments

Comments
 (0)