-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Add github actions and reconfigure paths for linters
- Loading branch information
Showing
11 changed files
with
2,412 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: tests core 11 | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
code-quality: | ||
name: "code quality with core v11" | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-version: [ '7.4'] | ||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Prepare dependencies for TYPO3 v11" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s composerUpdate" | ||
|
||
# Disabled, as latest installable version of TypoScript linter does not support the TYPO3 backend layout | ||
# override syntax in PageTSConfig files. | ||
# @see https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-96812-OverrideBackendTemplatesWithTSconfig.html | ||
# - name: "Run TypoScript lint" | ||
# run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s lintTypoScript" | ||
|
||
- name: "Run PHP lint" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s lintPhp" | ||
|
||
- name: "Validate CGL" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s cgl" | ||
|
||
- name: "Ensure tests methods do not start with \"test\"" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s checkTestMethodsPrefix" | ||
|
||
- name: "Ensure UTF-8 files do not contain BOM" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s checkBom" | ||
|
||
- name: "Test .rst files for integrity" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s checkRst" | ||
|
||
- name: "Find duplicate exception codes" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s checkExceptionCodes" | ||
|
||
- name: "Run PHPStan" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s phpstan" | ||
|
||
typoscript: | ||
name: "Linting TypoScript and TSConfig files" | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Prepare dependencies for TYPO3 v11" | ||
run: "Build/Scripts/runTests.sh -t 11 -p 8.1 -s composerUpdate" | ||
|
||
|
||
testsuite: | ||
name: all tests with core v11 | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- code-quality | ||
- typoscript | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-version: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] | ||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Prepare dependencies for TYPO3 v11" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s composerUpdate" | ||
|
||
- name: "Unit" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s unit" | ||
|
||
- name: "Functional SQLite" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s functional -d sqlite" | ||
|
||
- name: "Functional MariaDB 10.5 mysqli" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s functional -d mariadb -a mysqli" | ||
|
||
- name: "Functional MariaDB 10.5 pdo_mysql" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s functional -d mariadb -a pdo_mysql" | ||
|
||
- name: "Functional MySQL 8.0 mysqli" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s functional -d mariadb -a mysqli" | ||
|
||
- name: "Functional MySQL 8.0 pdo_mysql" | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s functional -d mariadb -a pdo_mysql" | ||
|
||
- name: "Functional PostgresSQL 10" | ||
# v11 postgres functional disabled with PHP 8.2 since https://github.com/doctrine/dbal/commit/73eec6d882b99e1e2d2d937accca89c1bd91b2d7 | ||
# is not fixed in doctrine core v11 doctrine 2.13.9 | ||
if: ${{ matrix.php <= '8.1' }} | ||
run: "Build/Scripts/runTests.sh -t 11 -p ${{ matrix.php-version }} -s functional -d postgres" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
######################### | ||
# | ||
# Check all UTF-8 files do not contain BOM. | ||
# | ||
# It expects to be run from the core root. | ||
# | ||
########################## | ||
|
||
FILES=`find . -type f \ | ||
! -path "./.Build/*" \ | ||
! -path "./.git/*" \ | ||
! -path "./.php_cs.cache" \ | ||
! -path "./.php-cs-fixer.cache" \ | ||
! -path "./Documentation-GENERATED-temp/*" \ | ||
-print0 | xargs -0 -n1 -P8 file {} | grep 'UTF-8 Unicode (with BOM)'` | ||
|
||
if [ -n "${FILES}" ]; then | ||
echo "Found UTF-8 files with BOM:"; | ||
echo ${FILES}; | ||
exit 1; | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
composer_cleanup() { | ||
echo -e "💥 Cleanup folders" | ||
rm -Rf \ | ||
.Build/vendor/* \ | ||
.Build/var/* \ | ||
.Build/bin/* \ | ||
.Build/Web/typo3conf/ext/* \ | ||
.Build/Web/typo3/* \ | ||
.Build/Web/typo3temp/* \ | ||
composer.lock | ||
} | ||
|
||
composer_update() { | ||
echo -e "🔥 Update to selected dependencies" | ||
php -dxdebug.mode=off $(which composer) install | ||
|
||
echo -e "🌊 Restore composer.json" | ||
git restore composer.json | ||
} | ||
|
||
update_v12() { | ||
echo -e "💪 Enforce TYPO3 v12" | ||
php -dxdebug.mode=off $(which composer) require --no-update \ | ||
"typo3/cms-core":"^12.4" | ||
|
||
echo -e "💪 Enforce PHPUnit ^10.1" | ||
php -dxdebug.mode=off $(which composer) req --dev --no-update \ | ||
"phpunit/phpunit":"^10.1" | ||
} | ||
|
||
update_v11() { | ||
echo -e "💪 Enforce TYPO3 v11" | ||
php -dxdebug.mode=off $(which composer) require --no-update \ | ||
"typo3/cms-core":"^11.5" | ||
|
||
echo -e "💪 Enforce PHPUnit ^9.6.8" | ||
php -dxdebug.mode=off $(which composer) req --dev --no-update \ | ||
"phpunit/phpunit":"^9.6.8" | ||
} | ||
|
||
case "$1" in | ||
12) | ||
composer_cleanup | ||
update_v12 | ||
composer_update | ||
;; | ||
11) | ||
composer_cleanup | ||
update_v11 | ||
composer_update | ||
;; | ||
*) | ||
echo -e "🌀 Usage: ddev update-to (11|12)" >&2 | ||
exit 0 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
#!/bin/bash | ||
|
||
######################### | ||
# | ||
# Find duplicate exception timestamps and list them. | ||
# Additionally find exceptions that have no exception code. | ||
# Optionally write the list of found exception codes to the standard output stream in JSON format. | ||
# | ||
# It expects to be run from the core root. | ||
# | ||
########################## | ||
|
||
# -------------------------- | ||
# --- default parameters --- | ||
# -------------------------- | ||
print=0 | ||
scanPath="Classes/" | ||
|
||
ignoreFiles=() | ||
ignoreFiles+="Service/Client/Client.php" | ||
|
||
|
||
# ------------------------ | ||
# --- print usage info --- | ||
# ------------------------ | ||
usage() | ||
{ | ||
echo "Usage: $0 [options] " | ||
echo " " | ||
echo "No arguments/default: Check exception numbers for duplicates. " | ||
echo " " | ||
echo "Options: " | ||
echo " -p " | ||
echo " Specifies whether the list of exceptions found should " | ||
echo " be output as JSON in the standard output stream. " | ||
echo " " | ||
echo " -h " | ||
echo " Show this help. " | ||
echo " " | ||
exit 0 | ||
} | ||
|
||
# ----------------------- | ||
# --- parsing of args --- | ||
# ----------------------- | ||
OPTIND=1 | ||
|
||
while getopts "hp" opt;do | ||
case "$opt" in | ||
h) | ||
usage | ||
;; | ||
p) | ||
print=1 | ||
;; | ||
*) | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
shift $((OPTIND-1)) | ||
|
||
# ------------------------------------------------ | ||
# --- print list of found exceptions to stdout --- | ||
# ------------------------------------------------ | ||
print_exceptions() { | ||
IFS=$'\n' sorted=($(sort -u <<<"${exceptionCodes[*]}")); unset IFS | ||
|
||
local numExceptions=${#sorted[@]} | ||
|
||
printf "{\n" | ||
printf " \"exceptions\": {\n" | ||
if [ ${numExceptions} -gt 0 ]; then | ||
for (( i=0; i<${numExceptions}-1; i++ )); | ||
do | ||
printf " \"%s\":\"%s\",\n" "${sorted[$i]}" "${sorted[$i]}" | ||
done | ||
printf " \"%s\":\"%s\"\n" "${sorted[${numExceptions}-1]}" "${sorted[${numExceptions}-1]}" | ||
fi | ||
printf " },\n" | ||
printf " \"total\":%s\n" "${numExceptions}" | ||
printf "}\n" | ||
} | ||
|
||
# ------------------------------------------------------------------------------- | ||
# --- check PHP files recursively for missing and duplicate exception numbers --- | ||
# ------------------------------------------------------------------------------- | ||
scan_exceptions() { | ||
local foundNewFile=0 | ||
local oldFilename="" | ||
local firstLineOfMatch="" | ||
local foundExceptionInFile=1 | ||
local exceptionCodes=() | ||
|
||
# grep | ||
# '-r' recursive | ||
# '--include '*.php'' in all .php files | ||
# '-Pzoab' pcre regex, -zo remove all linebreaks for multiline match, treat all files as text, output position "filename:position: match", binary position | ||
# | ||
# (?:(?!Exception\()[\w\\])* negative lookahead. capture all alphanum and \ until we reach "Exception(" | ||
# eat "Exception(" | ||
# (?:(?!\);).|[\r\n])*\);[\r\n]+ negative lookahead again, eat everything including a \n until we reach the first ");", then line breaks | ||
|
||
cd "$scanPath" || exit 1 | ||
|
||
grep \ | ||
-r \ | ||
--include '*.php' \ | ||
-Pzoab \ | ||
'new (?:(?!Exception\()[\w\\])*Exception\((?:(?!\);).|[\r\n])*\);[\r\n]+' \ | ||
| \ | ||
{ | ||
while read line; | ||
do | ||
possibleFilename=`echo ${line} | cut -d':' -f1` | ||
if [[ ${possibleFilename} =~ .php$ ]]; then | ||
# the matched line consists of a file name match, we're dealing with a new match here. | ||
foundNewFile=1 | ||
oldFilename=${currentFilename} | ||
currentFilename=${possibleFilename} | ||
else | ||
foundNewFile=0 | ||
fi | ||
|
||
# skip file if in blacklist | ||
if [[ {$ignoreFiles[@]} =~ ${currentFilename} ]]; then | ||
continue | ||
fi | ||
|
||
# check for match in previous file name | ||
if [[ ${foundNewFile} -eq 1 ]] && [[ ${foundExceptionInFile} -eq 0 ]]; then | ||
if [ "$print" -ne "1" ]; then | ||
# checking exception codes: exit | ||
# listing exception codes: ignore | ||
echo "File: $oldFilename" | ||
echo "The created exception contains no 10 digit exception code as second argument, in or below this line:" | ||
echo "$firstLineOfMatch" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# reset found flag if we're handling new file | ||
if [[ ${foundNewFile} -eq 1 ]]; then | ||
foundExceptionInFile=0 | ||
firstLineOfMatch=${line} | ||
fi | ||
|
||
# see if the line consists of an exception code | ||
if [[ "$line" =~ .*([0-9]{10}).* ]]; then | ||
foundExceptionInFile=1 | ||
exceptionCode=${BASH_REMATCH[1]} | ||
# check if that code was registered already | ||
if [[ " ${exceptionCodes[@]} " =~ " ${exceptionCode} " ]]; then | ||
if [ "$print" -ne "1" ]; then | ||
# checking exception codes: exit | ||
# listing exception codes: ignore | ||
echo "Duplicate exception code ${exceptionCode} in file:" | ||
echo ${currentFilename} | ||
exit 1 | ||
fi | ||
fi | ||
exceptionCodes+=(${exceptionCode}) | ||
fi | ||
done || exit 1 | ||
|
||
if [ "$print" -eq "1" ]; then | ||
print_exceptions | ||
fi | ||
|
||
exit 0 | ||
} | ||
|
||
exitCode=$? | ||
|
||
cd - > /dev/null | ||
|
||
exit $exitCode | ||
} | ||
|
||
scan_exceptions |
Oops, something went wrong.