From 06b093362bbbf335a061369d833841c621db2af0 Mon Sep 17 00:00:00 2001
From: Matthew Baggett <matthew@baggett.me>
Date: Sat, 18 May 2024 17:31:44 +0200
Subject: [PATCH] Lets try that builder again.

---
 .github/workflows/build.yml           |  2 +-
 .github/workflows/docker.build.yml    | 40 ++++++---------------------
 .github/workflows/docker.release.yml  | 11 +++++---
 .github/workflows/docker.validate.yml |  2 +-
 .github/workflows/php.check.yml       | 32 ++++-----------------
 .github/workflows/trunk.cache.yml     |  9 ++----
 .github/workflows/trunk.check.yml     |  9 ++----
 .github/workflows/trunk.upgrade.yml   |  9 ++----
 rector.php                            |  1 -
 src/Bouncer.php                       |  1 +
 src/Logger/Handlers/Cli.php           |  4 +--
 src/Logger/Handlers/Test.php          |  4 +--
 src/Target.php                        | 24 ++++++++--------
 tests/testsites/index.php             |  8 ++++--
 14 files changed, 47 insertions(+), 109 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0876129..3ab1ec9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,4 +1,4 @@
-name: Build Swarm Loadbalancer
+name: "Build"
 
 permissions:
   contents: read
diff --git a/.github/workflows/docker.build.yml b/.github/workflows/docker.build.yml
index b5b6a8d..3c92fda 100644
--- a/.github/workflows/docker.build.yml
+++ b/.github/workflows/docker.build.yml
@@ -1,4 +1,4 @@
-name: Build Swarm Loadbalancer
+name: "Build: Docker"
 
 permissions:
   contents: read
@@ -21,37 +21,13 @@ jobs:
     name: Build Swarm Loadbalancer
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v4
-      - id: date
-        run: |
-          {
-            echo "datetime=$(date +'%Y-%m-%d %H:%M:%S')"
-            echo "date=$(date +'%Y-%m-%d')"
-            echo "time=$(date +'%H:%M:%S')"
-            echo "container_build_datetime=$(date -u +'%Y-%m-%dT%H:%M:%S.%3NZ')"
-          } >> "$GITHUB_OUTPUT"
-      - id: read-php-version
-        run: echo "php_version=$(jq -r '.require["php"]' composer.json | sed -E 's/[^0-9.]//g')" >> $GITHUB_OUTPUT
-      - uses: shivammathur/setup-php@v2
+      - uses: benzine-framework/action-setup-php@main
+      - uses: benzine-framework/action-setup-docker@main
         with:
-          php-version: ${{ steps.read-php-version.outputs.php_version }}
-      - uses: docker/setup-qemu-action@v3
-      - uses: crazy-max/ghaction-github-runtime@v3
-      - uses: docker/setup-buildx-action@v3
-      - uses: docker/login-action@v3
-        with:
-          registry: ghcr.io
-          username: matthewbaggett
-          password: ${{ secrets.GITHUB_TOKEN }}
-      - id: composer-cache-find
-        run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
-      - id: composer-cache
-        uses: actions/cache@v4
-        with:
-          path: ${{ steps.composer-cache-find.outputs.dir }}
-          key: "${{ runner.os }}-bouncer-composer-${{ hashFiles('**/composer.lock') }}"
-          restore-keys: ${{ runner.os }}-bouncer-composer-
-      - run: composer install --ignore-platform-reqs --prefer-dist
+          ghcr_user: ${{ github.repository_owner }}
+          ghcr_token: ${{ secrets.GHCR_TOKEN }}
+          docker_hub_user: ${{ secrets.DOCKER_HUB_USER }}
+          docker_hub_token: ${{ secrets.DOCKER_HUB_TOKEN }}
       - name: "Build & Push Candidate Image as ${{ env.CANDIDATE_IMAGE }}"
         uses: docker/build-push-action@v5
         with:
