Skip to content
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
16 changes: 0 additions & 16 deletions .github/workflows/bench.yml

This file was deleted.

155 changes: 155 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: CI

on:
pull_request:
push:
branches: [master, "*.x"]
Comment on lines +1 to +6
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 security CodeQL security scanning silently removed

codeql-analysis.yml was deleted as part of this PR but is not mentioned in the description. The repository no longer has any automated security scanning for PHP source code. If this is intentional, the PR description should document the decision; if not, the file should be restored or replaced with an equivalent scanning step in ci.yml.


jobs:
format:
name: Checks / Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 actions/checkout version mismatch with PR description

The PR description says "Bump actions/checkout@v3@v4", but every uses: actions/checkout step in this file is pinned to @v6. If @v6 does not resolve in the GitHub Actions runner (e.g., it's ahead of what's been released), all five jobs will fail immediately on the checkout step. Verify the intended tag and update consistently.


- name: Run Pint
run: |
docker run --rm -v "$PWD":/app -w /app composer:2.7 sh -c \
"composer install --profile --ignore-platform-reqs --no-interaction && composer format:check"

analyze:
name: Checks / Analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: swoole
coverage: none
Comment thread
greptile-apps[bot] marked this conversation as resolved.

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ hashFiles('composer.lock') }}
restore-keys: composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction --ignore-platform-req=ext-opentelemetry

- name: PHPStan
run: composer analyze

unit:
name: Tests / Unit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: swoole
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ hashFiles('composer.lock') }}
restore-keys: composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction --ignore-platform-req=ext-opentelemetry

- name: Run unit tests
run: vendor/bin/phpunit --configuration phpunit.xml --testsuite unit

e2e:
name: Tests / E2E / ${{ matrix.adapter.display }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
adapter:
- { id: fpm, display: FPM }
- { id: swoole, display: Swoole }
steps:
- uses: actions/checkout@v6

- name: Build and wait for ${{ matrix.adapter.id }} to be healthy
run: docker compose up -d --build --wait ${{ matrix.adapter.id }}

- name: Run E2E tests
run: docker compose exec -T ${{ matrix.adapter.id }} vendor/bin/phpunit --configuration phpunit.xml --testsuite e2e-${{ matrix.adapter.id }}

- name: Dump container logs on failure
if: failure()
run: docker compose logs ${{ matrix.adapter.id }}

benchmark:
name: Benchmark
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6

- name: Build and wait for swoole to be healthy
run: docker compose up -d --build --wait swoole

- name: Setup k6
uses: grafana/setup-k6-action@v1

- name: Run k6 benchmark
uses: grafana/run-k6-action@v1
with:
path: tests/bench/benchmark.js
flags: --summary-export=summary.json
env:
BASE_URL: http://localhost:9501

- name: Render PR comment body
if: always() && hashFiles('summary.json') != ''
run: |
jq -r '
.metrics as $m |
[
"### k6 benchmark",
"",
"| Throughput | Requests | Fail rate | p50 | p95 |",
"| --- | --- | --- | --- | --- |",
"| \(($m.http_reqs.rate // 0) | floor) req/s | \($m.http_reqs.count // 0) | \((($m.http_req_failed.value // 0) * 100) * 1000 | floor / 1000)% | \(($m.http_req_duration.med // 0) * 100 | floor / 100) ms | \(($m.http_req_duration["p(95)"] // 0) * 100 | floor / 100) ms |"
] | .[]
' summary.json > summary.md

- name: Upload raw k6 summary
if: always()
uses: actions/upload-artifact@v7
with:
name: k6-summary
path: summary.json
if-no-files-found: ignore

- name: Comment benchmark summary on PR
if: github.event_name == 'pull_request' && always() && hashFiles('summary.md') != ''
uses: marocchino/sticky-pull-request-comment@v3
with:
header: k6-benchmark
path: summary.md

- name: Dump swoole logs on failure
if: failure()
run: docker compose logs swoole
17 changes: 0 additions & 17 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/lint.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/test.yml

This file was deleted.

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/vendor/
/.idea/
*.cache
/.vscode/
/composer.phar
.phpunit.result.cache
/.phpunit.cache/
*.cache
3 changes: 1 addition & 2 deletions Dockerfile.fpm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM composer:2.0 AS step0
FROM composer:2.7 AS step0


ARG TESTING=true
Expand Down Expand Up @@ -38,7 +38,6 @@ COPY ./tests/docker/start /usr/local/bin/start
COPY ./src /usr/share/nginx/html/src
COPY ./tests /usr/share/nginx/html/tests
COPY ./phpunit.xml /usr/share/nginx/html/phpunit.xml
COPY ./phpbench.json /usr/share/nginx/html/phpbench.json
COPY --from=step0 /usr/local/src/vendor /usr/share/nginx/html/vendor

# Supervisord Conf
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile.swoole
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM composer:2.0 AS step0
FROM composer:2.7 AS step0


ARG TESTING=true
Expand All @@ -21,7 +21,6 @@ WORKDIR /usr/src/code
COPY ./src /usr/src/code/src
COPY ./tests /usr/src/code/tests
COPY ./phpunit.xml /usr/src/code/phpunit.xml
COPY ./phpbench.json /usr/src/code/phpbench.json
COPY --from=step0 /usr/local/src/vendor /usr/src/code/vendor

EXPOSE 80
Expand Down
25 changes: 15 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,35 @@
"Utopia\\": "src/"
}
},
"autoload-dev": {
"autoload-dev": {
"psr-4": {
"Utopia\\Http\\Tests\\": "tests/",
"Tests\\E2E\\": "tests/e2e"
}
"Utopia\\Http\\Tests\\": "tests/",
"Tests\\E2E\\": "tests/e2e"
}
},
"scripts": {
"lint": "vendor/bin/pint --test",
"format": "vendor/bin/pint",
"check": "vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 512M",
"test": "vendor/bin/phpunit --configuration phpunit.xml",
"bench": "vendor/bin/phpbench run --report=benchmark"
"format:check": "vendor/bin/pint --test",
"analyze": "vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 512M",
"test": "vendor/bin/phpunit --configuration phpunit.xml"
},
"require": {
"php": ">=8.2",
"ext-swoole": "*",
"utopia-php/di": "0.3.*",
"utopia-php/servers": "0.3.*",
"utopia-php/compression": "0.1.*",
"utopia-php/telemetry": "0.2.*",
"utopia-php/validators": "0.2.*"
},
"suggest": {
"ext-swoole": "Required to use the Swoole server adapter (\\Utopia\\Http\\Adapter\\Swoole\\Server)."
},
"config": {
"platform": {
"php": "8.2",
"ext-opentelemetry": "1.0.0",
"ext-protobuf": "4.26.1"
},
"allow-plugins": {
"php-http/discovery": true,
"tbachert/spi": true
Expand All @@ -46,7 +52,6 @@
"require-dev": {
"doctrine/instantiator": "^1.5",
"laravel/pint": "1.*",
"phpbench/phpbench": "^1.2",
"phpstan/phpstan": "1.*",
"phpunit/phpunit": "^9.5.25",
"swoole/ide-helper": "4.8.3"
Expand Down
Loading
Loading