Skip to content

Commit

Permalink
upgrade caddy version and introduce phpmnd
Browse files Browse the repository at this point in the history
  • Loading branch information
mattvb91 committed Jun 9, 2024
1 parent 40a4eb4 commit a9f7b24
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
pull-image: true # Raise the flag to try to pull image

phpunit:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs:
- build-caddy-image
- build-composer-image
Expand All @@ -94,6 +94,7 @@ jobs:
docker run -v $(pwd):/app docker.pkg.github.com/mattvb91/${{ env.REPO_NAME }}/composer:head composer phpstan
docker run -v $(pwd):/app docker.pkg.github.com/mattvb91/${{ env.REPO_NAME }}/composer:head composer codesniffer
docker run -v $(pwd):/app docker.pkg.github.com/mattvb91/${{ env.REPO_NAME }}/composer:head composer rector
docker run -v $(pwd):/app docker.pkg.github.com/mattvb91/${{ env.REPO_NAME }}/composer:head composer phpmnd
docker run --network="caddy-network" -e XDEBUG_MODE=coverage -v $(pwd):/app docker.pkg.github.com/mattvb91/${{ env.REPO_NAME }}/composer:head composer phpunit
env:
REPO_NAME: ${{ github.event.repository.name }}
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"codesniffer": "phpcs ./src ./tests/**/*.php --standard=./codesniffer.xml -p",
"codefixer": "phpcbf ./src ./tests/**/*.php --standard=./codesniffer.xml",
"rector": "rector process --dry-run",
"rector-fix": "rector process"
"rector-fix": "rector process",
"phpmnd": "phpmnd ./src"
},
"autoload": {
"psr-4": {
Expand All @@ -26,13 +27,15 @@
},
"require": {
"php": "^8.1",
"guzzlehttp/guzzle": "^7.0"
"guzzlehttp/guzzle": "^7.0",
"symfony/http-foundation": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"dms/phpunit-arraysubset-asserts": "^0.4.0",
"phpstan/phpstan": "^1.10",
"squizlabs/php_codesniffer": "^3.7",
"rector/rector": "^0.17"
"rector/rector": "^1.0",
"povils/phpmnd": "^3.5"
}
}
3 changes: 1 addition & 2 deletions docker/caddy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM caddy:2.6.0-builder-alpine
FROM caddy:2.8.4-builder-alpine

RUN xcaddy build --with github.com/darkweak/souin/plugins/caddy@a2e88383a2bced983914cc12bde413ad8887b56d \
--with github.com/darkweak/souin@a2e88383a2bced983914cc12bde413ad8887b56d


# See https://caddyserver.com/docs/conventions#file-locations for details
ENV XDG_CONFIG_HOME /config
ENV XDG_DATA_HOME /data
Expand Down
9 changes: 5 additions & 4 deletions src/Caddy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use mattvb91\CaddyPhp\Exceptions\CaddyClientException;
use mattvb91\CaddyPhp\Interfaces\App;
use mattvb91\CaddyPhp\Interfaces\Arrayable;
use Symfony\Component\HttpFoundation\Response;

class Caddy implements Arrayable
{
Expand Down Expand Up @@ -94,7 +95,7 @@ public function addHostname(string $hostIdentifier, string $hostname): bool
if (
$this->client->put($this->hostsCache[$hostIdentifier]['path'] . '/0', [
'json' => $hostname,
])->getStatusCode() === 200
])->getStatusCode() === Response::HTTP_OK
) {
$this->hostsCache[$hostIdentifier]['host']->addHost($hostname);
return true;
Expand All @@ -116,7 +117,7 @@ public function removeHostname(string $hostIdentifier, string $hostname): bool
if (
$this->client->delete($path, [
'json' => $hostname,
])->getStatusCode() === 200
])->getStatusCode() === Response::HTTP_OK
) {
$this->hostsCache[$hostIdentifier]['host']->syncRemoveHost($hostname);
return true;
Expand Down Expand Up @@ -159,7 +160,7 @@ public function flushSurrogates(array $surrogates): bool
'Surrogate-Key' => implode(', ', $surrogates),
'Host' => $this->cacheHostnameHeader,
],
])->getStatusCode() === 204;
])->getStatusCode() === Response::HTTP_NO_CONTENT;
}

/**
Expand All @@ -171,7 +172,7 @@ public function load(): bool
try {
return $this->client->post('/load', [
'json' => $this->toArray(),
])->getStatusCode() === 200;
])->getStatusCode() === Response::HTTP_OK;
} catch (ClientException $e) {
throw new CaddyClientException(
$e->getResponse()->getBody() . PHP_EOL . json_encode($this->toArray(), JSON_PRETTY_PRINT)
Expand Down

0 comments on commit a9f7b24

Please sign in to comment.