@@ -62,8 +38,8 @@ jobs:
           build-args: |
             GIT_SHA=${{ github.sha }}
             GIT_BUILD_ID=${{ github.ref_name }}
-            BUILD_DATE=${{ steps.date.outputs.container_build_datetime }}
             GIT_COMMIT_MESSAGE=${{ github.event.head_commit.message }}
+            BUILD_DATE=${{ steps.date.outputs.container_build_datetime }}
           platforms: ${{ !env.ACT && env.PLATFORMS || 'linux/amd64' }}
           pull: true
           push: true
diff --git a/.github/workflows/docker.release.yml b/.github/workflows/docker.release.yml
index 13baa2a..d0fcfa3 100644
--- a/.github/workflows/docker.release.yml
+++ b/.github/workflows/docker.release.yml
@@ -1,4 +1,4 @@
-name: Release Swarm Loadbalancer
+name: "Build: Release"
 
 permissions:
   contents: read
@@ -30,9 +30,12 @@ jobs:
     steps:
       - name: "Pull Candidate Image"
         run: docker pull ${{ env.CANDIDATE_IMAGE }}
-      - name: "Login to Docker Hub"
-        if: matrix.registry == 'docker'
-        run: docker login -u matthewbaggett -p ${{ secrets.DOCKER_HUB_TOKEN }}
+      - uses: benzine-framework/action-setup-docker@main
+        with:
+          ghcr_user: ${{ github.repository_owner }}
+          ghcr_token: ${{ secrets.GHCR_TOKEN }}
+          docker_hub_user: ${{ secrets.DOCKER_HUB_USER }}
+          docker_hub_token: ${{ secrets.DOCKER_HUB_TOKEN }}
       - name: "Login to GHCR"
         if: matrix.registry == 'ghcr'
         run: docker login ghcr.io -u matthewbaggett -p ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/docker.validate.yml b/.github/workflows/docker.validate.yml
index 6b09c57..390079a 100644
--- a/.github/workflows/docker.validate.yml
+++ b/.github/workflows/docker.validate.yml
@@ -1,4 +1,4 @@
-name: Validate Swarm Loadbalancer
+name: "Build: Validate"
 
 permissions:
   contents: read
diff --git a/.github/workflows/php.check.yml b/.github/workflows/php.check.yml
index 155ae92..c5b808e 100644
--- a/.github/workflows/php.check.yml
+++ b/.github/workflows/php.check.yml
@@ -1,4 +1,4 @@
-name: "QC: PHP"
+name: "Quality Control: PHP"
 
 permissions:
   contents: read
@@ -24,23 +24,8 @@ jobs:
       checks: write # To post annotations
       contents: read # For repo checkout
     steps:
-      - uses: actions/checkout@v4
-      - id: read-php-version
-        run: echo "php_version=$(jq -r '.require["php"]' composer.json | sed -E 's/[^0-9.]//g')" >> $GITHUB_OUTPUT
-      - uses: shivammathur/setup-php@v2
-        with:
-          php-version: ${{ steps.read-php-version.outputs.php_version }}
-          tools: phpstan
-      - id: composer-cache-find
-        run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
-      - id: composer-cache
-        uses: actions/cache@v4
-        with:
-          path: ${{ steps.composer-cache-find.outputs.dir }}
-          key: "${{ runner.os }}-bouncer-composer-${{ hashFiles('**/composer.lock') }}"
-          restore-keys: ${{ runner.os }}-bouncer-composer-
-      - run: composer install --ignore-platform-reqs --prefer-dist
-      - run: phpstan analyse src
+      - uses: benzine-framework/action-setup-php@main
+      - run: vendor/bin/phpstan analyse src
 
   php-cs-fixer:
     name: PHP-CS-Fixer
@@ -48,13 +33,6 @@ jobs:
     permissions:
       checks: write # For trunk to post annotations
       contents: read # For repo checkout
-      pull-requests: write # To create PRs
     steps:
