Skip to content

Commit b053b25

Browse files
Merge pull request #2 from appwrite/feat/improvements-and-healthcheck
Add healthcheck endpoint and harden geo service
2 parents 5c4db3d + 432e831 commit b053b25

16 files changed

Lines changed: 3416 additions & 538 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
name: "CodeQL"
1+
name: "PHP Quality"
22

33
on: [pull_request]
44
jobs:
55
lint:
6-
name: CodeQL
6+
name: Lint & Static Analysis
77
runs-on: ubuntu-latest
88

99
steps:
1010
- name: Checkout repository
11-
uses: actions/checkout@v3
11+
uses: actions/checkout@v4
1212

13-
- name: Run CodeQL
13+
- name: Run lint and static analysis
1414
run: |
15-
docker run --rm -v $PWD:/app composer sh -c \
16-
"composer install --profile --ignore-platform-reqs && composer check"
17-
15+
docker run --rm -v $PWD:/app composer:2 sh -c \
16+
"composer install --profile --ignore-platform-reqs && composer lint && composer check"

.github/workflows/tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: E2E Tests
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
env:
10+
GEO_SECRET: test-secret
11+
GEO_ENV: development
12+
13+
jobs:
14+
e2e:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Build and start services
21+
run: docker compose up -d --build geo
22+
23+
- name: Wait for server to be ready
24+
run: |
25+
for i in $(seq 1 30); do
26+
if curl -sf http://localhost:8080/v1/health; then
27+
echo "Server is ready"
28+
exit 0
29+
fi
30+
sleep 1
31+
done
32+
echo "Server failed to start"
33+
docker compose logs geo
34+
exit 1
35+
36+
- name: Run E2E tests
37+
run: docker compose run --rm tests
38+
39+
- name: Show logs on failure
40+
if: failure()
41+
run: docker compose logs geo

Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM composer:2.0 AS composer
1+
FROM composer:2 AS composer
22

33
ARG TESTING=false
44
ENV TESTING=$TESTING
@@ -12,8 +12,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \
1212
--no-plugins --no-scripts --prefer-dist \
1313
`if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi`
1414

15-
# TODO fix utopia-php/docker-base and use appwrite/utopia-base
16-
FROM appwrite/base:0.9.3 as final
15+
FROM appwrite/base:1.1.1 as final
1716

1817
LABEL maintainer="team@appwrite.io"
1918

@@ -27,4 +26,7 @@ COPY ./src /usr/src/code/src
2726

2827
EXPOSE 80
2928

30-
CMD ["php", "app/http.php"]
29+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
30+
CMD php -r "exit(str_contains(file_get_contents('http://localhost:80/v1/health'), 'ok') ? 0 : 1);"
31+
32+
CMD ["php", "app/http.php"]

composer.json

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,47 @@
33
"type": "project",
44
"require": {
55
"php": ">=8.3.0",
6-
"utopia-php/fetch": "^0.2.1",
7-
"utopia-php/http": "1.0.*",
8-
"utopia-php/platform": "feat-upgrade-http-dev",
9-
"utopia-php/di": "^0.1.0",
10-
"utopia-php/system": "^0.8.0",
11-
"utopia-php/logger": "^0.6.1",
6+
"utopia-php/fetch": "0.5.*",
7+
"utopia-php/http": "0.34.*",
8+
"utopia-php/platform": "0.10.*",
9+
"utopia-php/di": "0.3.*",
10+
"utopia-php/system": "^0.10.1",
11+
"utopia-php/logger": "^0.7.1",
1212
"utopia-php/dsn": "^0.2.1",
13-
"utopia-php/cli": "dev-feat-upgrade-http as 0.19.0"
13+
"utopia-php/cli": "0.23.*",
14+
"utopia-php/console": "^0.1.1"
1415
},
1516
"autoload": {
1617
"psr-4": {
1718
"Appwrite\\Geo\\": "src/Geo"
1819
}
1920
},
21+
"autoload-dev": {
22+
"psr-4": {
23+
"Tests\\": "tests"
24+
}
25+
},
2026
"authors": [
2127
{
2228
"name": "Appwrite",
2329
"email": "team@appwrite.io"
2430
}
2531
],
2632
"require-dev": {
27-
"phpunit/phpunit": "^11.3",
28-
"laravel/pint": "^1.18",
29-
"phpstan/phpstan": "^1.12"
33+
"phpunit/phpunit": "^13.0",
34+
"laravel/pint": "^1.29",
35+
"phpstan/phpstan": "^2.1"
3036
},
3137
"scripts": {
3238
"lint": "./vendor/bin/pint --test --config pint.json",
3339
"format": "./vendor/bin/pint --config pint.json",
34-
"check": "./vendor/bin/phpstan analyse -c phpstan.neon"
40+
"check": "./vendor/bin/phpstan analyse -c phpstan.neon",
41+
"test:e2e": "./vendor/bin/phpunit --testsuite e2e"
42+
},
43+
"config": {
44+
"allow-plugins": {
45+
"php-http/discovery": false,
46+
"tbachert/spi": false
47+
}
3548
}
3649
}

0 commit comments

Comments
 (0)