Skip to content
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
25 changes: 25 additions & 0 deletions .docker/www.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[global]
; pid = /var/run/php-fpm.pid
error_log = /proc/self/fd/2
log_level = notice
daemonize = no
; https://github.com/docker-library/php/pull/725#issuecomment-443540114
log_limit = 8192

[www]
user = azure-oss
group = azure-oss

listen = 127.0.0.1:9000
catch_workers_output = yes
decorate_workers_output = no

; Allow access to the environment variables that were passed on to Docker
clear_env = no

; Process manager
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 500
pm.status_path = /status
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/vendor/
composer.lock
.idea
.phpunit.cache
/composer.lock
/.idea
/.build
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM php:8.1-fpm-buster

# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

# Install PHP package installer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

# Install packages
RUN apt update && apt install -y zip curl fcgiwrap && \
chmod uga+x /usr/local/bin/install-php-extensions && \
install-php-extensions curl && \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

ENV USER=azure-oss
ENV UID=10000
ENV GID=10001

RUN addgroup \
--gid $GID \
--system $USER \
&& adduser \
--uid $UID \
--disabled-password \
--gecos "" \
--ingroup $USER \
$USER \
&& mkdir -p /app \
&& chown -R $UID:$GID /app

# Add configuration files for PHP and PHPFPM
COPY ./.docker/www.conf /usr/local/etc/php-fpm.d/

ARG UID=${UID:-10000}
ARG GID=${GID:-10001}
ARG USER=${USER:-azure-oss}
RUN usermod -u $UID $USER && groupmod -g $GID $USER

WORKDIR /app
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.PHONY: build
build: cs static test install ## Runs cs, static, and test targets

# https://www.gnu.org/software/make/manual/html_node/Force-Targets.html
always:

.PHONY: help
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: install
install: ## Install depedencies
docker compose run phpfpm rm -rf composer.lock
docker compose run phpfpm composer install

.PHONY: cs
cs: ## Fixes coding standard issues with laravel/pint
docker compose run phpfpm vendor/bin/pint --repair

.PHONY: coverage
coverage: ## Collects coverage with phpunit
docker compose run phpfpm vendor/bin/phpunit --coverage-text --coverage-clover=.build/logs/clover.xml

.PHONY: test
test: ## Runs tests with phpunit
docker compose run -e AZURE_STORAGE_CONNECTION_STRING="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;TableEndpoint=http://azurite:10002/devstoreaccount1;" phpfpm vendor/bin/phpunit

.PHONY: static
static: ## Runs static analyzers
docker compose run phpfpm vendor/bin/phpstan --memory-limit=2G

.PHONY: baseline
baseline: ## Generate baseline files
docker compose run phpfpm vendor/bin/phpstan --memory-limit=2G --generate-baseline

.PHONY: clean
clean: ## Cleans up build and vendor files
rm -rf vendor composer.lock .build

.PHONY: bc
bc: ## Check for breaking changes since last release
docker run --env GITHUB_REPOSITORY="Azure-OSS/azure-storage-php-adapter-laravel" -u $(shell id -u) -v $(shell pwd):/app nyholm/roave-bc-check-ga
25 changes: 25 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
phpfpm:
build:
context: .
args:
UID: ${USER_ID:-1000}
GID: ${GROUP_ID:-1000}
user: "${UID:-1000}:${GID:-1000}"
links:
- "azurite"
volumes:
- .:/app

azurite:
image: mcr.microsoft.com/azure-storage/azurite
ports:
- 10000:10000
- 10001:10001
- 10002:10002
volumes:
- azurite:/data

volumes:
azurite:
driver: local
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"autoload-dev": {
"psr-4": {
"AzureOss\\LaravelAzureStorageBlob\\Tests": "tests/"
"AzureOss\\LaravelAzureStorageBlob\\Tests\\": "tests/"
}
},
"authors": [
Expand All @@ -27,7 +27,7 @@
},
"require-dev": {
"laravel/pint": "^1.17",
"orchestra/testbench": "^9.2",
"orchestra/testbench": "^8.27",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpstan/phpstan-strict-rules": "^1.6"
Expand Down
9 changes: 5 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
cacheDirectory=".build/.phpunit.cache"
executionOrder="depends,defects"
shortenArraysForExportThreshold="10"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true">
failOnWarning="true"
displayDetailsOnTestsThatTriggerWarnings="true">
<php>
<env name="AZURE_STORAGE_CONNECTION_STRING" value="UseDevelopmentStorage=true"/>
<env name="AZURE_STORAGE_CONTAINER" value="testing"/>
Expand All @@ -19,7 +20,7 @@
</testsuite>
</testsuites>

<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
Expand Down
2 changes: 1 addition & 1 deletion src/AzureStorageBlobServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function boot(): void
if (isset($config['prefix']) && ! is_string($config['prefix'])) {
throw new \InvalidArgumentException('The [prefix] must be a string in the disk configuration.');
}

if (isset($config['root']) && ! is_string($config['root'])) {
throw new \InvalidArgumentException('The [root] must be a string in the disk configuration.');
}
Expand Down
21 changes: 21 additions & 0 deletions tests/AzureStorageBlobAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use AzureOss\LaravelAzureStorageBlob\AzureStorageBlobAdapter;
use AzureOss\LaravelAzureStorageBlob\AzureStorageBlobServiceProvider;
use AzureOss\Storage\Blob\BlobContainerClient;
use AzureOss\Storage\Blob\BlobServiceClient;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
use Orchestra\Testbench\TestCase;
Expand All @@ -25,6 +27,25 @@ protected function getEnvironmentSetUp($app): void
]);
}

private static function createContainerClient(): BlobContainerClient
{
$connectionString = getenv('AZURE_STORAGE_CONNECTION_STRING');

if (empty($connectionString)) {
self::markTestSkipped('AZURE_STORAGE_CONNECTION_STRING is not provided.');
}

return BlobServiceClient::fromConnectionString($connectionString)->getContainerClient(
getenv('AZURE_STORAGE_CONTAINER')
);
}

public static function setUpBeforeClass(): void
{
self::createContainerClient()->deleteIfExists();
self::createContainerClient()->create();
}

#[Test]
public function it_resolves_from_manager(): void
{
Expand Down