Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests, move CI over to CircleCI & require PHP versions #29

Merged
merged 7 commits into from
Aug 13, 2021
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
75 changes: 75 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
version: 2

jobs:
php:
docker:
- image: becklyn/circleci-php7.4:latest

steps:
- checkout

# Download and cache dependencies
- restore_cache:
name: Restore Composer Main Cache
keys:
- composer-dependencies-v2-{{ checksum "composer.json" }}
# fallback to using the latest cache if no exact match is found
- composer-dependencies-v2-
-
- restore_cache:
name: Restore Composer Bin Cache
keys:
- composer-bin-dependencies-v2-{{ checksum "vendor-bin/test/composer.json" }}
# fallback to using the latest cache if no exact match is found
- composer-bin-dependencies-v2-

- run:
name: Composer Install
command: COMPOSER_MEMORY_LIMIT=-1 composer install --no-interaction --prefer-dist --no-progress --no-suggest
- run:
name: Install Composer Normalize + Bin Plugin
command: COMPOSER_MEMORY_LIMIT=-1 composer global require localheinz/composer-normalize bamarni/composer-bin-plugin --no-interaction --prefer-dist --no-progress --no-suggest
- run:
name: Composer Install (bin)
command: COMPOSER_MEMORY_LIMIT=-1 composer bin all install --no-interaction --prefer-dist --no-progress --no-suggest
- run:
name: Composer Log Directory for php-coveralls
command: mkdir -p build/logs


# RUN
- run:
name: Composer Normalize
command: COMPOSER_MEMORY_LIMIT=-1 composer normalize --indent-size 4 --indent-style space --dry-run
- run:
name: PHP CS Fixer
command: ./vendor/bin/php-cs-fixer fix --diff --config vendor-bin/test/vendor/becklyn/php-cs/.php_cs.dist.php --dry-run --no-interaction
- run:
name: PHPUnit
command: ./vendor/bin/simple-phpunit -c phpunit.xml --colors=always --testdox
# phpstan (needs to run after simple-phpunit, as it needs the installed phpunit)
- run:
name: PhpStan
command: ./vendor/bin/phpstan analyse --memory-limit 4G --ansi -c vendor-bin/test/vendor/becklyn/php-cs/phpstan/lib.neon src --no-interaction --no-progress
# php-coveralls (needs to run after simple-phpunit, as it needs the generated coverage-clover in build/logs/clover.xml)
# - run:
# name: php-coveralls
# command: ./vendor/bin/php-coveralls

# save cache at the end, to also store PHPUnit
- save_cache:
name: Save Composer Main Cache
paths:
- ./vendor
key: composer-dependencies-v2-{{ checksum "composer.json" }}
- save_cache:
name: Save Composer Bin Cache
paths:
- ./vendor-bin/test/vendor
key: composer-bin-dependencies-v2-{{ checksum "vendor-bin/test/composer.json" }}

workflows:
version: 2
all:
jobs:
- php
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
/vendor
/vendor-bin/test/composer.lock
/vendor-bin/test/vendor
/.php-cs-fixer.cache
/.phpunit.result.cache
/build/logs
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
3.2.0
=====

* (improvement) Bump minimum required version of PHP to 7.4 and add support for 8.0+.
* (improvement) Upgrade Sentry SDK to the newest version.
* (internal) Upgrade `becklyn/php-cs` to the newest versions.
* (internal) Move CI over to CircleCI.
* (internal) Add tests, courtesy of @apfelbox and @mangoischke.


3.1.4
=====

Expand Down
25 changes: 15 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
}
],
"require": {
"php": "^7.2",
"php": ">=7.4",
"ext-json": "*",
"becklyn/assets-bundle": "^2.3",
"sentry/sentry-symfony": "^3.4",
"symfony/cache-contracts": "^2.0",
"symfony/config": "^5.0",
"symfony/console": "^5.1",
"symfony/dependency-injection": "^5.0",
"symfony/http-kernel": "^5.0"
"becklyn/assets-bundle": "^2.6.9",
"sentry/sentry-symfony": "^4.2.0",
"symfony/cache-contracts": "^2.4.0",
"symfony/config": "^5.3.4",
"symfony/console": "^5.3.6",
"symfony/dependency-injection": "^5.3.4",
"symfony/http-kernel": "^5.3.6"
},
"require-dev": {
"symfony/phpunit-bridge": "^5.0",
"twig/twig": "^2.0 || ^3.0"
"symfony/phpunit-bridge": "^5.3.4",
"twig/twig": "^2.0 || ^3.3.2"
},
"config": {
"sort-packages": true
Expand All @@ -45,5 +45,10 @@
"psr-4": {
"Becklyn\\Hosting\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\Becklyn\\Hosting\\": "tests/"
}
}
}
4 changes: 4 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0"/>
</php>

