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
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
61 changes: 61 additions & 0 deletions .github/workflows/agdb_api_php.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: agdb_api_php

on:
pull_request:
branches: ["main"]

jobs:
diff:
runs-on: ubuntu-24.04
outputs:
diff: ${{ steps.diff.outputs.diff }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: diff
shell: bash
run: |
if [[ "$(git diff origin/main --name-only -- agdb_api/php/ agdb_server/openapi/schema.json .github/workflows/agdb_api_php.yaml)" != "" ]]; then (echo "diff=true" >> $GITHUB_OUTPUT); fi

agdb_api_php_analyse:
runs-on: ubuntu-24.04
needs: diff
if: needs.diff.outputs.diff == 'true'
defaults:
run:
working-directory: agdb_api/php
steps:
- uses: actions/checkout@v4
- run: composer install
- run: ./ci.sh analyse

agdb_api_php_coverage:
runs-on: ubuntu-24.04
needs: diff
if: needs.diff.outputs.diff == 'true'
defaults:
run:
working-directory: agdb_api/php
steps:
- uses: actions/checkout@v4
- run: composer install
- run: ./ci.sh coverage
- uses: actions/upload-artifact@v3
if: always()
with:
name: coverage
path: agdb_api/php/coverage/
retention-days: 30

agdb_api_php_format:
runs-on: ubuntu-latest
needs: diff
if: needs.diff.outputs.diff == 'true'
defaults:
run:
working-directory: agdb_api/php
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: ./ci.sh format:check
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"
}
}
Loading
Loading