diff --git a/.github/workflows/packagist-deploy.yml b/.github/workflows/packagist-deploy.yml new file mode 100644 index 0000000..6fea6b5 --- /dev/null +++ b/.github/workflows/packagist-deploy.yml @@ -0,0 +1,20 @@ +name: Packagist Deploy + +on: + release: + types: [created] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + - uses: mnavarrocarter/packagist-update@v1.0.0 + with: + username: "GautierDele" + api_token: ${{ secrets.PACKAGIST_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..f7a5a0b --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,48 @@ +name: tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: [ '8.3', '8.4' ] + + name: Tests on PHP ${{ matrix.php-version }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php-version }}- + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer i --prefer-dist --no-progress + + - name: Run test suite + run: vendor/bin/phpunit \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f631e3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/vendor +composer.lock +.phpunit* +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4e19af6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM php:latest + +RUN apt update +RUN apt install unzip curl -y + +RUN curl -sS https://getcomposer.org/installer -o /usr/local/composer-setup.php + +RUN php /usr/local/composer-setup.php --install-dir=/usr/local/bin --filename=composer + +RUN rm /usr/local/composer-setup.php diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..c2aca40 --- /dev/null +++ b/composer.json @@ -0,0 +1,44 @@ +{ + "name": "xefi/faker-php-files", + "type": "library", + "description": "Faker extension to generate files", + "keywords": [ + "faker", + "file", + "image" + ], + "license": "MIT", + "authors": [ + { + "name": "Gautier Deleglise" + } + ], + "require": { + "php": "^8.3", + "psr/container": "^2.0", + "xefi/faker-php": "^0" + }, + "require-dev": { + "phpunit/phpunit": "^11" + }, + "autoload": { + "psr-4": { + "Xefi\\Faker\\Files\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Xefi\\Faker\\Files\\Tests\\": "tests/" + } + }, + "config": { + "sort-packages": true + }, + "extra": { + "faker": { + "providers": [ + "Xefi\\Faker\\Files\\FakerFilesServiceProvider" + ] + } + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bee3307 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + php: + build: . + image: php:latest + volumes: + - ./:/var/www/html + working_dir: /var/www/html + tty: true \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..a354244 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,22 @@ + + + + + tests/Unit + + + + + src + + + + + \ No newline at end of file diff --git a/src/Extensions/ImagesExtension.php b/src/Extensions/ImagesExtension.php new file mode 100644 index 0000000..cccd04a --- /dev/null +++ b/src/Extensions/ImagesExtension.php @@ -0,0 +1,10 @@ +extensions([ + ImagesExtension::class + ]); + } + +} \ No newline at end of file