Split integration and migration tests

Closes #1017

Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Christian Wolf 2022-05-30 19:47:52 +02:00
Родитель 81e489648c
Коммит db365b1d89
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 9FC3120E932F73F1
12 изменённых файлов: 58 добавлений и 27135 удалений

2
.github/actions/run-tests/action.yml поставляемый
Просмотреть файл

@ -47,7 +47,7 @@ runs:
--create-env-dump
--create-plain-dump plain
--install-composer-deps
--run-tests
--run-all-tests
--extract-code-coverage
--shutdown-helpers || { failed=$?; } ;
if [ -n "$failed" ]; then

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

@ -24,6 +24,7 @@ Possible options:
--run-code-checker Run the cod checker
--run-unit-tests Run only the unit tests
--run-integration-tests Run only the integration tests
--run-migration-tests Run only the migration tests
--extract-code-coverage Output the code coverage reports into the folder volumes/coverage/.
--keep-code-coverage Normally, the last code coverage is removed to avoid filling up the disk. This flag keeps the old one.
--install-composer-deps Install composer dependencies
@ -43,7 +44,8 @@ Possible options:
--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 and code checking
--run-default-tests Run both unit as well as integration tests and code checking
--run-all-tests Run all tests present
--run Run the unit tests themselves. This is a shorthand for
--restore-env-dump --run-tests --extract-code-coverage
@ -407,6 +409,10 @@ run_tests() {
if [ $RUN_INTEGRATION_TESTS = 'y' ]; then
PARAMS+=' --run-integration-tests'
fi
if [ $RUN_MIGRATION_TESTS = 'y' ]; then
PARAMS+=' --run-migration-tests'
fi
if [ $EXTRACT_CODE_COVERAGE = 'y' ]; then
PARAMS+=' --create-coverage-report'
@ -478,6 +484,7 @@ OVERWRITE_ENV_DUMP=n
RUN_CODE_CHECKER=n
RUN_UNIT_TESTS=n
RUN_INTEGRATION_TESTS=n
RUN_MIGRATION_TESTS=n
EXTRACT_CODE_COVERAGE=n
KEEP_CODE_COVERAGE=n
INSTALL_COMPOSER_DEPS=n
@ -581,16 +588,24 @@ do
--run-code-checker)
RUN_CODE_CHECKER=y
;;
--run-tests)
--run-tests|--run-default-tests)
RUN_UNIT_TESTS=y
RUN_INTEGRATION_TESTS=y
;;
--run-all-tests)
RUN_UNIT_TESTS=y
RUN_INTEGRATION_TESTS=y
RUN_MIGRATION_TESTS=y
;;
--run-unit-tests)
RUN_UNIT_TESTS=y
;;
--run-integration-tests)
RUN_INTEGRATION_TESTS=y
;;
--run-migration-tests)
RUN_MIGRATION_TESTS=y
;;
--extract-code-coverage)
EXTRACT_CODE_COVERAGE=y
;;
@ -891,7 +906,7 @@ toc
rotate_code_coverage
tic
if [ $RUN_UNIT_TESTS = 'y' -o $RUN_INTEGRATION_TESTS = 'y' ]; then
if [ $RUN_UNIT_TESTS = 'y' -o $RUN_INTEGRATION_TESTS = 'y' -o $RUN_MIGRATION_TESTS = 'y' ]; then
run_tests "$@"
fi
toc

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

