Merge pull request #775 from nextcloud/fix/test-scripts-from-774

Fix some missing fucntionality from PR 774
This commit is contained in:
Christian 2021-08-09 16:48:23 +02:00 коммит произвёл GitHub
Родитель 2af2ffc361 8e85a63be6
Коммит bbd15f3942
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 133 добавлений и 23 удалений

Просмотреть файл

@ -45,11 +45,12 @@ services:
#GITHUB_SERVER_URL
#GITHUB_API_URL
#GITHUB_GRAPHQL_URL
DEBUG:
DEBUG_MODE:
DEBUG_PORT:
DEBUG_HOST:
DEBUG_UPON_ERROR:
DEBUG_START_MODE:
DEBUG_TRACE_FORMAT:
QUICK_MODE:
env_file:
- mysql.env
@ -62,6 +63,7 @@ services:
- ./volumes/dumps:/dumps
- ./volumes/coverage:/coverage
- ./volumes/www/:/www
- ./volumes/output:/output
occ:
<<: *dut

111
.github/actions/run-tests/run-locally.sh поставляемый
Просмотреть файл

@ -19,7 +19,9 @@ Possible options:
--drop-env-dump Remove a backup from an environment
--overwrite-env-dump Allow to overwrite a backup of an environment
--env-dump-path <PATH> The name of the environment to save. Multiple environment backups are possible.
--copy-env-dump <SRC> <DST> Copy the environment dump in <SRC> to <DST>
--list-env-dumps List all environment dumps stored in the docker volume
--run-code-checker Run the cod checker
--run-unit-tests Run only the unit tests
--run-integration-tests Run only the integration tests
--extract-code-coverage Output the code coverage reports into the folder volumes/coverage/.
@ -31,12 +33,15 @@ Possible options:
--debug-host <HOST> Host to connect the debugging session to (default to local docker host)
--debug-up-error Enable the debugger in case of an error (see xdebug's start_upon_error configuration)
--debug-start-with-request <MODE> Set the starting mode of xdebug to <MODE> (see xdebug's start_with_request configuration)
--enable-tracing Enable the tracing feature of xdebug
--trace-format <FORMAT> Set the trace format to the <FORMAT> (see xdebug's trace_format configuration)
--enable-profiling Enable the profiling function of xdebug
--help Show this help screen
-- Pass any further parameters to the phpunit program
--prepare <BRANCH> Prepare the system for running the unit tests. This is a shorthand for
--pull --create-images-if-needed --start-helpers --setup-environment <BRANCH> --create-env-dump --create-plain-dump plain
--run-tests Run both unit as well as integration tests
--run-tests Run both unit as well as integration tests and code checking
--run Run the unit tests themselves. This is a shorthand for
--restore-env-dump --run-tests --extract-code-coverage
@ -99,7 +104,7 @@ push_images() {
create_file_structure() {
echo 'Creating the required file structure for the volumes'
mkdir -p volumes/{mysql,postgres,nextcloud,cookbook,data,dumps,coverage,www}
mkdir -p volumes/{mysql,postgres,nextcloud,cookbook,data,dumps,coverage,www,output}
}
start_helpers(){
@ -351,6 +356,13 @@ drop_env_dump() {
rm -rf "volumes/dumps/$ENV_DUMP_PATH"
}
copy_environment() {
echo "Copying dump $COPY_ENV_SRC to new name $COPY_ENV_DST"
rm -rf "volumes/dumps/$COPY_ENV_DST"
cp -a "volumes/dumps/$COPY_ENV_SRC" "volumes/dumps/$COPY_ENV_DST"
}
run_tests() {
PARAMS=''
@ -375,12 +387,10 @@ run_tests() {
PARAMS+=' --build-npm'
fi
if [ $DEBUG = y ]; then
PARAMS+=" --debug --debug-port $DEBUG_PORT"
if [ "$RUN_CODE_CHECKER" = 'y' ]; then
PARAMS+=' --run-code-checker'
fi
PARAMS+=' --run-code-checker'
echo "Staring container to run the unit tests."
echo "Parameters for container: $PARAMS"
echo "Additional parameters for phpunit: $@"
@ -432,22 +442,31 @@ CREATE_PLAIN_DUMP=''
RESTORE_ENV_DUMP=n
DROP_ENV_DUMP=n
OVERWRITE_ENV_DUMP=n
RUN_CODE_CHECKER=n
RUN_UNIT_TESTS=n
RUN_INTEGRATION_TESTS=n
EXTRACT_CODE_COVERAGE=n
INSTALL_COMPOSER_DEPS=n
BUILD_NPM=n
DEBUG=n
DEBUG_PORT=''
DEBUG_HOST=''
DEBUG_UPON_ERROR=''
DEBUG_START_MODE=''
QUICK_MODE=''
DEBUG=n
DEBUG_PORT='9000'
DEBUG_HOST='172.17.0.1'
DEBUG_UPON_ERROR='default'
DEBUG_START_MODE='yes'
DEBUG_MODE_STEP=n
DEBUG_MODE_TRACE=n
DEBUG_MODE_PROFILE=n
DEBUG_TRACE_FORMAT=1
ENV_BRANCH=stable20
ENV_DUMP_PATH=default
PHP_VERSION="${PHP_VERSION:-7}"
COPY_ENV_SRC=''
COPY_ENV_DST=''
source mysql.env
source postgres.env
@ -517,6 +536,14 @@ do
list_env_dumps
exit 0
;;
--copy-env-dump)
COPY_ENV_SRC="$2"
COPY_ENV_DST="$3"
shift 2
;;
--run-code-checker)
RUN_CODE_CHECKER=y
;;
--run-tests)
RUN_UNIT_TESTS=y
RUN_INTEGRATION_TESTS=y
@ -544,7 +571,7 @@ do
exit 1
;;
--debug)
DEBUG=y
DEBUG_MODE_STEP=y
;;
--debug-port)
DEBUG_PORT="$2"
@ -561,6 +588,16 @@ do
DEBUG_START_MODE="$2"
shift
;;
--enable-tracing)
DEBUG_MODE_TRACE=y
;;
--trace-format)
DEBUG_TRACE_FORMAT="$2"
shift
;;
--enable-profiling)
DEBUG_MODE_PROFILE=y
;;
--prepare)
DOCKER_PULL=y
CREATE_IMAGES_IF_NEEDED=y
@ -573,6 +610,7 @@ do
;;
--run)
RESTORE_ENV_DUMP=y
RUN_CODE_CHECKER=y
RUN_UNIT_TESTS=y
RUN_INTEGRATION_TESTS=y
EXTRACT_CODE_COVERAGE=y
@ -633,7 +671,50 @@ if [ -z "$RUNNER_GID" ]; then
fi
export RUNNER_GID
export DEBUG DEBUG_PORT DEBUG_HOST DEBUG_UPON_ERROR DEBUG_START_MODE
if [ "$DEBUG_MODE_STEP" = y -o "$DEBUG_MODE_TRACE" = y -o "$DEBUG_MODE_PROFILE" = y ]; then
DEBUG=y
DEBUG_MODE=''
if [ "$DEBUG_MODE_STEP" = y ]; then
DEBUG_MODE=',debug'
fi
if [ "$DEBUG_MODE_TRACE" = y ]; then
DEBUG_MODE="$DEBUG_MODE,trace"
fi
if [ "$DEBUG_MODE_PROFILE" = y ]; then
DEBUG_MODE="$DEBUG_MODE,profile"
fi
DEBUG_MODE=$(echo "$DEBUG_MODE" | cut -c 2-)
fi
export DEBUG_PORT DEBUG_HOST DEBUG_UPON_ERROR DEBUG_START_MODE DEBUG_MODE DEBUG_TRACE_FORMAT
if [ -z "$COPY_ENV_SRC" -a -n "$COPY_ENV_DST" ]; then
echo "You need to specify a source environment name. Nothing found."
exit 1
fi
if [ -n "$COPY_ENV_SRC" ]; then
if [ -z "$COPY_ENV_DST" ]; then
echo "You need to specify a destination environment name."
exit 1
fi
if [ ! -d "volumes/dumps/$COPY_ENV_SRC" ]; then
echo "The source environment $COPY_ENV_SRC is not found."
exit 1
fi
if [ -d "volumes/dumps/$COPY_ENV_DST" -a "$OVERWRITE_ENV_DUMP" != y ]; then
echo "The destination env dump $COPY_ENV_DST is already existing. No overwrite was specified. Aborting."
exit 1
fi
fi
export QUICK_MODE
echo "Using PHP version $PHP_VERSION"
@ -663,6 +744,10 @@ catch()
echo 'Starting process'
if [ -n "$COPY_ENV_SRC" ]; then
copy_environment
fi
if [ $DOCKER_PULL = 'y' ]; then
pull_images
fi

