refactor!: delete common/lib and related usages

This commit is contained in:
UsamaSadiq
2022-08-25 16:31:47 +05:00
committed by Usama Sadiq
parent 96f6174d9e
commit 897cb3617f
40 changed files with 92 additions and 228 deletions

View File

@@ -42,7 +42,6 @@ FROM base as build
# Install Python requirements
COPY setup.py setup.py
COPY common/lib/ common/lib/
COPY openedx/core/lib openedx/core/lib
COPY lms lms
COPY cms cms

View File

@@ -36,7 +36,7 @@ if [ "$CIRCLE_NODE_TOTAL" == "1" ] ; then
echo "To run in more containers, configure parallelism for this repo's settings "
echo "via the CircleCI UI and adjust scripts/circle-ci-tests.sh to match."
echo "Running tests for common/lib/ and pavelib/"
echo "Running tests for pavelib/"
paver test_lib --cov-args="-p" || EXIT=1
echo "Running python tests for Studio"
paver test_system -s cms --cov-args="-p" || EXIT=1
@@ -82,7 +82,7 @@ else
paver test_system -s cms --cov-args="-p"
;;
3) # run the commonlib unit tests
3) # run the pavelib unit tests
paver test_lib --cov-args="-p"
;;

View File

@@ -17,9 +17,9 @@ set -e
# - "lms-unit": Run the LMS Python unit tests
# - "cms-unit": Run the CMS Python unit tests
# - "js-unit": Run the JavaScript tests
# - "commonlib-unit": Run Python unit tests from the common/lib directory
# - "commonlib-js-unit": Run the JavaScript tests and the Python unit
# tests from the common/lib directory
# - "pavelib-unit": Run Python unit tests from the pavelib/lib directory
# - "pavelib-js-unit": Run the JavaScript tests and the Python unit
# tests from the pavelib/lib directory
# - "bok-choy": Run acceptance tests that use the bok-choy framework
#
# `SHARD` is a number indicating which subset of the tests to build.
@@ -147,7 +147,7 @@ case "$TEST_SUITE" in
exit $EXIT
;;
"lms-unit"|"cms-unit"|"commonlib-unit")
"lms-unit"|"cms-unit"|"pavelib-unit")
$TOX bash scripts/unit-tests.sh
;;
@@ -156,7 +156,7 @@ case "$TEST_SUITE" in
$TOX paver diff_coverage
;;
"commonlib-js-unit")
"pavelib-js-unit")
$TOX paver test_js --coverage --skip-clean || { EXIT=1; }
paver test_lib --skip-clean $PAVER_ARGS || { EXIT=1; }

View File

@@ -1,48 +0,0 @@
#!/usr/bin/env bash
set -e
# Remove any cruft from a requirements file generated by pip-compile which we don't want to keep
function show_help {
echo "Usage: post-pip-compile.sh file ..."
echo "Remove any cruft left behind by pip-compile in the given requirements file(s)."
echo ""
echo "Removes \"-e\" prefixes which were added to GitHub URLs only so that"
echo "pip-compile could process them correctly."
}
function clean_file {
FILE_PATH=$1
TEMP_FILE=${FILE_PATH}.tmp
# Workaround for https://github.com/jazzband/pip-tools/issues/204 -
# change absolute paths for local editable packages back to relative ones
FILE_CONTENT=$(<${FILE_PATH})
FILE_URL_REGEX="-e (file:///[^"$'\n'"]*)/common/lib/\w+"
if [[ "${FILE_CONTENT}" =~ ${FILE_URL_REGEX} ]]; then
BASE_FILE_URL=${BASH_REMATCH[1]}
sed "s|$BASE_FILE_URL/||" ${FILE_PATH} > ${TEMP_FILE}
mv ${TEMP_FILE} ${FILE_PATH}
sed "s|$BASE_FILE_URL|.|" ${FILE_PATH} > ${TEMP_FILE}
mv ${TEMP_FILE} ${FILE_PATH}
fi
# Code sandbox local package installs must be non-editable due to file
# permissions issues. edxapp ones must stay editable until assorted
# packaging bugs are fixed.
if [[ "${FILE_PATH}" == "requirements/edx-sandbox/py38.txt" ]]; then
sed "s|-e common/lib/|common/lib/|" ${FILE_PATH} > ${TEMP_FILE}
mv ${TEMP_FILE} ${FILE_PATH}
fi
}
for i in "$@"; do
case ${i} in
-h|--help)
# help or unknown option
show_help
exit 0
;;
*)
clean_file ${i}
;;
esac
done

