-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert bash scripts to Python #7465
Changes from 1 commit
6ac0724
13c37f9
9ae6f2e
2eca67e
c9b6f98
7218092
9250dcb
9d33246
41113da
4fe2b2d
406129e
beb3c52
77e21d7
c5e3c97
a5eebeb
f9a8586
afb7068
dc1845c
eee27b9
a6dc5bb
e88fd13
c373919
06dc081
6b57f85
845a94c
4df7247
d3a2464
275d886
3482864
0ab00ec
cbb09a7
d2ed087
1ced71c
60510ae
f83f917
fb26396
d0a9f56
df0c880
af66d95
48c8ce8
fcbbbb0
0af2fc4
d3f80a3
740eb7a
c6ae74b
2834e82
8bbda96
cd84f0b
2c03e24
cd4a824
ae51254
a7e21c5
e9fd69d
b26d7dc
33a10ce
8ba23a5
db7a003
f521c7a
b6d5878
3086329
b912d6d
efabda0
899228a
6044c23
c28656b
2d62316
1e7bcdb
3a97331
cfad6b3
11ae549
46eb948
95b6ca9
7130eb7
13155a5
86647a8
7c47253
efc69b0
834bffa
0186a8a
326eda8
4f4b3c2
ad9fbae
34efc74
2d3d642
dcf6ec3
b532ba0
f58f27a
93b7cf4
01970a5
eda2856
92d39d5
98b324b
4cc089c
2f2871c
14d2659
862490c
1ec120f
9386c0c
11d891d
07eaf2b
ce7d114
6f04c1b
767d97e
82804cb
8e43243
fabf517
8b7bb5a
057f2e6
8003bfe
25b64ad
0492abe
fd168ab
77ddcbc
d89c3b0
251669a
b07b0d9
03e56b7
770cd4f
fafbde2
9ec9238
33f38a7
35cfe60
af6ad16
55a1a99
c604eae
90b50d8
5bdc8b1
891d088
a6e6b28
a42a17c
28eaabe
6e9b993
7bf028d
f0ebb60
8fe8d20
b73afbf
1b4638b
64fc6c5
320b65e
127cead
595be3c
6939582
80a9599
5ac03b0
9a84e6f
770c6f3
d713208
c3006d2
2459c84
89f61e6
07814eb
89afe82
6967564
6ba9902
943759b
911d84a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
import argparse | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
import python_utils | ||
|
||
|
@@ -51,14 +52,14 @@ | |
action='store_true') | ||
|
||
|
||
def main(): | ||
def main(argv): | ||
"""Runs the frontend tests.""" | ||
setup.main() | ||
setup_gae.main() | ||
xvfb_prefix = '' | ||
if os.environ.get('VAGRANT') or os.path.isfile('/etc/is_vagrant_vm'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note #7521 -- Vagrant is being removed due to lack of usage. I suspect that PR will get merged before this one, so you might want to consider dropping the Vagrant stuff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
xvfb_prefix = '/usr/bin/xvfb-run' | ||
parsed_args = _PARSER.parse_args() | ||
parsed_args = _PARSER.parse_args(args=argv) | ||
setup.maybe_install_dependencies( | ||
parsed_args.skip_install, parsed_args.run_minified_tests) | ||
python_utils.PRINT('') | ||
|
@@ -98,4 +99,4 @@ def main(): | |
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
main(sys.argv) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Copyright 2019 The Oppia Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the 'License'); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an 'AS-IS' BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""INSTRUCTIONS: | ||
|
||
Run this script from the oppia root folder prior to opening a PR: | ||
python -m scripts.run_presubmit_checks | ||
|
||
It runs the following tests in all cases. | ||
- Javascript and Python Linting | ||
brianrodri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Backend Python tests | ||
|
||
Only when frontend files are changed will it run Frontend Karma unit tests. | ||
|
||
If any of these tests result in errors, this script will terminate. | ||
|
||
Note: The test scripts are arranged in increasing order of time taken. This | ||
enables a broken build to be detected as quickly as possible. | ||
|
||
===================== | ||
CUSTOMIZATION OPTIONS | ||
===================== | ||
|
||
Set the origin branch to compare against by adding | ||
|
||
--branch=your_branch or -b=your_branch | ||
|
||
By default, if the current branch tip exists on remote origin, | ||
the current branch is compared against its tip on GitHub. | ||
Otherwise it's compared against 'develop'. | ||
""" | ||
from __future__ import absolute_import # pylint: disable=import-only-modules | ||
|
||
import argparse | ||
import sys | ||
|
||
import python_utils | ||
|
||
from . import common | ||
from . import pre_commit_linter | ||
from . import run_backend_tests | ||
from . import run_frontend_tests | ||
|
||
_PARSER = argparse.ArgumentParser() | ||
_PARSER.add_argument( | ||
'--branch', '-b', | ||
help='optional; if specified, the origin branch to compare against.') | ||
|
||
|
||
def main(argv): | ||
"""Run the presubmit checks.""" | ||
|
||
# Run Javascript and Python linters. | ||
python_utils.PRINT('Linting files since the last commit') | ||
pre_commit_linter.main() | ||
python_utils.PRINT('Linting passed.') | ||
python_utils.PRINT('') | ||
|
||
current_branch = common.run_command('git rev-parse --abbrev-ref HEAD') | ||
|
||
# If the current branch exists on remote origin, matched_branch_num=1 | ||
# else matched_branch_num=0. | ||
matched_branch_num = common.run_command( | ||
'git ls-remote --heads origin %s | wc -l' % current_branch) | ||
|
||
# Set the origin branch to develop if it's not specified. | ||
parsed_args, _ = _PARSER.parse_known_args(args=argv) | ||
if parsed_args.branch: | ||
branch = parsed_args.branch | ||
elif matched_branch_num == '1': | ||
branch = 'origin/%s' % current_branch | ||
else: | ||
branch = 'develop' | ||
|
||
python_utils.PRINT('Comparing the current branch with %s' % branch) | ||
|
||
all_changed_files = common.run_command( | ||
'git diff --cached --name-only --diff-filter=ACM %s' % branch) | ||
|
||
if common.FRONTEND_DIR in all_changed_files: | ||
# Run frontend unit tests. | ||
python_utils.PRINT('Running frontend unit tests') | ||
run_frontend_tests.main(['--run_minified_tests']) | ||
python_utils.PRINT('Frontend tests passed.') | ||
python_utils.PRINT('') | ||
else: | ||
# If files in common.FRONTEND_DIR were not changed, skip the tests. | ||
python_utils.PRINT('No frontend files were changed.') | ||
python_utils.PRINT('Skipped frontend tests') | ||
|
||
# Run backend tests. | ||
python_utils.PRINT('Running backend tests') | ||
run_backend_tests.main([]) | ||
python_utils.PRINT('Backend tests passed.') | ||
python_utils.PRINT('') | ||
|
||
|
||
if __name__ == '__main__': | ||
main(sys.argv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's delete this function, and just pass stuff to subprocess directly using lists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done