Skip to content

Commit

Permalink
[TASK] sync the CI stuff from main branch into 11.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
dkd-kaehm authored and dkd-friedrich committed Oct 30, 2024
1 parent c166ad4 commit a48f30e
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ If applicable, add screenshots to help explain your problem.
**Used versions (please complete the following information):**
- TYPO3 Version: [e.g. 11.5.41]
- Browser: [e.g. chrome, safari]
- EXT:solr Version: [e.g. 11.5.7]
- EXT:solr Version: [e.g. 11.6.0]
- Used Apache Solr Version: [e.g. 8.11.4]
- PHP Version: [e.g. 8.2.0]
- MySQL Version: [e.g. 8.0.0]
Expand Down
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE] Please describe your feature wish here"
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.

**Target versions**
Please add the EXT:solr target versions here.
17 changes: 9 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ jobs:
outputs:
matrix: ${{ steps.collect_build_matrix.outputs.matrix }}
steps:
# Workaround for issue with actions/checkout@v2 wrong PR commit checkout: See https://github.com/actions/checkout/issues/299#issuecomment-677674415
# Workaround for issue with actions/checkout "wrong PR commit checkout":
# See:
# ** https://github.com/actions/checkout/issues/299#issuecomment-677674415
# ** https://github.com/actions/checkout/issues/1359#issuecomment-1631503791
-
name: Checkout current state of Pull Request
if: github.event_name == 'pull_request'
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
-
name: Checkout current state of Branch
if: github.event_name == 'push'
uses: actions/checkout@v2
# End: Workaround for issue with actions/checkout@v2 wrong PR commit checkout
uses: actions/checkout@v3
# End: Workaround for issue with actions/checkout...
-
name: "Resolve target branch of pull request."
if: github.event_name == 'pull_request'
Expand Down Expand Up @@ -104,7 +107,6 @@ jobs:
TYPO3_DATABASE_HOST: '127.0.0.1'
TYPO3_DATABASE_USERNAME: 'root'
TYPO3_DATABASE_PASSWORD: 'root'
PHP_CS_FIXER_VERSION: '^3.2.1'
TYPO3_VERSION: ${{ matrix.TYPO3 }}

name: TYPO3 ${{ matrix.TYPO3 }} on PHP ${{ matrix.PHP }}
Expand All @@ -128,7 +130,7 @@ jobs:
name: Mount RAMFS
run: |
mkdir -p ${{ env.CI_BUILD_DIRECTORY }}
sudo mount -t tmpfs -o size=3G none ${{ env.CI_BUILD_DIRECTORY }}
sudo mount -t tmpfs -o size=1G none ${{ env.CI_BUILD_DIRECTORY }}
sudo mkdir -p ${{ env.CI_BUILD_DIRECTORY }}/data-{solr,mysql} \
&& sudo chown $USER ${{ env.CI_BUILD_DIRECTORY }}/data-mysql \
&& sudo chown 8983:8983 ${{ env.CI_BUILD_DIRECTORY }}/data-solr
Expand Down Expand Up @@ -160,10 +162,9 @@ jobs:
with:
php-version: ${{ matrix.PHP }}
coverage: pcov
tools: composer:2.1.14
tools: composer:2.5.5
-
name: CI-Bootstrap
if: steps.restore_ci_build_caches.outputs.cache-hit != 'true'
run: |
./Build/Test/bootstrap.sh --skip-solr-install
echo "Current Size of EXT:Solr build Artefacts before run: " \
Expand Down
1 change: 1 addition & 0 deletions Build/Test/IntegrationTests.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
bootstrap="IntegrationTestsBootstrap.php"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
Expand Down
6 changes: 4 additions & 2 deletions Build/Test/IntegrationTestsBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
* The TYPO3 project - inspiring people to share!
*/