@ -28,6 +28,7 @@ printCI() {
RUN_UNIT_TESTS=n
RUN_INTEGRATION_TESTS=n
RUN_MIGRATION_TESTS=n
CREATE_COVERAGE_REPORT=n
RUN_CODE_CHECKER=n
INSTALL_COMPOSER_DEPS=n
@ -42,6 +43,9 @@ do
--run-integration-tests)
RUN_INTEGRATION_TESTS=y
;;
--run-migration-tests)
RUN_MIGRATION_TESTS=y
;;
--create-coverage-report)
CREATE_COVERAGE_REPORT=y
;;
@ -93,12 +97,14 @@ printCI "::endgroup::"
PARAM_COVERAGE_UNIT='--log-junit /coverage/junit.xml --log-teamcity /coverage/teamcity.log'
PARAM_COVERAGE_INTEGRATION='--log-junit /coverage/junit-integration.xml --log-teamcity /coverage/teamcity.integration.log'
PARAM_COVERAGE_MIGRATION='--log-junit /coverage/junit-migration.xml --log-teamcity /coverage/teamcity.migration.log'
if [ $CREATE_COVERAGE_REPORT = 'y' ]; then
rm -rf /coverage/tmp
mkdir /coverage/tmp
PARAM_COVERAGE_UNIT+=' --coverage-clover /coverage/tmp/coverage.unit.xml --coverage-html /coverage/tmp/coverage-unit'
PARAM_COVERAGE_INTEGRATION+=' --coverage-clover /coverage/tmp/coverage.integration.xml --coverage-html /coverage/tmp/coverage-integration'
PARAM_COVERAGE_MIGRATION+=' --coverage-clover /coverage/tmp/coverage.migration.xml --coverage-html /coverage/tmp/coverage-migration'
fi
if [ $RUN_CODE_CHECKER = 'y' ]; then
@ -130,6 +136,12 @@ if [ $RUN_INTEGRATION_TESTS = 'y' ]; then
echo 'Integration testing done.'
fi
if [ $RUN_MIGRATION_TESTS = 'y' ]; then
echo 'Starting migration testing.'
/phpunit -c phpunit.migration.xml $PARAM_COVERAGE_MIGRATION "$@" || { FAILED=$?; true; }
echo 'Migration testing done.'
fi
popd > /dev/null
printCI "::group::Postprocessing output"
@ -137,7 +149,7 @@ printCI "::group::Postprocessing output"
if [ $CREATE_COVERAGE_REPORT = 'y' ]; then
echo 'Patching style in coverage report'
cd /coverage/tmp
for f in coverage-unit coverage-integration
for f in coverage-unit coverage-integration coverage-migration
do
if [ -f "$f/_css/style.css" ]; then
sed -i -f /helper/style.sed "$f/_css/style.css"

0
COPYING Executable file → Normal file
Просмотреть файл

0
Makefile Executable file → Normal file
Просмотреть файл

0
README.md Executable file → Normal file
Просмотреть файл

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

@ -1,26 +0,0 @@
#!/bin/bash
echo ""
echo "Building..."
echo ""
npm install
npm run build
echo ""
echo "Creating archive..."
echo ""
ln -s . cookbook
tar -czvf cookbook.tar.gz cookbook/appinfo cookbook/composer.json cookbook/COPYING cookbook/css cookbook/img cookbook/js cookbook/lib cookbook/Makefile cookbook/phpunit.integration.xml cookbook/phpunit.xml cookbook/README.md cookbook/templates cookbook/tests cookbook/l10n
rm cookbook
echo ""
echo "Creating signing key..."
echo ""
openssl dgst -sha512 -sign ~/.config/nextcloud/certificates/cookbook.key cookbook.tar.gz | openssl base64
echo ""
echo "Done!"
echo ""

Разница между файлами не показана из-за своего большого размера Загрузить разницу

0
phpunit.integration.xml Executable file → Normal file
Просмотреть файл

25
phpunit.migration.xml Normal file
Просмотреть файл

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/bootstrap.php"
colors="true"
backupGlobals="false"
backupStaticAttributes="false"
cacheResult="true"
cacheResultFile="/tmp/phpunit.cache"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<testsuites>
<testsuite name="migration">
<directory>./tests/Migration</directory>
</testsuite>
</testsuites>
<coverage includeUncoveredFiles="true" processUncoveredFiles="true">
<include>
<directory suffix=".php">lib</directory>
</include>
</coverage>
<php>
<env name="INPUT_DB" value="unknown" />
</php>
</phpunit>

0
phpunit.xml Executable file → Normal file
Просмотреть файл

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

@ -1,6 +1,6 @@
<?php
namespace OCA\Cookbook\tests\Integration\Setup\Migrations;
namespace OCA\Cookbook\tests\Migration\Setup\Migrations;
use Doctrine\DBAL\Schema\Table;
use OCP\IDBConnection;