Skip to content
Closed
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
47 changes: 46 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions src/VCS/Validator/DeploymentSkippable.php
Copy link
Copy Markdown
Contributor

@Meldiron Meldiron May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In validator folder,

should extend validator

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Utopia\VCS\Validator;

use Utopia\Validator;

class DeploymentSkippable extends Validator
{
private const PATTERNS = [
'[skip ci]',
// '[ci skip]',
// '[no ci]',
// '[skip action]',
// '[action skip]',
// '[no action]',
// '[skip actions]',
// '[actions skip]',
// '[no actions]',
// '[skip deploy]',
// '[deploy skip]',
// '[no deploy]',
// '[skip appwrite]',
// '[appwrite skip]',
// '[no appwrite]',
];
Comment thread
Meldiron marked this conversation as resolved.

public function getDescription(): string
{
return 'Value must be a commit message containing a skip directive such as [skip ci] or [no deploy].';
}

public function isValid($value): bool
{
if (!is_string($value)) {
return false;
}

$value = strtolower($value);

foreach (self::PATTERNS as $pattern) {
if (str_contains($value, $pattern)) {
return true;
}
}

return false;
}

public function isArray(): bool
{
return false;
}

public function getType(): string
{
return self::TYPE_STRING;
}
}
56 changes: 56 additions & 0 deletions tests/VCS/Unit/Validator/DeploymentSkippableTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace Utopia\Tests;

use PHPUnit\Framework\TestCase;
use Utopia\VCS\Validator\DeploymentSkippable;

class DeploymentSkippableTest extends TestCase
{
private DeploymentSkippable $validator;

protected function setUp(): void
{
$this->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([]));
}
}