Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add tests ci and & gzip #4

Merged
merged 9 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading