Skip to content
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

[ci] Add PHP support #1174 #1175

Merged
merged 8 commits into from
Aug 1, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add php setup
michaelvlach committed Aug 1, 2024
commit c77274f4370d0d9a78da12044dae56cd914c0a36
3 changes: 3 additions & 0 deletions agdb_api/php/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor/
coverage/
node_modules/
44 changes: 44 additions & 0 deletions agdb_api/php/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function coverage() {
local output=$(XDEBUG_MODE=coverage ./vendor/bin/phpunit tests --coverage-filter src/ --coverage-text)
echo "$output"
echo ""

if echo "$output" | grep "Lines:" | head -1 | grep -q "100.00%"; then
echo "Line coverage OK";
else
echo "Insufficient line coverage";
exit 1;
fi

if echo "$output" | grep "Methods:" | head -1 | grep -q "100.00%"; then
echo "Methods coverage OK";
else
echo "Insufficient methods coverage";
exit 1;
fi

if echo "$output" | grep "Classes:" | head -1 | grep -q "100.00%"; then
echo "Classes coverage OK";
else
echo "Insufficient classes coverage";
exit 1;
fi
}

function analysis() {
./vendor/bin/phpstan analyse --level=9 src tests
}

function format() {
npx prettier --plugin '@prettier/plugin-php' --write src tests
}

if [[ "$1" == "coverage" ]]; then
coverage
elif [[ "$1" == "analysis" ]]; then
analysis
elif [[ "$1" == "format" ]]; then
format
elif [[ "$1" == "format:check" ]]; then
npx prettier --plugin '@prettier/plugin-php' --check src tests
fi
11 changes: 11 additions & 0 deletions agdb_api/php/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"autoload": {
"classmap": [
"src"
]
},
"require-dev": {
"phpunit/phpunit": "^11",
"phpstan/phpstan": "^1.11"
}
}
1,709 changes: 1,709 additions & 0 deletions agdb_api/php/composer.lock

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions agdb_api/php/package-lock.json
6 changes: 6 additions & 0 deletions agdb_api/php/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"devDependencies": {
"@prettier/plugin-php": "^0.22.2",
"prettier": "^3.3.3"
}
}
12 changes: 12 additions & 0 deletions agdb_api/php/src/Agdb.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
namespace agdb;

class QueryBuilder
{
public string $query;

function __construct()
{
$this->query = "";
}
}
12 changes: 12 additions & 0 deletions agdb_api/php/tests/AgdbTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use agdb\QueryBuilder;

final class AgdbTest extends TestCase
{
public function testAgdb(): void
{
$qb = new QueryBuilder();
$this->assertSame($qb->query, "");
}
}