Skip to content

Commit

Permalink
feat(BE-2913): update guzzle ci and docker (#17)
Browse files Browse the repository at this point in the history
* feat(BE-2913): update guzzle ci and docker

* feat(BE-2913): docker adjustments

* chore(): code & tests adjustments

* feat(BE-2913): T&V Feedback; remove useless or wrong PHPDoc

Co-authored-by: Călin Blaga <calin.blaga@jobcloud.ch>
  • Loading branch information
haeber and calinblaga committed Aug 2, 2022
1 parent cbff245 commit ea730bb
Show file tree
Hide file tree
Showing 22 changed files with 195 additions and 229 deletions.
11 changes: 3 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,27 @@ orbs:
ci-php: jobcloud/ci-php@2.4

workflows:
php-kafka-schema-registry-client:
version: 2
test-php-kafka-schema-registry-client:
jobs:
- ci-caching/build-docker-images:
dockerComposeFile: "./docker/docker-compose.yml"
- ci-caching/build-docker-images
- ci-php/install-dependencies:
dockerComposeFile: "./docker/docker-compose.yml"
dependencyCheckSumFile: "./composer.json"
requires:
- ci-caching/build-docker-images
- ci-php/coverage:
dockerComposeFile: "./docker/docker-compose.yml"
dependencyCheckSumFile: "./composer.json"
requires:
- ci-php/install-dependencies
- ci-php/code-style:
dockerComposeFile: "./docker/docker-compose.yml"
dependencyCheckSumFile: "./composer.json"
requires:
- ci-php/install-dependencies
- ci-php/static-analysis:
dockerComposeFile: "./docker/docker-compose.yml"
dependencyCheckSumFile: "./composer.json"
requires:
- ci-php/install-dependencies
- ci-php/infection-testing:
dockerComposeFile: "./docker/docker-compose.yml"
dependencyCheckSumFile: "./composer.json"
requires:
- ci-php/install-dependencies
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# Packages
vendor/
composer.lock
composer.symlink

# Builds & caches
/build/
.phpunit.result.cache

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ composer require jobcloud/php-kafka-schema-registry-client
```

## Requirements
- php: >= 7.4
- php: ^7.4|^8.0

## Supported API calls
Currently it supports:
Expand Down
31 changes: 19 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,42 @@
"keywords": ["kafka", "schema", "registry", "php"],
"autoload": {
"psr-4": {
"Jobcloud\\Kafka\\SchemaRegistryClient\\": "src/",
"Jobcloud\\Kafka\\SchemaRegistryClient\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Jobcloud\\Kafka\\SchemaRegistryClient\\Tests\\": "tests/"
}
},
"authors": [
{
"name": "Jobcloud AG",
"name": "JobCloud AG",
"homepage": "https://careers.jobcloud.ch/en/our-team/?term=133"
}
],
"require": {
"php": ">=7.4",
"php": "^7.4|^8.0",
"ext-json": "*",
"psr/http-message": "^1.0",
"psr/http-message": "^1.0.1",
"psr/http-client": "^1.0.1"
},
"require-dev": {
"infection/infection": "^0.25",
"kriswallsmith/buzz": "^1.0",
"nyholm/psr7": "^1.2",
"php-mock/php-mock-phpunit": "^2.6",
"phpstan/phpstan": "^1.2",
"phpunit/phpunit": "^9.5",
"pimple/pimple": "^3.2",
"infection/infection": "^0.26.6",
"kriswallsmith/buzz": "^1.2.1",
"nyholm/psr7": "^1.5.1",
"php-mock/php-mock-phpunit": "^2.6.0",
"phpstan/phpstan": "^1.7.15",
"phpunit/phpunit": "^9.5.21",
"pimple/pimple": "^3.5.0",
"rregeer/phpunit-coverage-check": "^0.3.1",
"squizlabs/php_codesniffer": "^3.4.2"
"squizlabs/php_codesniffer": "^3.7.1"
},
"config": {
"sort-packages": true,
"platform": {
"php": "7.4.7"
},
"allow-plugins": {
"infection/extension-installer": true
}
Expand Down
18 changes: 11 additions & 7 deletions docker/dev/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
FROM php:7.4-cli-alpine3.15
FROM php:8.1-cli-alpine3.16

ARG HOST_USER_ID
ARG USER_ID

COPY files/bin /usr/local/bin/
COPY files/php /phpIni

# SYS: Install required packages
RUN apk --no-cache upgrade && \
apk --no-cache add bash git sudo autoconf gcc g++ make make shadow

COPY dev/php/files/bin/ /usr/local/bin/

# Set host user id if given, to avoid permission conflicts in dev
RUN /bin/bash -c 'if [ -n "$HOST_USER_ID" ] && [ "$HOST_USER_ID" -lt 60000 ]; then \
usermod -u ${HOST_USER_ID} www-data; \
fi'
RUN if [ -n "$USER_ID" ] && [ "$USER_ID" -lt 60001 ]; then \
usermod -u ${USER_ID} -o www-data; \
fi

RUN usermod -s /bin/bash www-data && \
echo 'www-data ALL=(ALL) NOPASSWD: ALL' > '/etc/sudoers.d/www-data'

# USER: copy home
COPY --chown=www-data:www-data files/user-home /home/www-data

# PHP: Install php extensions
RUN pecl channel-update pecl.php.net && \
pecl install pcov && \
Expand Down
1 change: 1 addition & 0 deletions docker/dev/php/files/php/20-pcov.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=pcov.so
7 changes: 7 additions & 0 deletions docker/dev/php/files/user-home/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
alias cls='printf "\033c"'

export PS1='\[\e[1;32m\]\h\[\e[0m\] \[\e[1;37m\]\w\[\e[0m\] \[\e[1;32m\]\u\[\e[0m\] \[\e[1;37m\]\$\[\e[0m\] '

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
13 changes: 13 additions & 0 deletions docker/docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.2'

services:
php:
hostname: kafka-schema-registry-client-php
container_name: kafka-schema-registry-client-php
build:
context: dev/php
args:
USER_ID: ${USER_ID}
volumes:
- ../:/var/www/html
tty: true
13 changes: 13 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.2'

services:
php:
hostname: kafka-schema-registry-client-php
container_name: kafka-schema-registry-client-php
build:
context: dev/php
args:
USER_ID: ${USER_ID}
volumes:
- ../:/var/www/html
tty: true
17 changes: 0 additions & 17 deletions docker/docker-compose.yml

This file was deleted.

1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
<file>src</file>
<file>tests</file>
<rule ref="PSR12"/>
<arg name="report-gitblame"/>
<arg name="report-full"/>
Expand Down
4 changes: 0 additions & 4 deletions src/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
class ErrorHandler implements ErrorHandlerInterface
{
/**
* @param ResponseInterface $response
* @param string|null $uri
* @param RequestInterface|null $request
* @return void
* @throws BackendDatastoreException
* @throws ClientException
* @throws CompatibilityException
Expand Down
2 changes: 0 additions & 2 deletions src/ErrorHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
interface ErrorHandlerInterface
{
/**
* @param ResponseInterface $response
* @param string|null $uri
* @throws ClientExceptionInterface
* @throws SchemaRegistryExceptionInterface
* @throws JsonException
Expand Down
13 changes: 0 additions & 13 deletions src/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ class HttpClient implements HttpClientInterface
*/
private $errorHandler;

/**
* @param ClientInterface $client
* @param RequestFactoryInterface $requestFactory
* @param ErrorHandlerInterface $errorHandler
* @param string $baseUrl
* @param string|null $username
* @param string|null $password
*/
public function __construct(
ClientInterface $client,
RequestFactoryInterface $requestFactory,
Expand All @@ -66,11 +58,8 @@ public function __construct(
}

/**
* @param string $method
* @param string $uri
* @param array<string,mixed> $body
* @param array<string,mixed> $queryParams
* @return RequestInterface
* @throws JsonException
*/
private function createRequest(
Expand Down Expand Up @@ -108,8 +97,6 @@ private function createRequest(
}

/**
* @param string $method
* @param string $uri
* @param array<string,mixed> $body
* @param array<string,mixed> $queryParams
* @return mixed
Expand Down
2 changes: 0 additions & 2 deletions src/HttpClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
interface HttpClientInterface
{
/**
* @param string $method
* @param string $uri
* @param array<string,mixed> $body
* @param array<string,mixed> $queryParams
* @return mixed
Expand Down

0 comments on commit ea730bb

Please sign in to comment.