Просмотреть файл

@ -13,33 +13,41 @@ if [ `whoami` = root ]; then
echo "Quick mode activated. No permission update is carried out"
fi
if [ -n "$DEBUG" -a "$DEBUG" = y ]; then
echo "Activating step debugging mode in container"
if [ -n "$DEBUG_MODE" ]; then
echo "Activating debugging mode in container"
if [ -n "$DEBUG_PORT" ]; then
if [ -z "$DEBUG_PORT" ]; then
DEBUG_PORT=9000
fi
if [ -n "$DEBUG_HOST" ]; then
if [ -z "$DEBUG_HOST" ]; then
DEBUG_HOST='172.17.0.1'
fi
if [ -n "$DEBUG_UPON_ERROR" ]; then
if [ -z "$DEBUG_UPON_ERROR" ]; then
DEBUG_UPON_ERROR=default
fi
if [ -n "$DEBUG_START_MODE" ]; then
if [ -z "$DEBUG_START_MODE" ]; then
DEBUG_START_MODE=default
fi
if [ -z "$DEBUG_TRACE_FORMAT" ]; then
DEBUG_TRACE_FORMAT=1
fi
mode="develop,coverage,$DEBUG_MODE"
cat >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini <<- EOF
xdebug.mode=develop,coverage,debug
xdebug.mode=$mode
xdebug.start_with_request = $DEBUG_START_MODE
xdebug.start_upon_error=$DEBUG_UPON_ERROR
xdebug.client_port = $DEBUG_PORT
xdebug.client_host = $DEBUG_HOST
#xdebug.start_with_request = $DEBUG_START_MODE
xdebug.trace_format = $DEBUG_TRACE_FORMAT
EOF
fi
echo "Running the main script as user runner"

12
.github/actions/run-tests/tests/xdebug.config поставляемый
Просмотреть файл

@ -1,2 +1,12 @@
xdebug.mode=coverage
xdebug.mode=develop,coverage
xdebug.output_dir = /output
xdebug.trace_output_name = trace.%c.%u
xdebug.collect_return = true
xdebug.var_display_max_depth = 3
xdebug.var_display_max_data = 1024
xdebug.var_display_max_children = 515
xdebug.profiler_output_name = cachegrind.out.%c.%u

Просмотреть файл

@ -4,6 +4,11 @@
- Added debugging helpers in the CI scripts
[#774](https://github.com/nextcloud/cookbook/pull/774) @christianlupus
### Fixed
- Fixed changes from #774 and minor extensions
[#775](https://github.com/nextcloud/cookbook/pull/775) @christianlupus
## 0.9.1 - 2021-07-05
### Added