call_user_func(function () {
$testbase = new \TYPO3\TestingFramework\Core\Testbase();
use TYPO3\TestingFramework\Core\Testbase;

call_user_func(static function () {
$testbase = new Testbase();
$testbase->defineOriginalRootPath();
$testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests');
$testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient');
Expand Down
1 change: 1 addition & 0 deletions Build/Test/UnitTests.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
bootstrap="UnitTestsBootstrap.php"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
Expand Down
52 changes: 12 additions & 40 deletions Build/Test/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
#!/usr/bin/env bash

if [[ -n ${BASH_SOURCE[0]} ]]; then
SCRIPTPATH=$( cd $(dirname ${BASH_SOURCE[0]}) ; pwd -P )
else
SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
fi

EXTENSION_ROOTPATH="$SCRIPTPATH/../../"
SOLR_INSTALL_PATH="/opt/solr-tomcat/"

DEFAULT_TYPO3_VERSION="^11.5.14"
DEFAULT_PHP_CS_FIXER_VERSION="^3.2.1"
DEFAULT_TYPO3_VERSION="11"
DEFAULT_TYPO3_DATABASE_HOST="localhost"
DEFAULT_TYPO3_DATABASE_NAME="test"
DEFAULT_TYPO3_DATABASE_USERNAME="root"
DEFAULT_TYPO3_DATABASE_PASSWORD="supersecret"

if [[ $* == *--use-defaults* ]]; then
export TYPO3_VERSION=$DEFAULT_TYPO3_VERSION
export PHP_CS_FIXER_VERSION=$DEFAULT_PHP_CS_FIXER_VERSION
export TYPO3_DATABASE_HOST=$DEFAULT_TYPO3_DATABASE_HOST
export TYPO3_DATABASE_NAME=$DEFAULT_TYPO3_DATABASE_NAME
export TYPO3_DATABASE_USERNAME=$DEFAULT_TYPO3_DATABASE_USERNAME
Expand All @@ -31,11 +20,6 @@ if [[ $* == *--local* ]]; then
if [ -z "$typo3Version" ]; then typo3Version=$DEFAULT_TYPO3_VERSION; fi
export TYPO3_VERSION=$typo3Version

echo -n "Choose a php-cs-fixer version [defaults: " $DEFAULT_PHP_CS_FIXER_VERSION"] : "
read phpCSFixerVersion
if [ -z "$phpCSFixerVersion" ]; then phpCSFixerVersion=$DEFAULT_PHP_CS_FIXER_VERSION; fi
export PHP_CS_FIXER_VERSION=$phpCSFixerVersion

echo -n "Choose a database hostname: [defaults: " $DEFAULT_TYPO3_DATABASE_HOST"] : "
read typo3DbHost
if [ -z "$typo3DbHost" ]; then typo3DbHost=$DEFAULT_TYPO3_DATABASE_HOST; fi
Expand All @@ -57,51 +41,39 @@ if [[ $* == *--local* ]]; then
export TYPO3_DATABASE_PASSWORD=$typo3DbPassword
fi

echo "Using TYPO3 Version: $TYPO3_VERSION"
echo "Using PHP-CS Fixer Version: $PHP_CS_FIXER_VERSION"
echo "Using database host: $TYPO3_DATABASE_HOST"
echo "Using database dbname: $TYPO3_DATABASE_NAME"
echo "Using database user: $TYPO3_DATABASE_USERNAME"
echo "Using database password: $TYPO3_DATABASE_PASSWORD"

if [ -z $TYPO3_VERSION ]; then
echo "Must set env var TYPO3_VERSION (e.g. dev-main or ^11.5)"
exit 1
fi

# Use latest TYPO3 LTS stable version, if version number is compatible with get.typo3.org API
if [[ $TYPO3_VERSION =~ ^[0-9]+$ ]] ; then
TYPO3_VERSION=$("${BASH_SOURCE%/*}/../Helpers/TYPO3_GET_LATEST_VERSION.sh" "$TYPO3_VERSION")
fi

if ! wget --version > /dev/null 2>&1
then
echo "Couldn't find wget."
exit 1
fi

COMPOSER_NO_INTERACTION=1
# Use latest TYPO3 LTS stable version, if version number is compatible with get.typo3.org API
if [[ $TYPO3_VERSION =~ ^[0-9]+$ ]] ; then
TYPO3_VERSION=$("${BASH_SOURCE%/*}/../Helpers/TYPO3_GET_LATEST_VERSION.sh" "$TYPO3_VERSION")
fi

# Setup TYPO3 environment variables
export TYPO3_PATH_PACKAGES="${EXTENSION_ROOTPATH}.Build/vendor/"
export TYPO3_PATH_WEB="${EXTENSION_ROOTPATH}.Build/Web/"
echo "Using TYPO3 Version: $TYPO3_VERSION"
echo "Using database host: $TYPO3_DATABASE_HOST"
echo "Using database dbname: $TYPO3_DATABASE_NAME"
echo "Using database user: $TYPO3_DATABASE_USERNAME"
echo "Using database password: $TYPO3_DATABASE_PASSWORD"

echo "Installing test environment"
echo "Using extension path $EXTENSION_ROOTPATH"
echo "Using package path $TYPO3_PATH_PACKAGES"
echo "Using web path $TYPO3_PATH_WEB"

export COMPOSER_NO_INTERACTION=1
if ! composer "tests:setup"; then
echo "The test environment could not be installed by composer as expected. Please fix this issue."
exit 1
fi

echo "Install third party tools globally:"
export PATH=$PATH:$(composer config --global home)/vendor/bin
if ! composer tests:setup:global-require
then
"The test environment could not be installed by composer as expected. Please fix this issue."
echo "The test environment could not be installed by composer as expected. Please fix this issue."
exit 1
fi

mkdir -p $TYPO3_PATH_WEB/uploads $TYPO3_PATH_WEB/typo3temp
42 changes: 22 additions & 20 deletions Build/Test/cibuild.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#!/usr/bin/env bash

TYPO3_PATH_WEB="$(pwd)/.Build/Web/"
export TYPO3_PATH_WEB
TYPO3_PATH_PACKAGES="$(pwd)/.Build/vendor/"
export TYPO3_PATH_PACKAGES

TYPO3_BIN_DIR="$(pwd)/.Build/bin/"
export TYPO3_BIN_DIR
export PATH="$TYPO3_BIN_DIR:$PATH"
EXIT_CODE=0

COMPOSERS_BIN_DIR="$(composer config home)/vendor/bin"
# Add COMPOSERS_BIN_DIR to $PATH, if not present
Expand All @@ -25,7 +18,7 @@ echo "Run PHP Lint"
if ! find . -name \*.php ! -path "./.Build/*" 2>/dev/null | parallel --gnu php -d display_errors=stderr -l {} > /dev/null
then
echo "There are syntax errors, please check and fix them."
exit 1
EXIT_CODE=1
else
echo "No syntax errors! Great job!"
fi
Expand All @@ -36,28 +29,36 @@ then
echo "Some files are not compliant to TYPO3 Coding Standards"
echo "Please fix the files listed above."
echo "Tip for auto fix: "
echo " composer tests:setup && composer t3:standards:fix"
exit 1
echo " TYPO3_VERSION=\"${TYPO3_VERSION}\" composer tests:setup && composer t3:standards:fix"
EXIT_CODE=3
else
echo "The code is TYPO3 Coding Standards compliant! Great job!"
fi
echo -e "\n\n"

echo "Run XML Lint"
if ! composer tests:lint-xml
then
echo "Some XML files are not valid"
echo "Please fix the files listed above"
exit 1
EXIT_CODE=4
fi

echo -e "\n\n"
echo "Run PHPStan analysis"
if ! composer tests:phpstan
then
# disable fail temporary
#EXIT_CODE=7
echo "Error during running the PHPStan analysis, please check and fix them."
echo "Tip for working on them: "
echo " TYPO3_VERSION=\"${TYPO3_VERSION}\" composer tests:setup && composer tests:phpstan"
fi

echo -e "\n\n"
echo "Run unit tests"
UNIT_BOOTSTRAP="Build/Test/UnitTestsBootstrap.php"
if ! .Build/bin/phpunit --colors -c Build/Test/UnitTests.xml --bootstrap=$UNIT_BOOTSTRAP --colors --coverage-text
if ! composer tests:unit -- --coverage-clover=coverage.unit.clover
then
echo "Error during running the unit tests please check and fix them"
exit 1
EXIT_CODE=5
fi

#
Expand Down Expand Up @@ -94,9 +95,10 @@ fi

echo -e "\n\n"
echo "Run integration tests"
INTEGRATION_BOOTSTRAP="Build/Test/IntegrationTestsBootstrap.php"
if ! .Build/bin/phpunit --colors -c Build/Test/IntegrationTests.xml --bootstrap=$INTEGRATION_BOOTSTRAP --colors --coverage-text
if ! composer tests:integration -- --coverage-clover=coverage.integration.clover
then
echo "Error during running the integration tests please check and fix them"
exit 1
EXIT_CODE=6
fi

exit $EXIT_CODE
5 changes: 5 additions & 0 deletions Build/Test/phpstan-constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

// testing-framework defines this, used in various tests.
define('ORIGINAL_ROOT', dirname(__FILE__, 2) . '/');
define('LF', "\n");
20 changes: 20 additions & 0 deletions Build/Test/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
includes:
- %rootDir%/../phpstan-phpunit/extension.neon

parameters:
level: 0
treatPhpDocTypesAsCertain: false

bootstrapFiles:
- phpstan-constants.php

universalObjectCratesClasses:
- ApacheSolrForTypo3\Solr\System\Solr\Document\Document
- ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\SearchResult

paths:
- %currentWorkingDirectory%/Classes
- %currentWorkingDirectory%/Tests

ignoreErrors:
- '#^Variable \$_EXTKEY might not be defined\.#'
1 change: 0 additions & 1 deletion Docker/Ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ TYPO3_DATABASE_NAME=typo3
TYPO3_DATABASE_HOST=db
TYPO3_DATABASE_USERNAME=typo3
TYPO3_DATABASE_PASSWORD=typo3
PHP_CS_FIXER_VERSION=^2.11
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

Loading

0 comments on commit a48f30e

Please sign in to comment.