Skip to content

Commit 2cb737d

Browse files
Merge pull request #7 from pimjansen/feature/ci
2 parents 71e9909 + 9729f5f commit 2cb737d

File tree

9 files changed

+163
-10
lines changed

9 files changed

+163
-10
lines changed

.docker/www.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[global]
2+
; pid = /var/run/php-fpm.pid
3+
error_log = /proc/self/fd/2
4+
log_level = notice
5+
daemonize = no
6+
; https://github.com/docker-library/php/pull/725#issuecomment-443540114
7+
log_limit = 8192
8+
9+
[www]
10+
user = azure-oss
11+
group = azure-oss
12+
13+
listen = 127.0.0.1:9000
14+
catch_workers_output = yes
15+
decorate_workers_output = no
16+
17+
; Allow access to the environment variables that were passed on to Docker
18+
clear_env = no
19+
20+
; Process manager
21+
pm = ondemand
22+
pm.max_children = 5
23+
pm.process_idle_timeout = 10s
24+
pm.max_requests = 500
25+
pm.status_path = /status

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/vendor/
2-
composer.lock
3-
.idea
4-
.phpunit.cache
2+
/composer.lock
3+
/.idea
4+
/.build

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM php:8.1-fpm-buster
2+
3+
# Install Composer
4+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
5+
6+
# Install PHP package installer
7+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
8+
9+
# Install packages
10+
RUN apt update && apt install -y zip curl fcgiwrap && \
11+
chmod uga+x /usr/local/bin/install-php-extensions && \
12+
install-php-extensions curl && \
13+
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
14+
15+
ENV USER=azure-oss
16+
ENV UID=10000
17+
ENV GID=10001
18+
19+
RUN addgroup \
20+
--gid $GID \
21+
--system $USER \
22+
&& adduser \
23+
--uid $UID \
24+
--disabled-password \
25+
--gecos "" \
26+
--ingroup $USER \
27+
$USER \
28+
&& mkdir -p /app \
29+
&& chown -R $UID:$GID /app
30+
31+
# Add configuration files for PHP and PHPFPM
32+
COPY ./.docker/www.conf /usr/local/etc/php-fpm.d/
33+
34+
ARG UID=${UID:-10000}
35+
ARG GID=${GID:-10001}
36+
ARG USER=${USER:-azure-oss}
37+
RUN usermod -u $UID $USER && groupmod -g $GID $USER
38+
39+
WORKDIR /app

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.PHONY: build
2+
build: cs static test install ## Runs cs, static, and test targets
3+
4+
# https://www.gnu.org/software/make/manual/html_node/Force-Targets.html
5+
always:
6+
7+
.PHONY: help
8+
help:
9+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
10+
11+
.PHONY: install
12+
install: ## Install depedencies
13+
docker compose run phpfpm rm -rf composer.lock
14+
docker compose run phpfpm composer install
15+
16+
.PHONY: cs
17+
cs: ## Fixes coding standard issues with laravel/pint
18+
docker compose run phpfpm vendor/bin/pint --repair
19+
20+
.PHONY: coverage
21+
coverage: ## Collects coverage with phpunit
22+
docker compose run phpfpm vendor/bin/phpunit --coverage-text --coverage-clover=.build/logs/clover.xml
23+
24+
.PHONY: test
25+
test: ## Runs tests with phpunit
26+
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
27+
28+
.PHONY: static
29+
static: ## Runs static analyzers
30+
docker compose run phpfpm vendor/bin/phpstan --memory-limit=2G
31+
32+
.PHONY: baseline
33+
baseline: ## Generate baseline files
34+
docker compose run phpfpm vendor/bin/phpstan --memory-limit=2G --generate-baseline
35+
36+
.PHONY: clean
37+
clean: ## Cleans up build and vendor files
38+
rm -rf vendor composer.lock .build
39+
40+
.PHONY: bc
41+
bc: ## Check for breaking changes since last release
42+
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

compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
services:
2+
phpfpm:
3+
build:
4+
context: .
5+
args:
6+
UID: ${USER_ID:-1000}
7+
GID: ${GROUP_ID:-1000}
8+
user: "${UID:-1000}:${GID:-1000}"
9+
links:
10+
- "azurite"
11+
volumes:
12+
- .:/app
13+
14+
azurite:
15+
image: mcr.microsoft.com/azure-storage/azurite
16+
ports:
17+
- 10000:10000
18+
- 10001:10001
19+
- 10002:10002
20+
volumes:
21+
- azurite:/data
22+
23+
volumes:
24+
azurite:
25+
driver: local

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"autoload-dev": {
1212
"psr-4": {
13-
"AzureOss\\LaravelAzureStorageBlob\\Tests": "tests/"
13+
"AzureOss\\LaravelAzureStorageBlob\\Tests\\": "tests/"
1414
}
1515
},
1616
"authors": [
@@ -27,7 +27,7 @@
2727
},
2828
"require-dev": {
2929
"laravel/pint": "^1.17",
30-
"orchestra/testbench": "^9.2",
30+
"orchestra/testbench": "^8.27",
3131
"phpstan/phpstan": "^1.11",
3232
"phpstan/phpstan-deprecation-rules": "^1.2",
3333
"phpstan/phpstan-strict-rules": "^1.6"

phpunit.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5-
cacheDirectory=".phpunit.cache"
5+
cacheDirectory=".build/.phpunit.cache"
66
executionOrder="depends,defects"
7-
shortenArraysForExportThreshold="10"
7+
beStrictAboutCoverageMetadata="true"
88
beStrictAboutOutputDuringTests="true"
99
failOnRisky="true"
10-
failOnWarning="true">
10+
failOnWarning="true"
11+
displayDetailsOnTestsThatTriggerWarnings="true">
1112
<php>
1213
<env name="AZURE_STORAGE_CONNECTION_STRING" value="UseDevelopmentStorage=true"/>
1314
<env name="AZURE_STORAGE_CONTAINER" value="testing"/>
@@ -19,7 +20,7 @@
1920
</testsuite>
2021
</testsuites>
2122

22-
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
23+
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
2324
<include>
2425
<directory>src</directory>
2526
</include>

src/AzureStorageBlobServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function boot(): void
2626
if (isset($config['prefix']) && ! is_string($config['prefix'])) {
2727
throw new \InvalidArgumentException('The [prefix] must be a string in the disk configuration.');
2828
}
29-
29+
3030
if (isset($config['root']) && ! is_string($config['root'])) {
3131
throw new \InvalidArgumentException('The [root] must be a string in the disk configuration.');
3232
}

tests/AzureStorageBlobAdapterTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use AzureOss\LaravelAzureStorageBlob\AzureStorageBlobAdapter;
66
use AzureOss\LaravelAzureStorageBlob\AzureStorageBlobServiceProvider;
7+
use AzureOss\Storage\Blob\BlobContainerClient;
8+
use AzureOss\Storage\Blob\BlobServiceClient;
79
use Illuminate\Support\Facades\Http;
810
use Illuminate\Support\Facades\Storage;
911
use Orchestra\Testbench\TestCase;
@@ -25,6 +27,25 @@ protected function getEnvironmentSetUp($app): void
2527
]);
2628
}
2729

30+
private static function createContainerClient(): BlobContainerClient
31+
{
32+
$connectionString = getenv('AZURE_STORAGE_CONNECTION_STRING');
33+
34+
if (empty($connectionString)) {
35+
self::markTestSkipped('AZURE_STORAGE_CONNECTION_STRING is not provided.');
36+
}
37+
38+
return BlobServiceClient::fromConnectionString($connectionString)->getContainerClient(
39+
getenv('AZURE_STORAGE_CONTAINER')
40+
);
41+
}
42+
43+
public static function setUpBeforeClass(): void
44+
{
45+
self::createContainerClient()->deleteIfExists();
46+
self::createContainerClient()->create();
47+
}
48+
2849
#[Test]
2950
public function it_resolves_from_manager(): void
3051
{

0 commit comments

Comments
 (0)