diff --git a/composer.json b/composer.json index 777198d8..f88494d5 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ "require": { "php": ">=8.2", "adhocore/jwt": "^1.1", + "utopia-php/validators": "^0.2", "utopia-php/cache": "^2.0", "utopia-php/fetch": "^1.1" }, diff --git a/composer.lock b/composer.lock index bc842a5c..27313abd 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": "21b37b7bff901c1c81b99777291b45b7", + "content-hash": "b8dafeca0eca87cf77089116e16b118d", "packages": [ { "name": "adhocore/jwt", @@ -2198,6 +2198,51 @@ "source": "https://github.com/utopia-php/telemetry/tree/0.3.0" }, "time": "2026-04-01T13:52:56+00:00" + }, + { + "name": "utopia-php/validators", + "version": "0.2.2", + "source": { + "type": "git", + "url": "https://github.com/utopia-php/validators.git", + "reference": "5d7d494e64457cd4eb67fdcfd9481f2c89796aa6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/validators/zipball/5d7d494e64457cd4eb67fdcfd9481f2c89796aa6", + "reference": "5d7d494e64457cd4eb67fdcfd9481f2c89796aa6", + "shasum": "" + }, + "require": { + "php": ">=8.0" + }, + "require-dev": { + "laravel/pint": "1.*", + "phpstan/phpstan": "2.*", + "phpunit/phpunit": "11.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A lightweight collection of reusable validators for Utopia projects", + "keywords": [ + "php", + "utopia", + "validation", + "validator" + ], + "support": { + "issues": "https://github.com/utopia-php/validators/issues", + "source": "https://github.com/utopia-php/validators/tree/0.2.2" + }, + "time": "2026-04-27T16:30:24+00:00" } ], "packages-dev": [ diff --git a/src/VCS/Validator/DeploymentSkippable.php b/src/VCS/Validator/DeploymentSkippable.php new file mode 100644 index 00000000..bd387a04 --- /dev/null +++ b/src/VCS/Validator/DeploymentSkippable.php @@ -0,0 +1,58 @@ +validator = new DeploymentSkippable(); + } + + public function testKnownSkipDirectivesSkip(): void + { + $this->assertTrue($this->validator->isValid('[skip ci] update changelog')); + } + + public function testKnownSkipDirectivesAreCaseInsensitive(): void + { + $this->assertTrue($this->validator->isValid('[SKIP CI] update changelog')); + } + + public function testMessageWithoutKnownDirectiveProceeds(): void + { + $this->assertFalse($this->validator->isValid('fix: real bug fix')); + $this->assertFalse($this->validator->isValid('feat: add new feature')); + $this->assertFalse($this->validator->isValid('skip deploy without brackets')); + $this->assertFalse($this->validator->isValid('deploy this please')); + $this->assertFalse($this->validator->isValid('skip-checks:true')); + } + + public function testDirectiveCanAppearAnywhere(): void + { + $this->assertTrue($this->validator->isValid('docs: update readme [skip ci]')); + $this->assertTrue($this->validator->isValid('docs: update readme[skip ci]')); + $this->assertTrue($this->validator->isValid('prefix[skip ci]suffix')); + $this->assertFalse($this->validator->isValid('refactor: skip ci cache seeding')); + } + + public function testMultilineCommitMessageSkips(): void + { + $message = "feat: add new stuff\n\nMore detail here.\n\n[skip ci]"; + + $this->assertTrue($this->validator->isValid($message)); + } + + public function testNonStringCommitMessageProceeds(): void + { + $this->assertFalse($this->validator->isValid(null)); + $this->assertFalse($this->validator->isValid([])); + } +}