<logging>
<log type="coverage-php" target="build/logs/coverage.cov"/>
</logging>

<testsuites>
<testsuite name="Bundle tests">
<directory>tests</directory>
Expand Down
10 changes: 2 additions & 8 deletions src/BecklynHostingBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@

class BecklynHostingBundle extends Bundle
{
/**
* @var ConfigureSentryPass
*/
private $releaseVersionPass;
private ConfigureSentryPass $releaseVersionPass;


/**
*
*/
public function __construct ()
{
$this->releaseVersionPass = new ConfigureSentryPass();
Expand Down Expand Up @@ -52,7 +46,7 @@ public function getContainerExtension ()
/**
* @inheritDoc
*/
public function getPath ()
public function getPath () : string
{
return \dirname(__DIR__);
}
Expand Down
25 changes: 3 additions & 22 deletions src/Config/HostingConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@ class HostingConfig
"production",
];

/** @var array */
private $config;
private array $config;
private ProjectVersion $projectVersion;
private string $tier;

/** @var ProjectVersion */
private $projectVersion;

/** @var string */
private $tier;


/**
*/
public function __construct (array $config, ProjectVersion $projectVersion)
{
$tier = $config["tier"];
Expand All @@ -46,24 +39,18 @@ public function __construct (array $config, ProjectVersion $projectVersion)
}


/**
*/
public function getDeploymentTier () : string
{
return $this->tier;
}


/**
*/
public function isInDevelopmentTier () : bool
{
return "development" === $this->tier;
}


/**
*/
public function getGitCommit () : ?string
{
return $this->projectVersion->getVersion();
Expand All @@ -81,8 +68,6 @@ public function getTrackJsToken () : ?string
}


/**
*/
public function getUptimeMonitorHtmlString () : string
{
return \sprintf(
Expand All @@ -92,16 +77,12 @@ public function getUptimeMonitorHtmlString () : string
}


/**
*/
public function getProjectName () : string
{
return $this->config["project"];
}


/**
*/
public function getProjectInstallationKey () : string
{
return $this->config["installation"];
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/BecklynHostingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

class BecklynHostingExtension extends Extension implements PrependExtensionInterface
{
/** @var ConfigureSentryPass */
private $configureSentryPass;
private ConfigureSentryPass $configureSentryPass;


public function __construct (ConfigureSentryPass $releaseVersionPass)
{
$this->configureSentryPass = $releaseVersionPass;
}


/**
* @inheritdoc
*/
Expand Down
11 changes: 3 additions & 8 deletions src/DependencyInjection/CompilerPass/ConfigureSentryPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@

class ConfigureSentryPass implements CompilerPassInterface
{
/** @var string */
private $projectInstallationKey;
private ?string $projectInstallationKey = null;
private ?string $tier = null;

/** @var string */
private $tier;


/**
*/
public function setConfig (string $projectInstallationKey, string $tier) : void
{
$this->projectInstallationKey = $projectInstallationKey;
Expand All @@ -30,7 +25,7 @@ public function setConfig (string $projectInstallationKey, string $tier) : void
*/
public function process (ContainerBuilder $container) : void
{
$git = new GitIntegration($container->getParameter('kernel.project_dir'));
$git = new GitIntegration($container->getParameter("kernel.project_dir"));
$version = $git->fetchHeadCommitHash() ?? "?";

$container->getDefinition(Options::class)
Expand Down
13 changes: 5 additions & 8 deletions src/Listener/SentryRequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

final class SentryRequestListener
{
/**
* @var RequestListener
*/
private $inner;
private RequestListener $inner;


public function __construct (RequestListener $inner)
Expand All @@ -21,18 +18,18 @@ public function __construct (RequestListener $inner)


/**
* We do not want to log any user details. Therefore this method is empty.
* We do not want to log any user details. Therefore, this method is empty.
*/
public function onKernelRequest (RequestListenerRequestEvent $event) : void
public function handleKernelRequestEvent (RequestListenerRequestEvent $event) : void
{

}


/**
*/
public function onKernelController (RequestListenerControllerEvent $event) : void
public function handleKernelControllerEvent (RequestListenerControllerEvent $event) : void
{
$this->inner->onKernelController($event);
$this->inner->handleKernelControllerEvent($event);
}
}
2 changes: 1 addition & 1 deletion src/Project/ProjectVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class ProjectVersion
{
const CACHE_KEY = "becklyn.hosting.version";
public const CACHE_KEY = "becklyn.hosting.version";

/** @var string|null */
private $version;
Expand Down
Loading