-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PHP testing app * script to build and launch using a ref of the SDK * Dockeration * release script * healthcheck * readme
- Loading branch information
Showing
15 changed files
with
3,264 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Set your appropriate values and save as `.env` | ||
EPPO_API_HOST=localhost | ||
EPPO_API_PORT=5000 | ||
EPPO_API_KEY=A123456780 | ||
|
||
SDK_RELAY_HOST=localhost | ||
SDK_RELAY_PORT=4000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM php:8.1 | ||
|
||
# dependencies needed for composer (and for build-and-run.sh). | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
curl \ | ||
libpng-dev \ | ||
libonig-dev \ | ||
libxml2-dev \ | ||
zip \ | ||
unzip | ||
|
||
|
||
COPY --from=composer /usr/bin/composer /usr/bin/composer | ||
|
||
WORKDIR /relayapp | ||
|
||
COPY . . | ||
|
||
COPY --chmod=755 build-and-run.sh / | ||
|
||
RUN composer install | ||
|
||
ENV SDK_RELAY_HOST=0.0.0.0 | ||
ENV EPPO_API_HOST=host.docker.internal | ||
|
||
EXPOSE $SDK_RELAY_PORT | ||
|
||
HEALTHCHECK CMD curl --fail http://localhost:${SDK_RELAY_PORT} || exit 1 | ||
|
||
|
||
CMD ["/build-and-run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# PHP Testing Server | ||
|
||
Post test case files to this server and check the results against what's expected. | ||
|
||
## Setup | ||
Open `.env.EXAMPLE`, set appropriate config values and then save it as `.env` | ||
|
||
## Running | ||
|
||
### Locally | ||
|
||
```shell | ||
BASH_ENV=.env SDK_REF=<your branch/tag/SHA> ./build-and-run.sh | ||
``` | ||
|
||
### With Docker | ||
#### Build Docker Image | ||
```shell | ||
docker build -t Eppo-exp/php-sdk-relay . | ||
``` | ||
|
||
#### Run the docker container | ||
```shell | ||
./docker-run.sh | ||
``` | ||
|
||
## Development | ||
|
||
### Running locally | ||
|
||
```shell | ||
php -S localhost:4000 src/index.php | ||
``` | ||
|
||
### Testing the relay server | ||
|
||
Use this [Postman collection](https://www.postman.com/material-meteorologist-42730907/typotter-eppo/collection/5bjhdzy/relay-server-testing) | ||
|
||
### Build and Tag a new Docker image | ||
_nb: not really needed as this target will need to be built on every run of the test cluster against this SDK, but | ||
useful for development along the way nonetheless_ | ||
|
||
```shell | ||
./release.sh <version> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
composer install | ||
|
||
# Set default values for vars | ||
|
||
: "${SDK_REF:=main}" | ||
: "${SDK_RELAY_HOST:=localhost}" | ||
: "${SDK_RELAY_PORT:=4000}" | ||
SDK="https://github.com/Eppo-exp/php-sdk.git" | ||
|
||
|
||
# checkout the specified ref of the SDK repo, build it, and then insert it into vendors here. | ||
mkdir -p tmp | ||
|
||
echo "Cloning ${SDK}@${SDK_REF}" | ||
git clone -b ${SDK_REF} --depth 1 --single-branch ${SDK} tmp || ( echo "Cloning repo failed"; exit 1 ) | ||
|
||
# overwrite vendor files | ||
cp -Rf tmp/. ./vendor/eppo/php-sdk/ | ||
rm -Rf tmp | ||
|
||
# Run the poller | ||
php src/eppo_poller.php & | ||
|
||
echo "Listening on port ${SDK_RELAY_PORT}" | ||
|
||
php -S "0.0.0.0:${SDK_RELAY_PORT}" -t src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "eppo/php-sdk-test", | ||
"description": "Test server using the PHP SDK", | ||
"type": "project", | ||
"license": "MIT", | ||
"homepage": "https://github.com/Eppo-exp/sdk-test-data", | ||
"minimum-stability": "stable", | ||
"autoload": { | ||
"psr-4": { | ||
"Eppo\\SDKTest\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Ty Potter", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.1", | ||
"eppo/php-sdk": "^3.2", | ||
"vlucas/phpdotenv": "^5.6", | ||
"php-http/curl-client": "^2.3", | ||
"nyholm/psr7": "^1.8", | ||
"slim/slim": "^4.14", | ||
"slim/psr7": "^1.7", | ||
"php-di/php-di": "^7.0", | ||
"slim/http": "^1.4" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"php-http/discovery": true | ||
} | ||
} | ||
} |
Oops, something went wrong.