From abd2eac1efe247b94538aa07e1262e1b1b15e602 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:11:50 +0100 Subject: [PATCH 1/9] fix: add tests ci --- .github/workflows/tests.yml | 18 ++++++++++++++++++ src/Compression/Compression.php | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..9ff75de --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,18 @@ +name: "Tests" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: [pull_request] +jobs: + build: + name: Build & Unit + runs-on: ubuntu-latest + + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + + - name: Unit Tests + run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit \ No newline at end of file diff --git a/src/Compression/Compression.php b/src/Compression/Compression.php index 36b2db6..dac35c6 100644 --- a/src/Compression/Compression.php +++ b/src/Compression/Compression.php @@ -113,7 +113,7 @@ public static function fromAcceptEncoding(string $acceptEncoding, array $support if (empty($supported)) { $supported = [ self::BROTLI => Algorithms\Brotli::isSupported(), - self::GZIP => Algorithms\Gzip::isSupported(), + self::GZIP => Algorithms\GZIP::isSupported(), self::DEFLATE => Algorithms\Deflate::isSupported(), self::IDENTITY => true, ]; From 8509f4b2784e3302d0e3fc606840e5a0fae73623 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:13:22 +0100 Subject: [PATCH 2/9] fix: docker --- .github/workflows/tests.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9ff75de..1504554 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,5 +14,28 @@ jobs: - name: Checkout Repo uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build image + uses: docker/build-push-action@v3 + with: + context: . + push: false + load: true + tags: storage-dev + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Start storage + run: | + docker compose up -d + sleep 10 + + - name: Doctor + run: | + docker compose logs tests + docker ps + - name: Unit Tests run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit \ No newline at end of file From 1fb40cd937aa0dcfd099792170d2271474aacdc5 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:15:36 +0100 Subject: [PATCH 3/9] fix: tests --- tests/Compression/Algorithms/BrotliTest.php | 6 +++--- tests/Compression/Algorithms/GZIPTest.php | 6 +++--- tests/Compression/Algorithms/LZ4Test.php | 4 ++-- tests/Compression/Algorithms/SnappyTest.php | 4 ++-- tests/Compression/Algorithms/XZTest.php | 4 ++-- tests/Compression/Algorithms/ZstdTest.php | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/Compression/Algorithms/BrotliTest.php b/tests/Compression/Algorithms/BrotliTest.php index 3e47f97..c2801a5 100644 --- a/tests/Compression/Algorithms/BrotliTest.php +++ b/tests/Compression/Algorithms/BrotliTest.php @@ -49,7 +49,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithLargeText() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/lorem.txt'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/lorem.txt'); $demoSize = mb_strlen($demo, '8bit'); $this->object->setLevel(8); @@ -70,7 +70,7 @@ public function testCompressDecompressWithLargeText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = mb_strlen($demo, '8bit'); $this->object->setLevel(8); @@ -89,7 +89,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = mb_strlen($demo, '8bit'); $this->object->setLevel(8); diff --git a/tests/Compression/Algorithms/GZIPTest.php b/tests/Compression/Algorithms/GZIPTest.php index f00fcd4..fff7e8b 100644 --- a/tests/Compression/Algorithms/GZIPTest.php +++ b/tests/Compression/Algorithms/GZIPTest.php @@ -42,7 +42,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithLargeText() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/lorem.txt'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/lorem.txt'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -61,7 +61,7 @@ public function testCompressDecompressWithLargeText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -80,7 +80,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); diff --git a/tests/Compression/Algorithms/LZ4Test.php b/tests/Compression/Algorithms/LZ4Test.php index d3c38ef..89f346e 100644 --- a/tests/Compression/Algorithms/LZ4Test.php +++ b/tests/Compression/Algorithms/LZ4Test.php @@ -39,7 +39,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -58,7 +58,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); diff --git a/tests/Compression/Algorithms/SnappyTest.php b/tests/Compression/Algorithms/SnappyTest.php index a1b9ed5..5859577 100644 --- a/tests/Compression/Algorithms/SnappyTest.php +++ b/tests/Compression/Algorithms/SnappyTest.php @@ -43,7 +43,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -62,7 +62,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); diff --git a/tests/Compression/Algorithms/XZTest.php b/tests/Compression/Algorithms/XZTest.php index 226075b..c81871b 100644 --- a/tests/Compression/Algorithms/XZTest.php +++ b/tests/Compression/Algorithms/XZTest.php @@ -39,7 +39,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -58,7 +58,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); diff --git a/tests/Compression/Algorithms/ZstdTest.php b/tests/Compression/Algorithms/ZstdTest.php index 1b2d51a..7ec65ff 100644 --- a/tests/Compression/Algorithms/ZstdTest.php +++ b/tests/Compression/Algorithms/ZstdTest.php @@ -39,7 +39,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithLargeText() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/lorem.txt'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/lorem.txt'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -58,7 +58,7 @@ public function testCompressDecompressWithLargeText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -77,7 +77,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); From 7fdf64888ea28278eb77f18106d777613dc5d425 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:23:32 +0100 Subject: [PATCH 4/9] chore: remove cache --- .github/workflows/tests.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1504554..56c9d67 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,20 +12,18 @@ jobs: steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build image - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: context: . push: false load: true - tags: storage-dev - cache-from: type=gha - cache-to: type=gha,mode=max + tags: storage-devs - name: Start storage run: | From 37ce39f68a02efbb02d08d01195c9d69035afc7c Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:27:27 +0100 Subject: [PATCH 5/9] fix: workdir --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 56c9d67..4efde97 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,7 +23,9 @@ jobs: context: . push: false load: true - tags: storage-devs + tags: storage-dev + cache-from: type=gha + cache-to: type=gha,mode=max - name: Start storage run: | From 39f576b070313237aed49789ff9708ad3ccce572 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:30:02 +0100 Subject: [PATCH 6/9] debug: logs --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4efde97..83af10c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,6 +36,8 @@ jobs: run: | docker compose logs tests docker ps + docker compose exec -T tests ls -la /usr/src/code/vendor/bin + docker compose exec -T tests pwd - name: Unit Tests run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit \ No newline at end of file From 8d808fe77903ba1f13765494004452c46003c18b Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:31:43 +0100 Subject: [PATCH 7/9] fix: doctor --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index cfb0a89..87f758c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: '3.1' services: tests: container_name: tests + working_dir: /usr/src/code build: context: . volumes: From a13619b77f720ce2e87cd0c16f155e21ce3fcc7c Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:33:14 +0100 Subject: [PATCH 8/9] debug: remove bin --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 83af10c..309eeee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,7 +36,7 @@ jobs: run: | docker compose logs tests docker ps - docker compose exec -T tests ls -la /usr/src/code/vendor/bin + docker compose exec -T tests ls -la /usr/src/code docker compose exec -T tests pwd - name: Unit Tests From a2704e7cf391d50bc186c809ce4e58fde4cd39c3 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:37:14 +0100 Subject: [PATCH 9/9] fix vendor --- .github/workflows/tests.yml | 8 -------- docker-compose.yml | 3 ++- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 309eeee..6a1aa33 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,14 +30,6 @@ jobs: - name: Start storage run: | docker compose up -d - sleep 10 - - - name: Doctor - run: | - docker compose logs tests - docker ps - docker compose exec -T tests ls -la /usr/src/code - docker compose exec -T tests pwd - name: Unit Tests run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 87f758c..1b7547e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,4 +7,5 @@ services: build: context: . volumes: - - ./:/usr/src/code \ No newline at end of file + - ./:/usr/src/code + - /usr/src/code/vendor \ No newline at end of file