Skip to content

Commit

Permalink
chore: add phpchecks
Browse files Browse the repository at this point in the history
  • Loading branch information
eaCe committed Sep 3, 2022
1 parent fccc3f1 commit b94060d
Show file tree
Hide file tree
Showing 14 changed files with 3,153 additions and 23 deletions.
46 changes: 46 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.php]
indent_size = 4
ij_php_special_else_if_treatment = false
ij_any_special_else_if_treatment = false
ij_php_block_brace_style = end_of_line
ij_php_class_brace_style = next_line
ij_php_method_brace_style = next_line
ij_php_anonymous_brace_style = end_of_line
ij_php_catch_on_new_line = true
ij_php_else_on_new_line = true
ij_php_finally_on_new_line = true
ij_php_for_brace_force = always
ij_php_if_brace_force = never
ij_php_space_after_type_cast = true
ij_php_space_after_colon_in_return_type = true
ij_php_blank_lines_after_imports = 1
ij_php_blank_lines_before_imports = 1
ij_php_align_class_constants = false
ij_php_align_assignments = false
ij_php_align_inline_comments = false
ij_php_align_key_value_pairs = false
ij_php_align_group_field_declarations = false
ij_php_align_multiline_array_initializer_expression = false
ij_php_align_multiline_for = false
ij_php_align_phpdoc_comments = false
ij_php_align_phpdoc_param_names = false
ij_php_import_sorting = alphabetic
ij_php_blank_lines_after_class_header = 0
ij_php_blank_lines_before_class_end = 0
ij_php_else_if_style = separate
ij_any_else_on_new_line = false

[*.html]
indent_size = 4
48 changes: 48 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
'root': true,
'extends': 'eslint:recommended',
'globals': {
'wp': true,
},
'env': {
'node': true,
'es6': true,
'amd': true,
'browser': true,
'jquery': true,
},
'parserOptions': {
'ecmaFeatures': {
'globalReturn': true,
'generators': false,
'objectLiteralDuplicateProperties': false,
'experimentalObjectRestSpread': true,
},
'ecmaVersion': 2018,
'sourceType': 'module',
},
'plugins': [
'import',
],
'settings': {
'import/core-modules': [],
'import/ignore': [
'node_modules',
'\\.(coffee|scss|css|less|hbs|svg|json)$',
],
},
'rules': {
'no-console': 0,
'quotes': ['error', 'single'],
'comma-dangle': [
'error',
{
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'always-multiline',
'exports': 'always-multiline',
'functions': 'ignore',
},
],
},
};
28 changes: 28 additions & 0 deletions .github/workflows/default.config.yml.github-action.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/redaxo_cms/redaxo/src/core/default.config.yml b/redaxo_cms/redaxo/src/core/default.config.yml
index 2880a09e9..3485d830a 100644
--- a/redaxo_cms/redaxo/src/core/default.config.yml
+++ b/redaxo_cms/redaxo/src/core/default.config.yml
@@ -1,8 +1,8 @@
setup: true
debug:
- enabled: false
- throw_always_exception: false # `true` for all error levels, `[E_WARNING, E_NOTICE]` for subset
-instname: null
+ enabled: true
+ throw_always_exception: true # `true` for all error levels, `[E_WARNING, E_NOTICE]` for subset
+instname: 57d0619b2d578f108506a917826ea8b62c1c3eea
server: https://www.redaxo.org/
servername: REDAXO
error_email: null
@@ -64,9 +64,9 @@ table_prefix: rex_
temp_prefix: tmp_
db:
1:
- host: localhost
+ host: 127.0.0.1
login: root
- password: ''
+ password: root
name: redaxo5
persistent: false
ssl_key: null
77 changes: 77 additions & 0 deletions .github/workflows/phpchecks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: PHP checks

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

permissions:
contents: read

jobs:
check:

runs-on: ubuntu-latest
permissions:
contents: write # for Git to git apply

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: gd, intl, pdo_mysql
coverage: none # disable xdebug, pcov

# credits https://blog.markvincze.com/download-artifacts-from-a-latest-github-release-in-sh-and-powershell/
- name: Download latest REDAXO release
run: |
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/redaxo/redaxo/releases/latest)
REDAXO_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
echo "Downloaded REDAXO $REDAXO_VERSION"
curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/$REDAXO_VERSION/redaxo_$REDAXO_VERSION.zip
unzip -oq redaxo.zip -d redaxo_cms
rm redaxo.zip
- name: Init database
run: |
sudo /etc/init.d/mysql start
mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo5;'
git apply .github/workflows/default.config.yml.github-action.diff
- name: Setup REDAXO
run: |
php redaxo_cms/redaxo/bin/console setup:run -n --lang=de_de --agree-license --db-password=root --db-createdb=no --db-setup=normal --admin-username=admin --admin-password=adminpassword [email protected] --ansi
# copy Addon files, ignore some directories...
# install phpmailer
# install the addon
# if the addon name does not match the repository name, ${{ github.event.repository.name }} must be replaced with the addon name
- name: Copy and install Addons
run: |
rsync -av --exclude='vendor' --exclude='.github' --exclude='.git' --exclude='redaxo_cms' './' 'redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}'
redaxo_cms/redaxo/bin/console package:install '${{ github.event.repository.name }}'
- name: Install test dependencies
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
env:
COMPOSER: composer.json
run: composer install --prefer-dist --no-progress

- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run lint
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
run: composer lint

- name: Run phpcs
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
run: composer phpcs

# - name: Run phpunit
# working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
# run: composer test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.idea/
/vendor/
34 changes: 34 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
'extends': 'stylelint-config-standard',
'rules': {
'no-empty-source': null,
'string-quotes': 'double',
'at-rule-no-unknown': [
true,
{
'ignoreAtRules': [
'extend',
'at-root',
'debug',
'warn',
'error',
'if',
'else',
'for',
'each',
'while',
'mixin',
'include',
'content',
'return',
'function',
'tailwind',
'apply',
'responsive',
'variants',
'screen',
],
},
],
},
};
13 changes: 13 additions & 0 deletions .tools/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

unset($REX);
$REX['REDAXO'] = true;
$REX['HTDOCS_PATH'] = '../../../../';
$REX['BACKEND_FOLDER'] = 'redaxo';
$REX['LOAD_PAGE'] = false;

require __DIR__.'../../../../core/boot.php';
require __DIR__.'../../../../core/packages.php';

// use original error handlers of the tools
rex_error_handler::unregister();
14 changes: 14 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"license": "MIT",
"scripts": {
"lint": "phplint ./ --exclude=vendor --no-cache lib",
"phpcs": "phpcs --ignore=*/vendor/* --extensions=php --standard=phpcs.xml lib",
"phpcbf": "phpcbf --extensions=php --standard=phpcs.xml lib",
"test": "phpunit --testdox"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.6",
"overtrue/phplint": "^4.1"
}
}
Loading

0 comments on commit b94060d

Please sign in to comment.