-      - uses: actions/checkout@v4
-      - id: read-php-version
-        run: echo "php_version=$(jq -r '.require["php"]' composer.json | sed -E 's/[^0-9.]//g')" >> $GITHUB_OUTPUT
-      - uses: shivammathur/setup-php@v2
-        with:
-          php-version: ${{ steps.read-php-version.outputs.php_version }}
-          tools: php-cs-fixer
-      - run: php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose --dry-run
+      - uses: benzine-framework/action-setup-php@main
+      - run: vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
diff --git a/.github/workflows/trunk.cache.yml b/.github/workflows/trunk.cache.yml
index 6e3c66f..bed5347 100644
--- a/.github/workflows/trunk.cache.yml
+++ b/.github/workflows/trunk.cache.yml
@@ -1,4 +1,4 @@
-name: Trunk Cache
+name: "Quality Control: Trunk Cache"
 
 permissions: read-all
 
@@ -24,12 +24,7 @@ jobs:
     permissions:
       actions: write
     steps:
-      - name: "Setup PHP"
-        uses: shivammathur/setup-php@v2
-        with:
-          php-version: 8.3
-      - name: "Checkout"
-        uses: actions/checkout@v4
+      - uses: benzine-framework/action-setup-php@main
       - name: "Trunk Cache"
         uses: trunk-io/trunk-action@v1
         with:
diff --git a/.github/workflows/trunk.check.yml b/.github/workflows/trunk.check.yml
index 2e06a65..54331d0 100644
--- a/.github/workflows/trunk.check.yml
+++ b/.github/workflows/trunk.check.yml
@@ -1,4 +1,4 @@
-name: Trunk Check
+name: "Quality Control: Trunk Check"
 
 permissions: read-all
 
@@ -23,11 +23,6 @@ jobs:
       checks: write # For trunk to post annotations
       contents: read # For repo checkout
     steps:
-      - name: "Setup PHP"
-        uses: shivammathur/setup-php@v2
-        with:
-          php-version: 8.3
-      - name: "Checkout"
-        uses: actions/checkout@v4
+      - uses: benzine-framework/action-setup-php@main
       - name: "Trunk Check"
         uses: trunk-io/trunk-action@v1
diff --git a/.github/workflows/trunk.upgrade.yml b/.github/workflows/trunk.upgrade.yml
index cc870b3..5d9774a 100644
--- a/.github/workflows/trunk.upgrade.yml
+++ b/.github/workflows/trunk.upgrade.yml
@@ -1,4 +1,4 @@
-name: Trunk Upgrade
+name: "Quality Control: Trunk Upgrade"
 
 permissions: read-all
 
@@ -26,12 +26,7 @@ jobs:
       contents: write # For trunk to create PRs
       pull-requests: write # For trunk to create PRs
     steps:
-      - name: "Setup PHP"
-        uses: shivammathur/setup-php@v2
-        with:
-          php-version: 8.3
-      - name: "Checkout"
-        uses: actions/checkout@v4
+      - uses: benzine-framework/action-setup-php@main
       - name: "Trunk Upgrade"
         uses: trunk-io/trunk-action/upgrade@v1
       - name: "PR: Find Pull Request"
diff --git a/rector.php b/rector.php
index 193b612..1514510 100644
--- a/rector.php
+++ b/rector.php
@@ -11,7 +11,6 @@ use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
 use Rector\PHPUnit\Rector\Class_\PreferPHPUnitSelfCallRector;
 use Rector\PHPUnit\Set\PHPUnitSetList;
 use Rector\Removing\Rector\FuncCall\RemoveFuncCallRector;
-use Rector\Renaming\Rector\Name\RenameClassRector;
 use Rector\Symfony\Set\SensiolabsSetList;
 use Rector\Symfony\Set\SymfonySetList;
 use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
