From 3ddd1792ef6f2bec08e96dc58f8e9b829d40c544 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jul 2024 11:29:21 +0200 Subject: [PATCH 1/6] fix: Use compact license and constructor Signed-off-by: Joas Schilling --- lib/AppInfo/Application.php | 22 ++---------- lib/BackgroundJob/ExpireUsers.php | 25 ++------------ lib/Service/RetentionService.php | 57 ++++++------------------------- lib/Settings/Admin.php | 45 +++++------------------- lib/SkipUserException.php | 31 ++++------------- templates/settings/admin.php | 19 ++--------- 6 files changed, 33 insertions(+), 166 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 311c452a..62592cdb 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -1,28 +1,12 @@ - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ - namespace OCA\UserRetention\AppInfo; - use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; diff --git a/lib/BackgroundJob/ExpireUsers.php b/lib/BackgroundJob/ExpireUsers.php index d473bc96..775342f4 100644 --- a/lib/BackgroundJob/ExpireUsers.php +++ b/lib/BackgroundJob/ExpireUsers.php @@ -1,27 +1,10 @@ - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ - namespace OCA\UserRetention\BackgroundJob; use OCA\UserRetention\Service\RetentionService; @@ -29,14 +12,12 @@ use OCP\BackgroundJob\TimedJob; class ExpireUsers extends TimedJob { - protected RetentionService $service; public function __construct( ITimeFactory $time, - RetentionService $service + protected RetentionService $service ) { parent::__construct($time); - $this->service = $service; // Every day $this->setInterval(60 * 60 * 24); diff --git a/lib/Service/RetentionService.php b/lib/Service/RetentionService.php index ae2f380e..70bf3603 100644 --- a/lib/Service/RetentionService.php +++ b/lib/Service/RetentionService.php @@ -1,29 +1,10 @@ - * - * @author Joas Schilling - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ - namespace OCA\UserRetention\Service; use OC\Authentication\Token\Manager; @@ -33,7 +14,6 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\IGroupManager; -use OCP\IL10N; use OCP\IServerContainer; use OCP\IUser; use OCP\IUserManager; @@ -44,15 +24,6 @@ use Psr\Log\LoggerInterface; class RetentionService { - protected IConfig $config; - protected IUserManager $userManager; - protected IGroupManager $groupManager; - protected ITimeFactory $time; - protected IServerContainer $server; - protected IMailer $mailer; - protected IFactory $l10nFactory; - protected LoggerInterface $logger; - protected int $userDaysDisable = 0; protected int $userDisableMaxLastLogin = 0; protected int $userDays = 0; @@ -67,23 +38,15 @@ class RetentionService { protected bool $keepUsersWithoutLogin = true; public function __construct( - IConfig $config, - IUserManager $userManager, - IGroupManager $groupManager, - ITimeFactory $time, - IServerContainer $server, - IMailer $mailer, - IFactory $l10nFactory, - LoggerInterface $logger + protected IConfig $config, + protected IUserManager $userManager, + protected IGroupManager $groupManager, + protected ITimeFactory $time, + protected IServerContainer $server, + protected IMailer $mailer, + protected IFactory $l10nFactory, + protected LoggerInterface $logger, ) { - $this->config = $config; - $this->userManager = $userManager; - $this->groupManager = $groupManager; - $this->time = $time; - $this->server = $server; - $this->mailer = $mailer; - $this->l10nFactory = $l10nFactory; - $this->logger = $logger; } public function runCron(): void { diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 9c5dc1a6..493e409c 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -1,25 +1,10 @@ - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ - namespace OCA\UserRetention\Settings; use OCP\App\IAppManager; @@ -31,24 +16,12 @@ use OCP\Settings\ISettings; class Admin implements ISettings { - - /** @var IConfig */ - private $config; - /** @var IInitialState */ - private $initialStateService; - /** @var IGroupManager */ - private $groupManager; - /** @var IAppManager */ - private $appManager; - - public function __construct(IConfig $config, - IInitialState $initialStateService, - IGroupManager $groupManager, - IAppManager $appManager) { - $this->config = $config; - $this->initialStateService = $initialStateService; - $this->groupManager = $groupManager; - $this->appManager = $appManager; + public function __construct( + protected IConfig $config, + protected IInitialState $initialStateService, + protected IGroupManager $groupManager, + protected IAppManager $appManager, + ) { } public function getForm(): TemplateResponse { diff --git a/lib/SkipUserException.php b/lib/SkipUserException.php index bce17a04..df0ebfec 100644 --- a/lib/SkipUserException.php +++ b/lib/SkipUserException.php @@ -1,37 +1,18 @@ - * - * @author Joas Schilling - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ - namespace OCA\UserRetention; class SkipUserException extends \RuntimeException { - protected array $logParameters; - - public function __construct(string $logMessage = '', array $logParameters = []) { + public function __construct( + string $logMessage = '', + protected array $logParameters = [], + ) { parent::__construct($logMessage); - $this->logParameters = $logParameters; } public function getLogParameters(): array { diff --git a/templates/settings/admin.php b/templates/settings/admin.php index 8b77522b..b3ed4a75 100644 --- a/templates/settings/admin.php +++ b/templates/settings/admin.php @@ -1,23 +1,8 @@ - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ script('user_retention', 'user_retention-main'); ?> From 0264ed7343a2b826858f8a1c2a9ed45d6824cb2e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jul 2024 11:30:46 +0200 Subject: [PATCH 2/6] fix: Cleanup tests Signed-off-by: Joas Schilling --- tests/Service/RetentionServiceTest.php | 60 ++++++-------------------- tests/bootstrap.php | 23 ++-------- 2 files changed, 18 insertions(+), 65 deletions(-) diff --git a/tests/Service/RetentionServiceTest.php b/tests/Service/RetentionServiceTest.php index b3f40bb1..07b44174 100644 --- a/tests/Service/RetentionServiceTest.php +++ b/tests/Service/RetentionServiceTest.php @@ -1,28 +1,14 @@ - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\UserRetention\Tests; use OC\Authentication\Token\Manager; use OC\Authentication\Token\PublicKeyToken; -use OCA\UserRetention\BackgroundJob\ExpireUsers; use OCA\UserRetention\Service\RetentionService; use OCA\UserRetention\SkipUserException; use OCP\AppFramework\Utility\ITimeFactory; @@ -38,22 +24,14 @@ use Test\TestCase; class RetentionServiceTest extends TestCase { - /** @var MockObject|IConfig */ - protected $config; - /** @var MockObject|IUserManager */ - protected $userManager; - /** @var MockObject|IGroupManager */ - protected $groupManager; - /** @var MockObject|ITimeFactory */ - protected $timeFactory; - /** @var MockObject|IServerContainer */ - protected $container; - /** @var MockObject|IMailer */ - protected $mailer; - /** @var MockObject|IFactory */ - protected $l10nFactory; - /** @var MockObject|LoggerInterface */ - protected $logger; + protected MockObject|IConfig $config; + protected MockObject|IUserManager $userManager; + protected MockObject|IGroupManager $groupManager; + protected MockObject|ITimeFactory $timeFactory; + protected MockObject|IServerContainer $container; + protected MockObject|IMailer $mailer; + protected MockObject|IFactory $l10nFactory; + protected MockObject|LoggerInterface $logger; protected function setUp(): void { parent::setUp(); @@ -145,11 +123,6 @@ public function dataShouldPerformActionOnUser(): array { /** * @dataProvider dataShouldPerformActionOnUser - * @param bool $skipWithoutLogin - * @param int $discoveryTimestamp - * @param int $lastLogin - * @param int $authTokenLastActivity - * @param bool $expectsThrow */ public function testShouldPerformActionOnUser(bool $skipWithoutLogin, int $discoveryTimestamp, int $lastLogin, ?int $authTokenLastActivity, ?int $skipOlderThan, bool $expectsThrow, ?int $expectedReturn = null): void { /** @var MockObject|RetentionService $service */ @@ -171,7 +144,7 @@ public function testShouldPerformActionOnUser(bool $skipWithoutLogin, int $disco ->willReturn($authTokenLastActivity); if ($expectsThrow) { - $this->expectException(SkipUserException::class); + $this->expectException(SkipUserException::class); self::invokePrivate($service, 'shouldPerformActionOnUser', [$user, 100_000, $skipOlderThan]); } else { $this->assertSame($expectedReturn, self::invokePrivate($service, 'shouldPerformActionOnUser', [$user, 100_000, $skipOlderThan])); @@ -187,9 +160,6 @@ public function dataSkipUserBasedOnDiscovery(): array { /** * @dataProvider dataSkipUserBasedOnDiscovery - * @param int $discoveryTimestamp - * @param int|null $newDiscoveryTimestamp - * @param bool $expectsThrow */ public function testSkipUserBasedOnDiscovery(int $discoveryTimestamp, ?int $newDiscoveryTimestamp, bool $expectsThrow): void { $service = $this->createService(); @@ -215,7 +185,7 @@ public function testSkipUserBasedOnDiscovery(int $discoveryTimestamp, ?int $newD } if ($expectsThrow) { - $this->expectException(SkipUserException::class); + $this->expectException(SkipUserException::class); } self::invokePrivate($service, 'skipUserBasedOnDiscovery', [$user]); } @@ -236,7 +206,6 @@ public function dataSkipUserBasedOnProtectedGroupMembership(): array { * @dataProvider dataSkipUserBasedOnProtectedGroupMembership * @param string[] $excludedGroups * @param string[] $groupMemberships - * @param bool $expectsThrow */ public function testSkipUserBasedOnProtectedGroupMembership(array $excludedGroups, array $groupMemberships, bool $expectsThrow): void { $service = $this->createService(); @@ -269,7 +238,6 @@ public function dataGetAuthTokensLastActivity(): array { /** * @dataProvider dataGetAuthTokensLastActivity * @param int[] $tokenActivities - * @param ?int $expected */ public function testGetAuthTokensLastActivity(array $tokenActivities, ?int $expected): void { $service = $this->createService(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 97864554..6912d9b9 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,24 +1,9 @@ - * - * @author Joas Schilling - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); From aa29279801169564987d6e17fe36c160d4847861 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jul 2024 11:31:33 +0200 Subject: [PATCH 3/6] ci: Add coding-standards Signed-off-by: Joas Schilling --- .gitignore | 1 + .php-cs-fixer.dist.php | 22 ++++++++++ composer.json | 5 ++- composer.lock | 95 +++++++++++++++++++++++++++++++++++++++++- psalm.xml | 35 +++++----------- 5 files changed, 131 insertions(+), 27 deletions(-) create mode 100644 .php-cs-fixer.dist.php diff --git a/.gitignore b/.gitignore index d36c8edd..99e26d2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.php-cs-fixer.cache /build /cypress/screenshots/ /cypress/videos/ diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 00000000..187a36e9 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,22 @@ +getFinder() + ->ignoreVCSIgnored(true) + ->notPath('build') + ->notPath('l10n') + ->notPath('src') + ->notPath('vendor') + ->in(__DIR__); +return $config; diff --git a/composer.json b/composer.json index 2cc6c042..3700ec6e 100644 --- a/composer.json +++ b/composer.json @@ -11,11 +11,14 @@ "sort-packages": true }, "require-dev": { + "nextcloud/coding-standard": "^1.2.1", "nextcloud/ocp": "dev-stable27", "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^5.9" + "vimeo/psalm": "^5.25" }, "scripts": { + "cs:check": "php-cs-fixer fix --dry-run --diff", + "cs:fix": "php-cs-fixer fix", "lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l", "psalm": "psalm --threads=1", "psalm:update-baseline": "psalm --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml", diff --git a/composer.lock b/composer.lock index a7fbbdd3..4f585aee 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b80c9ca3ded24e9bcfc2c8f89a6170f4", + "content-hash": "25592cc38a5d62008a4020daa6c79460", "packages": [], "packages-dev": [ { @@ -811,6 +811,47 @@ }, "time": "2024-01-31T06:18:54+00:00" }, + { + "name": "nextcloud/coding-standard", + "version": "v1.2.1", + "source": { + "type": "git", + "url": "https://github.com/nextcloud/coding-standard.git", + "reference": "cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e", + "reference": "cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e", + "shasum": "" + }, + "require": { + "php": "^7.3|^8.0", + "php-cs-fixer/shim": "^3.17" + }, + "type": "library", + "autoload": { + "psr-4": { + "Nextcloud\\CodingStandard\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christoph Wurst", + "email": "christoph@winzerhof-wurst.at" + } + ], + "description": "Nextcloud coding standards for the php cs fixer", + "support": { + "issues": "https://github.com/nextcloud/coding-standard/issues", + "source": "https://github.com/nextcloud/coding-standard/tree/v1.2.1" + }, + "time": "2024-02-01T14:54:37+00:00" + }, { "name": "nextcloud/ocp", "version": "dev-stable27", @@ -1029,6 +1070,58 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "php-cs-fixer/shim", + "version": "v3.60.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/shim.git", + "reference": "11f328afa9768eed89bacffab02f56263185058c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/11f328afa9768eed89bacffab02f56263185058c", + "reference": "11f328afa9768eed89bacffab02f56263185058c", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^7.4 || ^8.0" + }, + "replace": { + "friendsofphp/php-cs-fixer": "self.version" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters." + }, + "bin": [ + "php-cs-fixer", + "php-cs-fixer.phar" + ], + "type": "application", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "support": { + "issues": "https://github.com/PHP-CS-Fixer/shim/issues", + "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.60.0" + }, + "time": "2024-07-25T09:27:32+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", diff --git a/psalm.xml b/psalm.xml index 1914255c..d057fcc6 100644 --- a/psalm.xml +++ b/psalm.xml @@ -5,33 +5,18 @@ xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="tests/psalm-baseline.xml" + phpVersion="8.0" > - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + From fc959c7ef9f96675cbe7c54ceb4a332f638b400e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jul 2024 11:37:10 +0200 Subject: [PATCH 4/6] fix!: Bump Nextcloud requirements to 28-30 Signed-off-by: Joas Schilling --- .../workflows/update-nextcloud-ocp-matrix.yml | 2 +- CHANGELOG.md | 6 ++++++ appinfo/info.xml | 4 ++-- composer.json | 2 +- composer.lock | 18 +++++++++--------- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/update-nextcloud-ocp-matrix.yml b/.github/workflows/update-nextcloud-ocp-matrix.yml index 4b4bda51..61c7d8b1 100644 --- a/.github/workflows/update-nextcloud-ocp-matrix.yml +++ b/.github/workflows/update-nextcloud-ocp-matrix.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: branches: ['main'] - target: ['stable27'] + target: ['stable28'] name: update-nextcloud-ocp-${{ matrix.branches }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 81c51250..774a05da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog All notable changes to this project will be documented in this file. +## 1.13.0 – 2024-07-30 +### Changed +- ✨ Support Nextcloud 30 and require Nextcloud 28. +- 🗣️ Update translations. +- 🔌 Upgrade dependencies. + ## 1.12.1 – 2024-05-21 ### Fixed - AdminSettings: prevent checkbox double click diff --git a/appinfo/info.xml b/appinfo/info.xml index 795b9c73..69211fe8 100755 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -10,7 +10,7 @@ * ⛔ Exclude accounts based on group memberships (default: admin group) * 🔑 Exclude accounts that never logged in (default: enabled) ]]> - 1.12.1 + 1.13.0 agpl Joas Schilling UserRetention @@ -27,7 +27,7 @@ https://raw.githubusercontent.com/nextcloud/user_retention/main/docs/screenshot.png - + diff --git a/composer.json b/composer.json index 3700ec6e..08b03ed1 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ }, "require-dev": { "nextcloud/coding-standard": "^1.2.1", - "nextcloud/ocp": "dev-stable27", + "nextcloud/ocp": "dev-stable28", "phpunit/phpunit": "^9.5", "vimeo/psalm": "^5.25" }, diff --git a/composer.lock b/composer.lock index 4f585aee..1b94f486 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "25592cc38a5d62008a4020daa6c79460", + "content-hash": "98d2863dc8a991ac1e1ad963d25b440e", "packages": [], "packages-dev": [ { @@ -854,20 +854,20 @@ }, { "name": "nextcloud/ocp", - "version": "dev-stable27", + "version": "dev-stable28", "source": { "type": "git", "url": "https://github.com/nextcloud-deps/ocp.git", - "reference": "ba957cf4c69c55488d58229032bba7d71ad19e72" + "reference": "bfdd4dcddff043a016cf0cf937018c70618b8a01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/ba957cf4c69c55488d58229032bba7d71ad19e72", - "reference": "ba957cf4c69c55488d58229032bba7d71ad19e72", + "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/bfdd4dcddff043a016cf0cf937018c70618b8a01", + "reference": "bfdd4dcddff043a016cf0cf937018c70618b8a01", "shasum": "" }, "require": { - "php": "^7.4 || ~8.0 || ~8.1", + "php": "~8.0 || ~8.1 || ~8.2 || ~8.3", "psr/clock": "^1.0", "psr/container": "^2.0.2", "psr/event-dispatcher": "^1.0", @@ -876,7 +876,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-stable27": "27.0.0-dev" + "dev-stable28": "28.0.0-dev" } }, "notification-url": "https://packagist.org/downloads/", @@ -892,9 +892,9 @@ "description": "Composer package containing Nextcloud's public API (classes, interfaces)", "support": { "issues": "https://github.com/nextcloud-deps/ocp/issues", - "source": "https://github.com/nextcloud-deps/ocp/tree/stable27" + "source": "https://github.com/nextcloud-deps/ocp/tree/stable28" }, - "time": "2024-07-28T00:41:17+00:00" + "time": "2024-07-26T00:37:14+00:00" }, { "name": "nikic/php-parser", From 9e31379aea67e8cbe6304ef5600fd740074b7f2d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jul 2024 11:41:08 +0200 Subject: [PATCH 5/6] ci: Update workflows Signed-off-by: Joas Schilling --- .github/workflows/appstore-build-publish.yml | 44 ++++++++------- .github/workflows/cypress.yml | 24 ++++----- .../workflows/dependabot-approve-merge.yml | 8 ++- .github/workflows/lint-eslint.yml | 23 ++++---- .github/workflows/lint-info-xml.yml | 7 ++- .github/workflows/lint-php.yml | 24 +++++++-- .github/workflows/lint-stylelint.yml | 13 +++-- .github/workflows/node.yml | 22 +++++--- .github/workflows/phpunit-sqlite.yml | 54 ++++++++++++------- .github/workflows/pr-feedback.yml | 15 ++++-- .github/workflows/psalm.yml | 18 +++++-- .../update-nextcloud-ocp-approve-merge.yml | 13 ++++- .../workflows/update-nextcloud-ocp-matrix.yml | 17 +++--- 13 files changed, 184 insertions(+), 98 deletions(-) diff --git a/.github/workflows/appstore-build-publish.yml b/.github/workflows/appstore-build-publish.yml index 1ff8375d..aa8d7dc5 100644 --- a/.github/workflows/appstore-build-publish.yml +++ b/.github/workflows/appstore-build-publish.yml @@ -2,6 +2,9 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT name: Build and publish app release @@ -9,9 +12,6 @@ on: release: types: [published] -env: - PHP_VERSION: 8.2 - jobs: build_and_publish: runs-on: ubuntu-latest @@ -21,7 +21,7 @@ jobs: steps: - name: Check actor permission - uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2.1 + uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0 with: require: write @@ -32,7 +32,7 @@ jobs: echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: path: ${{ env.APP_NAME }} @@ -44,38 +44,44 @@ jobs: expression: "//info//dependencies//nextcloud/@min-version" - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 id: versions # Continue if no package.json continue-on-error: true with: path: ${{ env.APP_NAME }} fallbackNode: '^20' - fallbackNpm: '^9' + fallbackNpm: '^10' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} # Skip if no package.json if: ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} - name: Set up npm ${{ steps.versions.outputs.npmVersion }} # Skip if no package.json if: ${{ steps.versions.outputs.npmVersion }} - run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' + + - name: Get php version + id: php-versions + uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1 + with: + filename: ${{ env.APP_NAME }}/appinfo/info.xml - - name: Set up php ${{ env.PHP_VERSION }} - uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2 + - name: Set up php ${{ steps.php-versions.outputs.php-min }} + uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 with: - php-version: ${{ env.PHP_VERSION }} + php-version: ${{ steps.php-versions.outputs.php-min }} coverage: none env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check composer.json id: check_composer - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 with: files: "${{ env.APP_NAME }}/composer.json" @@ -93,11 +99,11 @@ jobs: run: | cd ${{ env.APP_NAME }} npm ci - npm run build + npm run build --if-present - name: Check Krankerl config id: krankerl - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 with: files: ${{ env.APP_NAME }}/krankerl.toml @@ -123,12 +129,12 @@ jobs: continue-on-error: true id: server-checkout run: | - NCVERSION=${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }} + NCVERSION='${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}' wget --quiet https://download.nextcloud.com/server/releases/latest-$NCVERSION.zip unzip latest-$NCVERSION.zip - name: Checkout server master fallback - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 if: ${{ steps.server-checkout.outcome != 'success' }} with: submodules: true @@ -142,7 +148,7 @@ jobs: tar -xvf ${{ env.APP_NAME }}.tar.gz cd ../../../ # Setting up keys - echo "${{ secrets.APP_PRIVATE_KEY }}" > ${{ env.APP_NAME }}.key + echo '${{ secrets.APP_PRIVATE_KEY }}' > ${{ env.APP_NAME }}.key wget --quiet "https://github.com/nextcloud/app-certificate-requests/raw/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt" # Signing php nextcloud/occ integrity:sign-app --privateKey=../${{ env.APP_NAME }}.key --certificate=../${{ env.APP_NAME }}.crt --path=../${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }} @@ -151,7 +157,7 @@ jobs: tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }} - name: Attach tarball to github release - uses: svenstaro/upload-release-action@1beeb572c19a9242f4361f4cee78f8e0d9aec5df # v2 + uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2 id: attach_to_release with: repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 1b68be92..66781154 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -15,13 +15,13 @@ env: jobs: changes: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low outputs: src: ${{ steps.changes.outputs.src}} steps: - - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 + - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 id: changes continue-on-error: true with: @@ -54,7 +54,7 @@ jobs: node-version: [20] php-versions: ['8.1'] databases: ['sqlite'] - server-versions: ['stable27', 'master'] + server-versions: ['stable28', 'master'] steps: - name: Set app env @@ -63,26 +63,26 @@ jobs: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Checkout server - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: path: apps/${{ env.APP_NAME }} - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2 + uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 with: php-version: ${{ matrix.php-versions }} extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, gd coverage: none - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 id: versions with: fallbackNode: '^20' @@ -90,12 +90,12 @@ jobs: path: apps/${{ env.APP_NAME }} - name: Set up node ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} - name: Set up npm ${{ steps.versions.outputs.npmVersion }} - run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' - name: Install dependencies & build working-directory: apps/${{ env.APP_NAME }} @@ -129,7 +129,7 @@ jobs: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - name: Upload test failure screenshots - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 if: failure() with: name: Upload screenshots @@ -137,7 +137,7 @@ jobs: retention-days: 5 - name: Upload nextcloud logs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 if: failure() with: name: Upload nextcloud log @@ -147,7 +147,7 @@ jobs: summary: permissions: contents: none - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low needs: [changes, cypress] if: always() diff --git a/.github/workflows/dependabot-approve-merge.yml b/.github/workflows/dependabot-approve-merge.yml index b5a8f0b8..efe8bfe3 100644 --- a/.github/workflows/dependabot-approve-merge.yml +++ b/.github/workflows/dependabot-approve-merge.yml @@ -31,7 +31,13 @@ jobs: pull-requests: write steps: - # Github actions bot approve + - name: Disabled on forks + if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} + run: | + echo 'Can not approve PRs from forks' + exit 1 + + # GitHub actions bot approve - uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint-eslint.yml b/.github/workflows/lint-eslint.yml index 99b624d1..74c5e9c8 100644 --- a/.github/workflows/lint-eslint.yml +++ b/.github/workflows/lint-eslint.yml @@ -3,8 +3,8 @@ # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization # -# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions -# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT name: Lint eslint @@ -19,13 +19,16 @@ concurrency: jobs: changes: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low + permissions: + contents: read + pull-requests: read outputs: src: ${{ steps.changes.outputs.src}} steps: - - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 + - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 id: changes continue-on-error: true with: @@ -53,22 +56,22 @@ jobs: steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 id: versions with: fallbackNode: '^20' - fallbackNpm: '^9' + fallbackNpm: '^10' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} - name: Set up npm ${{ steps.versions.outputs.npmVersion }} - run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' - name: Install dependencies env: @@ -82,7 +85,7 @@ jobs: summary: permissions: contents: none - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low needs: [changes, lint] if: always() diff --git a/.github/workflows/lint-info-xml.yml b/.github/workflows/lint-info-xml.yml index bf6f1787..736a8950 100644 --- a/.github/workflows/lint-info-xml.yml +++ b/.github/workflows/lint-info-xml.yml @@ -2,6 +2,9 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT name: Lint info.xml @@ -16,12 +19,12 @@ concurrency: jobs: xml-linters: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low name: info.xml lint steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Download schema run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml index 92769c49..104fed64 100644 --- a/.github/workflows/lint-php.yml +++ b/.github/workflows/lint-php.yml @@ -2,6 +2,9 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT name: Lint php @@ -15,22 +18,35 @@ concurrency: cancel-in-progress: true jobs: + matrix: + runs-on: ubuntu-latest-low + outputs: + php-versions: ${{ steps.versions.outputs.php-versions }} + steps: + - name: Checkout app + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Get version matrix + id: versions + uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.0.0 + php-lint: runs-on: ubuntu-latest + needs: matrix strategy: matrix: - php-versions: [ '8.0', '8.1', '8.2', '8.3' ] + php-versions: ${{fromJson(needs.matrix.outputs.php-versions)}} name: php-lint steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2 + uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 with: php-version: ${{ matrix.php-versions }} + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite coverage: none ini-file: development env: @@ -42,7 +58,7 @@ jobs: summary: permissions: contents: none - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low needs: php-lint if: always() diff --git a/.github/workflows/lint-stylelint.yml b/.github/workflows/lint-stylelint.yml index 684bb619..1e9db8f7 100644 --- a/.github/workflows/lint-stylelint.yml +++ b/.github/workflows/lint-stylelint.yml @@ -2,6 +2,9 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT name: Lint stylelint @@ -22,22 +25,22 @@ jobs: steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 id: versions with: fallbackNode: '^20' - fallbackNpm: '^9' + fallbackNpm: '^10' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} - name: Set up npm ${{ steps.versions.outputs.npmVersion }} - run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' - name: Install dependencies env: diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 75c32b44..3ca15c8b 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -2,6 +2,9 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT name: Node @@ -16,13 +19,16 @@ concurrency: jobs: changes: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low + permissions: + contents: read + pull-requests: read outputs: src: ${{ steps.changes.outputs.src}} steps: - - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 + - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 id: changes continue-on-error: true with: @@ -47,22 +53,22 @@ jobs: name: NPM build steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 id: versions with: fallbackNode: '^20' - fallbackNpm: '^9' + fallbackNpm: '^10' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} - name: Set up npm ${{ steps.versions.outputs.npmVersion }} - run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' - name: Install dependencies & build env: @@ -86,7 +92,7 @@ jobs: summary: permissions: contents: none - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low needs: [changes, build] if: always() diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml index e3838909..be9e3324 100644 --- a/.github/workflows/phpunit-sqlite.yml +++ b/.github/workflows/phpunit-sqlite.yml @@ -2,8 +2,11 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT -name: PHPUnit sqlite +name: PHPUnit SQLite on: pull_request @@ -15,14 +18,30 @@ concurrency: cancel-in-progress: true jobs: + matrix: + runs-on: ubuntu-latest-low + outputs: + php-version: ${{ steps.versions.outputs.php-available-list }} + server-max: ${{ steps.versions.outputs.branches-max-list }} + steps: + - name: Checkout app + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Get version matrix + id: versions + uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1 + changes: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low + permissions: + contents: read + pull-requests: read outputs: src: ${{ steps.changes.outputs.src}} steps: - - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 + - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 id: changes continue-on-error: true with: @@ -42,20 +61,15 @@ jobs: phpunit-sqlite: runs-on: ubuntu-latest - needs: changes + needs: [changes, matrix] if: needs.changes.outputs.src != 'false' strategy: matrix: - php-versions: ['8.1', '8.2', '8.3'] - server-versions: ['master'] - include: - - php-versions: '8.3' - server-versions: 'stable29' - - php-versions: '8.3' - server-versions: 'stable28' - - php-versions: '8.0' - server-versions: 'stable27' + php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }} + server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }} + + name: SQLite PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} steps: - name: Set app env @@ -64,19 +78,19 @@ jobs: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Checkout server - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: path: apps/${{ env.APP_NAME }} - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2 + uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 with: php-version: ${{ matrix.php-versions }} # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation @@ -88,7 +102,7 @@ jobs: - name: Check composer file existence id: check_composer - uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 with: files: apps/${{ env.APP_NAME }}/composer.json @@ -111,7 +125,7 @@ jobs: continue-on-error: true working-directory: apps/${{ env.APP_NAME }} run: | - composer run --list | grep "^ test:unit " | wc -l | grep 1 + composer run --list | grep '^ test:unit ' | wc -l | grep 1 - name: PHPUnit # Only run if phpunit config file exists @@ -124,7 +138,7 @@ jobs: continue-on-error: true working-directory: apps/${{ env.APP_NAME }} run: | - composer run --list | grep "^ test:integration " | wc -l | grep 1 + composer run --list | grep '^ test:integration ' | wc -l | grep 1 - name: Run Nextcloud # Only run if phpunit integration config file exists @@ -152,7 +166,7 @@ jobs: summary: permissions: contents: none - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low needs: [changes, phpunit-sqlite] if: always() diff --git a/.github/workflows/pr-feedback.yml b/.github/workflows/pr-feedback.yml index 940eda23..6a01fa09 100644 --- a/.github/workflows/pr-feedback.yml +++ b/.github/workflows/pr-feedback.yml @@ -24,18 +24,27 @@ jobs: id: scrape with: website: 'https://nextcloud.com/team/' + + - name: Get blocklist + id: blocklist + run: | + blocklist=$(curl https://raw.githubusercontent.com/nextcloud/.github/master/non-community-usernames.txt | paste -s -d, -) + echo "blocklist=$blocklist" >> "$GITHUB_OUTPUT" + - uses: marcelklehr/pr-feedback-action@1883b38a033fb16f576875e0cf45f98b857655c4 with: feedback-message: | Hello there, - Thank you so much for taking the time and effort to create a pull request to our Nextcloud project. + Thank you so much for taking the time and effort to create a pull request to our Nextcloud project. We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! + + (If you believe you should not receive this message, you can add yourself to the [blocklist](https://github.com/nextcloud/.github/blob/master/non-community-usernames.txt).) days-before-feedback: 14 - start-date: "2023-07-10" - exempt-authors: "${{ steps.scrape.outputs.users }},nextcloud-command,nextcloud-android-bot,skjnldsv,datenangebot" + start-date: '2024-04-30' + exempt-authors: '${{ steps.blocklist.outputs.blocklist }},${{ steps.scrape.outputs.users }}' exempt-bots: true diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 302873bc..e9258903 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -2,6 +2,9 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT name: Static analysis @@ -15,15 +18,20 @@ jobs: static-analysis: runs-on: ubuntu-latest - name: Nextcloud + name: static-psalm-analysis steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Get php version + id: versions + uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1 - - name: Set up php8.2 - uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2 + - name: Set up php${{ steps.versions.outputs.php-available }} + uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 with: - php-version: 8.2 + php-version: ${{ steps.versions.outputs.php-available }} + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite coverage: none ini-file: development env: diff --git a/.github/workflows/update-nextcloud-ocp-approve-merge.yml b/.github/workflows/update-nextcloud-ocp-approve-merge.yml index 58d5182a..5edf7ac1 100644 --- a/.github/workflows/update-nextcloud-ocp-approve-merge.yml +++ b/.github/workflows/update-nextcloud-ocp-approve-merge.yml @@ -2,6 +2,9 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT name: Auto approve nextcloud/ocp @@ -22,7 +25,7 @@ concurrency: jobs: auto-approve-merge: if: github.actor == 'nextcloud-command' - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low permissions: # for hmarr/auto-approve-action to approve PRs pull-requests: write @@ -30,6 +33,12 @@ jobs: contents: write steps: + - name: Disabled on forks + if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} + run: | + echo 'Can not approve PRs from forks' + exit 1 + - uses: mdecoleman/pr-branch-name@bab4c71506bcd299fb350af63bb8e53f2940a599 # v2.0.0 id: branchname with: @@ -43,7 +52,7 @@ jobs: # Enable GitHub auto merge - name: Auto merge - uses: alexwilson/enable-github-automerge-action@f3e77fa17ba5a11771671361c01f382322c6db03 # main + uses: alexwilson/enable-github-automerge-action@56e3117d1ae1540309dc8f7a9f2825bc3c5f06ff # main if: startsWith(steps.branchname.outputs.branch, 'automated/noid/') && endsWith(steps.branchname.outputs.branch, 'update-nextcloud-ocp') with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-nextcloud-ocp-matrix.yml b/.github/workflows/update-nextcloud-ocp-matrix.yml index 61c7d8b1..8fdd3d51 100644 --- a/.github/workflows/update-nextcloud-ocp-matrix.yml +++ b/.github/workflows/update-nextcloud-ocp-matrix.yml @@ -2,6 +2,9 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT name: Update nextcloud/ocp @@ -23,13 +26,13 @@ jobs: name: update-nextcloud-ocp-${{ matrix.branches }} steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: ref: ${{ matrix.branches }} submodules: true - name: Set up php8.2 - uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2 + uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 with: php-version: 8.2 # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation @@ -52,7 +55,7 @@ jobs: run: composer require --dev nextcloud/ocp:dev-${{ matrix.target }} - name: Raise on issue on failure - uses: dacbd/create-issue-action@ba4d1c45cccf9c483f2720cefb40e437f0ee6f7d # v1.2.1 + uses: dacbd/create-issue-action@cdb57ab6ff8862aa09fee2be6ba77a59581921c2 # v2.0.0 if: ${{ failure() && steps.update_branch.conclusion == 'failure' }} with: token: ${{ secrets.GITHUB_TOKEN }} @@ -78,15 +81,15 @@ jobs: continue-on-error: true - name: Create Pull Request - uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v3 + uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 with: token: ${{ secrets.COMMAND_BOT_PAT }} - commit-message: "chore(dev-deps): Bump nextcloud/ocp package" + commit-message: 'chore(dev-deps): Bump nextcloud/ocp package' committer: GitHub author: nextcloud-command signoff: true - branch: automated/noid/${{ matrix.branches }}-update-nextcloud-ocp - title: "[${{ matrix.branches }}] Update nextcloud/ocp dependency" + branch: 'automated/noid/${{ matrix.branches }}-update-nextcloud-ocp' + title: '[${{ matrix.branches }}] Update nextcloud/ocp dependency' body: | Auto-generated update of [nextcloud/ocp](https://github.com/nextcloud-deps/ocp/) dependency labels: | From 7071fe64026dcaecb9d0a9fd0d06ec568f070e77 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jul 2024 11:56:57 +0200 Subject: [PATCH 6/6] ci: Add phpunit-mysql to test the full range matrix Signed-off-by: Joas Schilling --- .github/workflows/phpunit-mysql.yml | 191 ++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 .github/workflows/phpunit-mysql.yml diff --git a/.github/workflows/phpunit-mysql.yml b/.github/workflows/phpunit-mysql.yml new file mode 100644 index 00000000..c0f4c69b --- /dev/null +++ b/.github/workflows/phpunit-mysql.yml @@ -0,0 +1,191 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT + +name: PHPUnit MySQL + +on: pull_request + +permissions: + contents: read + +concurrency: + group: phpunit-mysql-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + matrix: + runs-on: ubuntu-latest-low + outputs: + matrix: ${{ steps.versions.outputs.sparse-matrix }} + steps: + - name: Checkout app + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Get version matrix + id: versions + uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1 + with: + matrix: '{"mysql-versions": ["8.4"]}' + + changes: + runs-on: ubuntu-latest-low + permissions: + contents: read + pull-requests: read + + outputs: + src: ${{ steps.changes.outputs.src}} + + steps: + - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 + id: changes + continue-on-error: true + with: + filters: | + src: + - '.github/workflows/**' + - 'appinfo/**' + - 'lib/**' + - 'templates/**' + - 'tests/**' + - 'vendor/**' + - 'vendor-bin/**' + - '.php-cs-fixer.dist.php' + - 'composer.json' + - 'composer.lock' + + phpunit-mysql: + runs-on: ubuntu-latest + + needs: [changes, matrix] + if: needs.changes.outputs.src != 'false' + + strategy: + matrix: ${{ fromJson(needs.matrix.outputs.matrix) }} + + name: MySQL ${{ matrix.mysql-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} + + services: + mysql: + image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest + ports: + - 4444:3306/tcp + env: + MYSQL_ROOT_PASSWORD: rootpassword + options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10 + + steps: + - name: Set app env + run: | + # Split and keep last + echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV + + - name: Checkout server + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + submodules: true + repository: nextcloud/server + ref: ${{ matrix.server-versions }} + + - name: Checkout app + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + path: apps/${{ env.APP_NAME }} + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 + with: + php-version: ${{ matrix.php-versions }} + # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, mysql, pdo_mysql + coverage: none + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Enable ONLY_FULL_GROUP_BY MySQL option + run: | + echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword + echo 'SELECT @@sql_mode;' | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword + + - name: Check composer file existence + id: check_composer + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 + with: + files: apps/${{ env.APP_NAME }}/composer.json + + - name: Set up dependencies + # Only run if phpunit config file exists + if: steps.check_composer.outputs.files_exists == 'true' + working-directory: apps/${{ env.APP_NAME }} + run: composer i + + - name: Set up Nextcloud + env: + DB_PORT: 4444 + run: | + mkdir data + ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + ./occ app:enable --force ${{ env.APP_NAME }} + + - name: Check PHPUnit script is defined + id: check_phpunit + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep '^ test:unit ' | wc -l | grep 1 + + - name: PHPUnit + # Only run if phpunit config file exists + if: steps.check_phpunit.outcome == 'success' + working-directory: apps/${{ env.APP_NAME }} + run: composer run test:unit + + - name: Check PHPUnit integration script is defined + id: check_integration + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep '^ test:integration ' | wc -l | grep 1 + + - name: Run Nextcloud + # Only run if phpunit integration config file exists + if: steps.check_integration.outcome == 'success' + run: php -S localhost:8080 & + + - name: PHPUnit integration + # Only run if phpunit integration config file exists + if: steps.check_integration.outcome == 'success' + working-directory: apps/${{ env.APP_NAME }} + run: composer run test:integration + + - name: Print logs + if: always() + run: | + cat data/nextcloud.log + + - name: Skipped + # Fail the action when neither unit nor integration tests ran + if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure' + run: | + echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts' + exit 1 + + summary: + permissions: + contents: none + runs-on: ubuntu-latest-low + needs: [changes, phpunit-mysql] + + if: always() + + name: phpunit-mysql-summary + + steps: + - name: Summary status + run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-mysql.result != 'success' }}; then exit 1; fi