Skip to content

Commit aaa8df0

Browse files
committed
Add CI workflows and update config
1 parent 722c4c7 commit aaa8df0

8 files changed

Lines changed: 174 additions & 0 deletions

File tree

.github/workflows/integration.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Integration Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
integration:
11+
name: Integration Tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '8.4'
22+
extensions: swoole, redis, sockets
23+
tools: composer:v2
24+
25+
- name: Install dependencies
26+
run: composer install --prefer-dist --no-progress
27+
28+
- name: Run integration tests
29+
run: composer test:integration

.github/workflows/lint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
pint:
11+
name: Laravel Pint
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '8.4'
22+
tools: composer:v2
23+
24+
- name: Install dependencies
25+
run: composer install --no-interaction --prefer-dist
26+
27+
- name: Run Pint
28+
run: composer lint -- --test
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Static Analysis
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
phpstan:
11+
name: PHPStan
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '8.4'
22+
extensions: swoole, redis
23+
tools: composer:v2
24+
25+
- name: Install dependencies
26+
run: composer install --no-interaction --prefer-dist
27+
28+
- name: Run PHPStan
29+
run: composer check

.github/workflows/tests.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
unit:
11+
name: Unit Tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Build test image
19+
run: |
20+
docker build -t protocol-proxy-test --target test -f Dockerfile.test .
21+
22+
- name: Run tests
23+
run: |
24+
docker run --rm protocol-proxy-test composer test

Dockerfile.test

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM php:8.4-cli-alpine AS test
2+
3+
RUN apk add --no-cache \
4+
autoconf \
5+
g++ \
6+
make \
7+
linux-headers \
8+
libstdc++ \
9+
brotli-dev \
10+
libzip-dev \
11+
openssl-dev
12+
13+
RUN docker-php-ext-install \
14+
pcntl \
15+
sockets \
16+
zip
17+
18+
RUN pecl channel-update pecl.php.net && \
19+
pecl install swoole-6.0.1 && \
20+
docker-php-ext-enable swoole
21+
22+
RUN pecl channel-update pecl.php.net && \
23+
pecl install redis && \
24+
docker-php-ext-enable redis
25+
26+
WORKDIR /app
27+
28+
COPY composer.json composer.lock ./
29+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
30+
RUN composer install --optimize-autoloader \
31+
--ignore-platform-req=ext-mongodb \
32+
--ignore-platform-req=ext-memcached \
33+
--ignore-platform-req=ext-opentelemetry \
34+
--ignore-platform-req=ext-protobuf
35+
36+
COPY . .

docker-compose.integration.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ services:
2323
http-proxy:
2424
environment:
2525
HTTP_BACKEND_ENDPOINT: http-backend:5678
26+
HTTP_SKIP_VALIDATION: "true"
2627
depends_on:
2728
- http-backend
2829

2930
tcp-proxy:
3031
environment:
3132
TCP_BACKEND_ENDPOINT: tcp-backend:15432
33+
TCP_SKIP_VALIDATION: "true"
3234
depends_on:
3335
- tcp-backend
3436

3537
smtp-proxy:
3638
environment:
3739
SMTP_BACKEND_ENDPOINT: smtp-backend:1025
40+
SMTP_SKIP_VALIDATION: "true"
3841
depends_on:
3942
- smtp-backend

phpunit.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
<testsuites>
44
<testsuite name="Unit">
55
<directory>tests</directory>
6+
<exclude>tests/Integration</exclude>
7+
</testsuite>
8+
<testsuite name="Integration">
9+
<directory>tests/Integration</directory>
610
</testsuite>
711
</testsuites>
812
</phpunit>

pint.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"preset": "psr12",
3+
"exclude": [
4+
"./app/sdks",
5+
"./tests/resources/functions",
6+
"./app/console"
7+
],
8+
"rules": {
9+
"array_indentation": true,
10+
"single_import_per_statement": true,
11+
"simplified_null_return": true,
12+
"ordered_imports": {
13+
"sort_algorithm": "alpha",
14+
"imports_order": [
15+
"const",
16+
"class",
17+
"function"
18+
]
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)