diff --git a/src/Bouncer.php b/src/Bouncer.php
index e614bd6..33ae816 100644
--- a/src/Bouncer.php
+++ b/src/Bouncer.php
@@ -659,6 +659,7 @@ class Bouncer
         if (array_reduce($targets, fn ($carry, $target) => $carry || $target->requiresForcedScanning(), false)) {
             $this->logger->warning('Forcing an update in 5 seconds because one or more targets require it.', ['emoji' => Emoji::warning()]);
             sleep(5);
+
             return;
         }
 
diff --git a/src/Logger/Handlers/Cli.php b/src/Logger/Handlers/Cli.php
index c18a4b9..e1d59c0 100644
--- a/src/Logger/Handlers/Cli.php
+++ b/src/Logger/Handlers/Cli.php
@@ -6,6 +6,4 @@ namespace Bouncer\Logger\Handlers;
 
 use Monolog\Handler\StreamHandler;
 
-class Cli extends StreamHandler
-{
-}
+class Cli extends StreamHandler {}
diff --git a/src/Logger/Handlers/Test.php b/src/Logger/Handlers/Test.php
index b375393..84e1246 100644
--- a/src/Logger/Handlers/Test.php
+++ b/src/Logger/Handlers/Test.php
@@ -11,6 +11,4 @@ use Monolog\Handler\TestHandler;
  *
  * @coversNothing
  */
-class Test extends TestHandler
-{
-}
+class Test extends TestHandler {}
diff --git a/src/Target.php b/src/Target.php
index d5d1f97..12b783b 100644
--- a/src/Target.php
+++ b/src/Target.php
@@ -7,7 +7,6 @@ namespace Bouncer;
 use Bouncer\Logger\AbstractLogger;
 use Bouncer\Logger\Logger;
 use Bouncer\Settings\Settings;
-use Psr\Log\LoggerInterface;
 use Spatie\Emoji\Emoji;
 
 class Target
@@ -20,17 +19,17 @@ class Target
     private bool $letsEncrypt = false;
     private string $targetPath;
     private bool $allowNonSSL;
-    private bool $useTemporaryCert      = false;
-    private bool $useGlobalCert         = false;
-    private ?string $customCert         = null;
-    private ?string $customCertKey      = null;
-    private bool $allowWebsocketSupport = true;
-    private bool $allowLargePayloads    = false;
-    private ?int $proxyTimeoutSeconds   = null;
-    private ?string $username           = null;
-    private ?string $password           = null;
-    private ?string $hostOverride      = null;
-    private ?string $customNginxConfig = null;
+    private bool $useTemporaryCert       = false;
+    private bool $useGlobalCert          = false;
+    private ?string $customCert          = null;
+    private ?string $customCertKey       = null;
+    private bool $allowWebsocketSupport  = true;
+    private bool $allowLargePayloads     = false;
+    private ?int $proxyTimeoutSeconds    = null;
+    private ?string $username            = null;
+    private ?string $password            = null;
+    private ?string $hostOverride        = null;
+    private ?string $customNginxConfig   = null;
     private bool $requiresForcedScanning = false;
 
     public function __construct(
@@ -414,7 +413,6 @@ class Target
         return $this;
     }
 
-
     public function updateLogger(): self
     {
         $this->logger = $this->logger->withName($this->getLabel());
diff --git a/tests/testsites/index.php b/tests/testsites/index.php
index 3a3a611..0abc9e8 100644
--- a/tests/testsites/index.php
+++ b/tests/testsites/index.php
@@ -1,5 +1,7 @@
 <?php
+
+declare(strict_types=1);
 $environment = array_merge($_ENV, $_SERVER);
-$site = $environment['SITE_NAME'] ?? 'unknown';
-$server = $environment['SERVER_NAME'] ?? gethostname();
-printf("<h1>Website %s</h1><p>Running on %s</p>", $site, $server);
+$site        = $environment['SITE_NAME']     ?? 'unknown';
+$server      = $environment['SERVER_NAME'] ?? gethostname();
+printf('<h1>Website %s</h1><p>Running on %s</p>', $site, $server);