View File

@@ -15,7 +15,7 @@ set -e
#
# - "lms-unit": Run the LMS Python unit tests
# - "cms-unit": Run the CMS Python unit tests
# - "commonlib-unit": Run Python unit tests from the common/lib directory
# - "pavelib-unit": Run Python unit tests from the pavelib/paver_tests directory
#
# `SHARD` is a number indicating which subset of the tests to build.
#
@@ -109,27 +109,27 @@ case "${TEST_SUITE}" in
esac
;;
"commonlib-unit")
"pavelib-unit")
case "$SHARD" in
"all")
paver test_lib --disable_capture ${PAVER_ARGS} ${PARALLEL} 2> common-tests.log
mv reports/${TEST_SUITE}.coverage reports/.coverage.commonlib
paver test_lib --disable_capture ${PAVER_ARGS} ${PARALLEL} 2> pavelib-tests.log
mv reports/${TEST_SUITE}.coverage reports/.coverage.pavelib
;;
[1-2])
paver test_lib -l ./xmodule --disable_capture --eval-attr="shard==$SHARD" ${PAVER_ARGS} 2> common-tests.${SHARD}.log
mv reports/${TEST_SUITE}.coverage reports/.coverage.commonlib.${SHARD}
paver test_lib -l ./xmodule --disable_capture --eval-attr="shard==$SHARD" ${PAVER_ARGS} 2> pavelib-tests.${SHARD}.log
mv reports/${TEST_SUITE}.coverage reports/.coverage.pavelib.${SHARD}
;;
3|"noshard")
paver test_lib --disable_capture --eval-attr="shard>=$SHARD or not shard" ${PAVER_ARGS} 2> common-tests.3.log
mv reports/${TEST_SUITE}.coverage reports/.coverage.commonlib.3
paver test_lib --disable_capture --eval-attr="shard>=$SHARD or not shard" ${PAVER_ARGS} 2> pavelib-tests.3.log
mv reports/${TEST_SUITE}.coverage reports/.coverage.pavelib.3
;;
*)
# If no shard is specified, rather than running all tests, create an empty xunit file. This is a
# backwards compatibility feature. If a new shard (e.g., shard n) is introduced in the build
# system, but the tests are called with the old code, then builds will not fail because the
# code is out of date. Instead, there will be an instantly-passing shard.
mkdir -p reports/common
emptyxunit "common/nosetests"
mkdir -p reports/pavelib
emptyxunit "pavelib/nosetests"
;;
esac
;;

View File

@@ -30,15 +30,6 @@ exclude+='^\.$'
exclude+='|^xmodule/capa/safe_exec/tests/test_files/?.*$'
exclude+='|^common/test/data/?.*$'
# Exclude common/lib and its immediate child directories.
# They are not Python packages, but instead are Python sub-projects (hence the setup.py
# in each chlid directory).
# However, we do NOT want to exclude the source directories *within* the sub-projects.
# Example:
# * common/lib/capa -> EXCLUDE from check.
# * common/lib/capa/capa/safe_exec -> INCLUDE in check.
exclude+='|^common/lib$'
# xmodule data folder
exclude+='|^xmodule/tests/data/xml-course-root/capa$'
exclude+='|^xmodule/tests/data/xml-course-root/uploads/python_lib_zip$'

View File

@@ -25,7 +25,7 @@ import click
@click.option(
'--test-suite',
help="Test suite that the pytest worker ran.",
type=click.Choice(['lms-unit', 'cms-unit', 'commonlib-unit']),
type=click.Choice(['lms-unit', 'cms-unit']),
required=True
)
def main(log_file, test_suite):
@@ -38,9 +38,6 @@ def main(log_file, test_suite):
if worker_num_string not in worker_test_dict:
worker_test_dict[worker_num_string] = []
test = regex_search.group(3)
if test_suite == "commonlib-unit":
if "pavelib" not in test and not test.startswith('scripts'):
test = f"common/lib/{test}"
worker_test_dict[worker_num_string].append(test)
output_folder_name = "worker_list_files"