Skip to content

Commit 04655c3

Browse files
authored
Merge pull request #76 from nextcloud/enh/noid/adjust-21
CI adjustments and code maintenance for NC 21
2 parents 1ebc1ce + 01dba07 commit 04655c3

File tree

7 files changed

+206
-125
lines changed

7 files changed

+206
-125
lines changed

.drone.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- stable*
9+
10+
jobs:
11+
php:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
php-versions: ['7.3', '7.4', '8.0']
17+
18+
name: php${{ matrix.php-versions }}
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Set up php ${{ matrix.php-versions }}
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php-versions }}
26+
coverage: none
27+
28+
- name: Lint
29+
run: composer run lint || ( echo 'Please run `composer run lint` and fix your code' && exit 1 )
30+
31+
php-cs-fixer:
32+
runs-on: ubuntu-latest
33+
34+
strategy:
35+
matrix:
36+
php-versions: ['7.4']
37+
38+
name: cs php${{ matrix.php-versions }}
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v2
42+
43+
- name: Set up php
44+
uses: shivammathur/setup-php@v2
45+
with:
46+
php-version: ${{ matrix.php-versions }}
47+
coverage: none
48+
49+
- name: Install dependencies
50+
run: composer i
51+
52+
- name: Run coding standards check
53+
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
54+
55+
xml-linters:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@master
60+
- name: Download schema
61+
run: wget https://apps.nextcloud.com/schema/apps/info.xsd
62+
- name: Lint info.xml
63+
uses: ChristophWurst/xmllint-action@v1
64+
with:
65+
xml-file: ./appinfo/info.xml
66+
xml-schema-file: ./info.xsd

.nextcloudignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ composer.*
66
krankerl.toml
77
l10n/.gitkeep
88
.nextcloudignore
9+
.php_cs.dist
910
README.md
1011
screenshots
1112
tests

.php_cs.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require_once './vendor/autoload.php';
6+
7+
use Nextcloud\CodingStandard\Config;
8+
9+
$config = new Config();
10+
$config
11+
->getFinder()
12+
->ignoreVCSIgnored(true)
13+
->notPath('build')
14+
->notPath('l10n')
15+
->notPath('src')
16+
->notPath('vendor')
17+
->in(__DIR__);
18+
return $config;

composer.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
{
2-
"require-dev": {
3-
"php-parallel-lint/php-parallel-lint": "^1.2"
4-
}
2+
"autoload-dev": {
3+
"psr-4": {
4+
"OCP\\": "vendor/christophwurst/nextcloud/OCP",
5+
"OCA\\WorkflowScript\\": "lib/"
6+
}
7+
},
8+
"scripts": {
9+
"cs:check": "php-cs-fixer fix --dry-run --diff",
10+
"cs:fix": "php-cs-fixer fix",
11+
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './build/*' -not -path './tests/integration/vendor/*' -print0 | xargs -0 -n1 php -l"
12+
},
13+
"require-dev": {
14+
"nextcloud/coding-standard": "^0.5.0",
15+
"christophwurst/nextcloud": "dev-master"
16+
}
517
}

lib/BackgroundJobs/Launcher.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@
2323

2424
namespace OCA\WorkflowScript\BackgroundJobs;
2525

26+
use Exception;
27+
use OC\BackgroundJob\QueuedJob;
28+
use OC\Files\View;
2629
use OCP\Files\IRootFolder;
27-
use OCP\Files\NotFoundException;
28-
use OCP\ILogger;
2930
use OCP\ITempManager;
31+
use Psr\Log\LoggerInterface;
3032

31-
class Launcher extends \OC\BackgroundJob\QueuedJob {
33+
class Launcher extends QueuedJob {
3234

33-
/** @var ILogger */
35+
/** @var LoggerInterface */
3436
protected $logger;
3537
/** @var ITempManager */
3638
private $tempManager;
@@ -40,9 +42,9 @@ class Launcher extends \OC\BackgroundJob\QueuedJob {
4042
/**
4143
* BackgroundJob constructor.
4244
*
43-
* @param ILogger $logger
45+
* @param LoggerInterface $logger
4446
*/
45-
public function __construct(ILogger $logger, ITempManager $tempManager, IRootFolder $rootFolder) {
47+
public function __construct(LoggerInterface $logger, ITempManager $tempManager, IRootFolder $rootFolder) {
4648
$this->logger = $logger;
4749
$this->tempManager = $tempManager;
4850
$this->rootFolder = $rootFolder;
@@ -54,13 +56,16 @@ public function __construct(ILogger $logger, ITempManager $tempManager, IRootFol
5456
protected function run($argument) {
5557
$command = (string)$argument['command'];
5658

57-
if(strpos($command, '%f')) {
59+
if (strpos($command, '%f')) {
5860
$path = isset($argument['path']) ? (string)$argument['path'] : '';
5961
try {
60-
$view = new \OC\Files\View(dirname($path));
62+
$view = new View(dirname($path));
6163
$tmpFile = $view->toTmpFile(basename($path));
62-
} catch (\Exception $e) {
63-
$this->logger->logException($e, ['level' => ILogger::WARN, 'app' => 'workflow_script']);
64+
} catch (Exception $e) {
65+
$this->logger->warning($e->getMessage(), [
66+
'app' => 'workflow_script',
67+
'exception' => $e
68+
]);
6469
return;
6570
}
6671
$command = str_replace('%f', escapeshellarg($tmpFile), $command);

0 commit comments

Comments
 (0)