Skip to content

Convert extension to use JoRobo #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,49 @@
kind: pipeline
name: default

clone:

steps:
- name: composer
image: joomlaprojects/docker-images:php7.4
image: joomlaprojects/docker-images:php8.3
volumes:
- name: composer-cache
path: /tmp/composer-cache
commands:
- composer validate --no-check-all --strict
- composer install --no-progress --no-suggest
- composer install --no-progress --ignore-platform-reqs

- name: phpcs
image: joomlaprojects/docker-images:php7.2
image: joomlaprojects/docker-images:php8.1
depends_on: [ composer ]
commands:
- echo $(date)
- ./administrator/components/com_patchtester/vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml .
- ./vendor/bin/php-cs-fixer fix -vvv --dry-run --diff
- ./vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml src/
- echo $(date)

- name: prepare_tests
depends_on: [ composer ]
image: joomlaprojects/docker-images:cypress8.2
commands:
- vendor/bin/robo build
- curl https://joomla.org/latest -L --output joomla.zip
- mkdir joomla
- cp joomla.zip joomla/joomla.zip
- cd joomla
- unzip joomla.zip

- name: phpstan
image: joomlaprojects/docker-images:php8.2
depends_on: [ prepare_tests ]
failure: ignore
commands:
- vendor/bin/phpstan

volumes:
- name: composer-cache
host:
path: /tmp/composer-cache

---
kind: signature
hmac: 6894a15e535673bd3eb1cf2c8ee3f9cbac4b5a6e52aa26773add3e4943f3bd86
hmac: 185a81743827fe02d6281724b30bdb25fb6e161f68d545483fa1924e61874b57

...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# Build #
/build/logs
/dist

# IDE & System #
/.buildpath
Expand All @@ -18,4 +19,4 @@
/.idea

# Composer Install #
/administrator/components/com_patchtester/vendor
/vendor
79 changes: 79 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* @package Joomla.Site
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

/**
* This is the configuration file for php-cs-fixer
*
* @see https://github.com/FriendsOfPHP/PHP-CS-Fixer
* @see https://mlocati.github.io/php-cs-fixer-configurator/#version:3.0
*
*
* If you would like to run the automated clean up, then open a command line and type one of the commands below
*
* To run a quick dry run to see the files that would be modified:
*
* ./component/backend/vendor/bin/php-cs-fixer fix --dry-run
*
* To run a full check, with automated fixing of each problem :
*
* ./component/backend/vendor/bin/php-cs-fixer fix
*
* You can run the clean up on a single file if you need to, this is faster
*
* ./component/backend/vendor/bin/php-cs-fixer fix --dry-run administrator/index.php
* ./component/backend/vendor/bin/php-cs-fixer fix administrator/index.php
*/

// Add all the core Joomla folders
$finder = PhpCsFixer\Finder::create()
->in(
[
__DIR__ . '/src',
]
)
// Ignore template files as PHP CS fixer can't handle them properly
// https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/3702#issuecomment-396717120
->notPath('/vendor/')
->notPath('/tmpl/');

$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setHideProgress(false)
->setUsingCache(false)
->setRules(
[
// Basic ruleset is PSR 12
'@PSR12' => true,
// Short array syntax
'array_syntax' => ['syntax' => 'short'],
// List of values separated by a comma is contained on a single line should not have a trailing comma like [$foo, $bar,] = ...
'no_trailing_comma_in_singleline' => true,
// Arrays on multiline should have a trailing comma
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
// Align elements in multiline array and variable declarations on new lines below each other
'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align', '??=' => 'align']],
// The "No break" comment in switch statements
'no_break_comment' => ['comment_text' => 'No break'],
// Remove unused imports
'no_unused_imports' => true,
// Classes from the global namespace should not be imported
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
// Alpha order imports
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
// There should not be useless else cases
'no_useless_else' => true,
// Native function invocation
'native_function_invocation' => ['include' => ['@compiler_optimized']],
// Adds null to type declarations when parameter have a default null value
'nullable_type_declaration_for_default_null_value' => true,
]
)
->setFinder($finder);

return $config;
99 changes: 99 additions & 0 deletions RoboFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

/**
* This is project's console commands configuration for Robo task runner.
*
* Download robo.phar from http://robo.li/robo.phar and type in the root of the repo: $ php robo.phar
* Or do: $ composer update, and afterwards you will be able to execute robo like $ php vendor/bin/robo
*
* @package Joomla.Site
* @subpackage RoboFile
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

use Joomla\Jorobo\Tasks\Tasks as loadReleaseTasks;
use Robo\Tasks;

require_once 'vendor/autoload.php';

if (!defined('JPATH_BASE')) {
define('JPATH_BASE', __DIR__);
}

/**
* Modern php task runner for Joomla! Browser Automated Tests execution
*
* @package RoboFile
*
* @since 1.0
*/
class RoboFile extends Tasks
{
// Load tasks from composer, see composer.json
use loadReleaseTasks;

/**
* Constructor
*/
public function __construct()
{
// Set default timezone (so no warnings are generated if it is not set)
date_default_timezone_set('UTC');
}

/**
* Build the joomla extension package
*
* @param array $params Additional params
*
* @return void
*/
public function build($params = ['dev' => false])
{
if (!file_exists('jorobo.ini')) {
$this->_copy('jorobo.dist.ini', 'jorobo.ini');
}

$this->task(\Joomla\Jorobo\Tasks\Build::class, $params)->run();
}

/**
* Update copyright headers for this project. (Set the text up in the jorobo.ini)
*
* @return void
*/
public function headers()
{
if (!file_exists('jorobo.ini')) {
$this->_copy('jorobo.dist.ini', 'jorobo.ini');
}

$this->task(\Joomla\Jorobo\Tasks\CopyrightHeader::class)->run();
}

/**
* Update Version __DEPLOY_VERSION__ in Component. (Set the version up in the jorobo.ini)
*
* @return void
*/
public function bump()
{
$this->task(\Joomla\Jorobo\Tasks\BumpVersion::class)->run();
}

/**
* Map into Joomla installation.
*
* @param String $target The target joomla instance
*
* @return void
* @since __DEPLOY_VERSION__
*
*/
public function map($target)
{
$this->task(\Joomla\Jorobo\Tasks\Map::class, $target)->run();
}
}
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
"homepage": "https://github.com/joomla-extensions/patchtester",
"license": "GPL-2.0-or-later",
"config": {
"vendor-dir": "administrator/components/com_patchtester/vendor",
"platform": {
"php": "7.2.5"
"php": "8.2.0"
}
},
"require": {
"php": "^7.2",
"php": "^8.2",
"ext-json": "*"
},
"require-dev": {
"squizlabs/php_codesniffer": "~3.0"
"squizlabs/php_codesniffer": "^3.12",
"joomla-projects/jorobo": "^0.12.1",
"friendsofphp/php-cs-fixer": "^3.75",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-deprecation-rules": "^2.0"
}
}
Loading