Skip to content

Commit

Permalink
Merge pull request #4 from utopia-php/fix-gzip
Browse files Browse the repository at this point in the history
fix: add tests ci and & gzip
  • Loading branch information
loks0n authored Nov 8, 2024
2 parents 2ac5709 + a2704e7 commit 6062f70
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 17 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image
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

- name: Start storage
run: |
docker compose up -d
- name: Unit Tests
run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ version: '3.1'
services:
tests:
container_name: tests
working_dir: /usr/src/code
build:
context: .
volumes:
- ./:/usr/src/code
- ./:/usr/src/code
- /usr/src/code/vendor
2 changes: 1 addition & 1 deletion src/Compression/Compression.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
Expand Down
6 changes: 3 additions & 3 deletions tests/Compression/Algorithms/BrotliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/Compression/Algorithms/GZIPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/Compression/Algorithms/LZ4Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/Compression/Algorithms/SnappyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/Compression/Algorithms/XZTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/Compression/Algorithms/ZstdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 6062f70

Please sign in to comment.