Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ralflang committed Nov 25, 2021
1 parent b197357 commit 194678e
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 28 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ on:
push:
branches:
- master
- maintaina-composerfixed
- main
- FRAMEWORK_6_0
pull_request:
branches:
- master
- maintaina-composerfixed
- main
- FRAMEWORK_6_0


Expand All @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
operating-system: ['ubuntu-20.04']
php-versions: ['7.4', '8.0']
php-versions: ['7.4', '8.0', 'latest']
phpunit-versions: ['latest', '9.5']
steps:
- name: Setup github ssh key
Expand All @@ -39,18 +39,20 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter
extensions: bcmath, ctype, curl, dom, gd, fileinfo, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter
ini-values: post_max_size=512M, max_execution_time=360
coverage: xdebug
tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}, composer:v2
tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}, composer:v2, phpstan
- name: Setup Github Token as composer credential
run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
- name: Install horde/test dependency and other dependencies
run: |
## For unclear reasons, github action fails randomly if we do not install before we require.
COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer config minimum-stability dev
COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install
- name: Redo install due to many fails
run: |
COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: run phpunit
run: phpunit --bootstrap test/bootstrap.php
- name: run phpstan
run: phpstan analyze src/ --level 8
4 changes: 3 additions & 1 deletion .github/workflows/phpdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches:
- master
- maintaina-composerfixed
- FRAMEWORK_6_0
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down Expand Up @@ -58,7 +60,7 @@ jobs:
echo "Creating UUT related dir in docu repo"
mkdir -p $UUT_DIR/phpdoc-git/${GITHUB_REF##*/}/${REPO}/
## TODO: check for and include lib, src, app (if they exist) but not test or script dirs
$BIN_DIR/phpdocumentor -d $UUT_DIR/src/ -t "${UUT_DIR}/phpdoc-git/${GITHUB_REF##*/}/${REPO}/"
$BIN_DIR/phpdocumentor -d $UUT_DIR/lib/ -d $UUT_DIR/src/ -d $UUT_DIR/app/ -t "${UUT_DIR}/phpdoc-git/${GITHUB_REF##*/}/${REPO}/"
cd ${UUT_DIR}/phpdoc-git
git add "${GITHUB_REF##*/}/${REPO}"
php indexer.php ${GITHUB_REF##*/} $REPO
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/update-satis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@ jobs:
export WORK_DIR=/home/runner/
export BIN_DIR="${WORK_DIR}/bin"
composer create-project composer/satis:dev-main
php satis/bin/satis build -vvv maintaina-com.github.io/satis.json maintaina-com.github.io/ horde/http_server
php satis/bin/satis build -vvv maintaina-com.github.io/satis.json maintaina-com.github.io/ horde/${REPO,,}
cd maintaina-com.github.io
git add include/ index.html p2/ packages.json
git commit -m "Update for horde/http_server"
git commit -m "Update for horde/${REPO,,}"
git push
2 changes: 1 addition & 1 deletion src/Middleware/Gzip.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
* multi-byte chars as single bytes so we need to treat the string like its
* 8-bit encoded to get an accurate byte count.
*/
protected function _byteCount($string)
protected function _byteCount(string $string): int
{
if (ini_get('mbstring.func_overload') > 0) {
return mb_strlen($string, '8bit');
Expand Down
16 changes: 12 additions & 4 deletions src/RampageRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
Expand Down Expand Up @@ -42,6 +42,14 @@ class RampageRequestHandler implements RequestHandlerInterface

private ?RequestHandlerInterface $payloadHandler;

/**
* Constructor
*
* @param ResponseFactoryInterface $responseFactory
* @param StreamFactoryInterface $streamFactory
* @param MiddlewareInterface[] $middlewares
* @param RequestHandlerInterface|null $payloadHandler
*/
public function __construct(
ResponseFactoryInterface $responseFactory,
StreamFactoryInterface $streamFactory,
Expand All @@ -60,15 +68,15 @@ public function __construct(
/**
* Add another middleware to the queue just before the payload handler
*/
public function addMiddleware(MiddlewareInterface $middleware)
public function addMiddleware(MiddlewareInterface $middleware): void
{
$this->middlewares[] = $middleware;
}

/**
* Configure the payload handler
*/
public function setPayloadHandler(RequestHandlerInterface $handler)
public function setPayloadHandler(RequestHandlerInterface $handler): void
{
$this->payloadHandler = $handler;
}
Expand All @@ -89,7 +97,7 @@ public function nextMiddleware(): ?MiddlewareInterface
*
* Finally the we will return a response ourselves.
*/
public function handle(RequestInterface $request): ResponseInterface
public function handle(ServerRequestInterface $request): ResponseInterface
{
$middleware = $this->nextMiddleware();
if ($middleware) {
Expand Down
9 changes: 9 additions & 0 deletions src/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function withGlobalVariables(): self
} else {
$scheme = 'https';
}
} else {
// Default to https
$scheme = 'https';
}
$host = $_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'];
$queryString = $_SERVER['QUERY_STRING'] ?? '';
Expand Down Expand Up @@ -75,6 +78,12 @@ public function withGlobalVariables(): self
return $this;
}

/**
* Add headers from list
*
* @param mixed[] $headers
* @return self
*/
public function withHeaders(array $headers): self
{
foreach ($headers as $header => $value) {
Expand Down
2 changes: 1 addition & 1 deletion src/ResponseWriterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ interface ResponseWriterInterface
/**
* Output the HTTP Response to STDOUT
*/
public function writeResponse(ResponseInterface $response);
public function writeResponse(ResponseInterface $response): void;
}
10 changes: 4 additions & 6 deletions src/ResponseWriterWeb.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
class ResponseWriterWeb implements ResponseWriterInterface
{
public function writeResponse(ResponseInterface $response)
public function writeResponse(ResponseInterface $response): void
{
header(
sprintf(
Expand All @@ -39,10 +39,8 @@ public function writeResponse(ResponseInterface $response)
header($key . ': ' . $response->getHeaderLine($key));
}
$body = $response->getBody();
if (is_resource($body)) {
stream_copy_to_stream($body, fopen('php://output', 'a'));
} else {
echo $body;
}
// For now, disable outputting the stream via stream copying
// We would need to implement a stream wrapper first
echo $body;
}
}
2 changes: 1 addition & 1 deletion src/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(RequestHandlerInterface $handler, ResponseWriterInte
$this->responseWriter = $responseWriter;
}

public function run(ServerRequestInterface $request)
public function run(ServerRequestInterface $request): void
{
$response = $this->handler->handle($request);
$this->responseWriter->writeResponse($response);
Expand Down

0 comments on commit 194678e

Please sign in to comment.