Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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.

153 changes: 153 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
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@v4

- 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@v4

- 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@v4
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@v4

- 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@v4
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@v4

- 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@v4

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

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

- name: Run k6 benchmark
run: |
set -o pipefail
k6 run --summary-export=summary.json tests/bench/benchmark.js 2>&1 | tee summary.txt
env:
BASE_URL: http://localhost:9501

- name: Render PR comment body
if: always()
run: |
{
echo '### k6 benchmark'
echo
echo '```'
cat summary.txt
echo '```'
} > summary.md

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

- name: Comment benchmark summary on PR
if: github.event_name == 'pull_request' && always()
uses: marocchino/sticky-pull-request-comment@v2
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