Skip to content

Commit

Permalink
Fix CI (#206)
Browse files Browse the repository at this point in the history
* Change pip to pip3 to install pipenv

* Specify pythin version on pipenv install

* Specify python version on ci install

* Add pipenv install command in CI

* Try add --three to pipenv install command

* Remove pipenv cache from CI

* De-comment pywin32

* Comment pypiwin32

* Fix phpstan.neon calling old version

* Replace deprecated service 'session' with RequestStack

* Pass requeststack in construct

* Remove trait construct and make request stack public for tests

* Try using MockFile for test session

* Fix typo

* Add typehint

* push to force ci execution

* Ignore phpstan error

* Update .gitignore

* Apply cs-fixer

* Apply reviewer suggestion
  • Loading branch information
Nispeon authored Sep 7, 2021
1 parent 81d6a07 commit 96e8f10
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 60 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@ jobs:
path: ~/.composer/cache/
key: composer-${{ hashFiles('composer.lock') }}
restore-keys: composer-
- name: Cache Pipenv
uses: actions/cache@v2
with:
path: |
~/.cache/pip
~/.cache/pipenv
~/.local/share/virtualenvs/
key: pip-pipenv-${{ hashFiles('Pipfile.lock') }}
restore-keys: pip-pipenv-

- name: Cache PHPStan
uses: actions/cache@v2
with:
Expand All @@ -52,7 +44,7 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- run: pip install pipenv
- run: pip3 install pipenv

# Install the stack and run the tests
- run: pipenv install --deploy --dev
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
/vendor/
###< symfony/framework-bundle ###
###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.php
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###

Expand Down
46 changes: 46 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

$header = <<<'EOF'
This file is part of the Secret Santa project.
(c) JoliCode <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(array(
'@Symfony' => true,
'@Symfony:risky' => true,
'header_comment' => array('header' => $header),
'array_syntax' => array('syntax' => 'short'),
'ordered_class_elements' => true,
'ordered_imports' => true,
'heredoc_to_nowdoc' => true,
'php_unit_strict' => true,
'php_unit_construct' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'strict_comparison' => true,
'strict_param' => true,
'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'),
'no_short_echo_tag' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'semicolon_after_instruction' => true,
'combine_consecutive_unsets' => true,
'concat_space' => array('spacing' => 'one'),
))
->setFinder(
PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__ . '/config')
->in(__DIR__ . '/public')
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
)
->setCacheFile('.php-cs-fixer.cache') // forward compatibility with 3.x line
;
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ docker = "*"
invoke = ">=1.4"
# https://github.com/docker/compose/issues/6839
colorama = {version = ">=0.4, <1"}
pypiwin32 = {version = "*", sys_platform = "== 'win32'"}
#pypiwin32 = {version = "*", sys_platform = "== 'win32'"}
#pywin32 = {version = "*", sys_platform = "== 'win32'"}

[requires]
Expand Down
26 changes: 1 addition & 25 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ parameters:

# Make tests analyses working with Symfony's PHPUnit bridge
bootstrapFiles:
- vendor/bin/.phpunit/phpunit-7.5-0/vendor/autoload.php
- vendor/bin/.phpunit/phpunit-9.5-0/vendor/autoload.php

ignoreErrors: []
ignoreErrors:
-
message: '#Service "session" is not registered in the container.#'
path: tests/Controller/SessionPrepareTrait.php
10 changes: 5 additions & 5 deletions src/Controller/ContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,31 @@ public function __construct(Environment $twig, StatisticCollector $statisticColl
$this->statisticCollector = $statisticCollector;
}

#[Route('/', name:'homepage', methods:['GET'])]
#[Route('/', name: 'homepage', methods: ['GET'])]
public function homepage(): Response
{
$content = $this->twig->render('content/homepage.html.twig');

return new Response($content);
}

#[Route('/terms-of-service', name:'terms', methods:['GET'])]
#[Route('/terms-of-service', name: 'terms', methods: ['GET'])]
public function terms(): Response
{
$content = $this->twig->render('content/terms.html.twig');

return new Response($content);
}

#[Route('/privacy-policy', name:'privacy_policy', methods:['GET'])]
#[Route('/privacy-policy', name: 'privacy_policy', methods: ['GET'])]
public function privacyPolicy(): Response
{
$content = $this->twig->render('content/privacy_policy.html.twig');

return new Response($content);
}

#[Route('/hall-of-fame', name:'hall_of_fame', methods:['GET'])]
#[Route('/hall-of-fame', name: 'hall_of_fame', methods: ['GET'])]
public function hallOfFame(): Response
{
$companies = [
Expand Down Expand Up @@ -227,7 +227,7 @@ public function hallOfFame(): Response
return new Response($content);
}

#[Route('/stats', name:'stats', methods:['GET'])]
#[Route('/stats', name: 'stats', methods: ['GET'])]
public function stats(): Response
{
$content = $this->twig->render('content/stats.html.twig', [
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/DiscordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(string $discordClientId, string $discordClientSecret
/**
* Ask for Discord authentication and store the AccessToken in Session.
*/
#[Route('/auth/discord', name:'discord_authenticate', methods:['GET'])]
#[Route('/auth/discord', name: 'discord_authenticate', methods: ['GET'])]
public function authenticate(Request $request, DiscordApplication $discordApplication): Response
{
$session = $request->getSession();
Expand Down
16 changes: 8 additions & 8 deletions src/Controller/SantaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(RouterInterface $router, Environment $twig, LoggerIn
$this->bugsnag = $bugsnag;
}

#[Route('/run/{application}', name:'run', methods:['GET', 'POST'])]
#[Route('/run/{application}', name: 'run', methods: ['GET', 'POST'])]
public function run(Request $request, string $application): Response
{
$application = $this->getApplication($application);
Expand All @@ -69,7 +69,7 @@ public function run(Request $request, string $application): Response
return $this->redirectToRoute('participants', ['application' => $application->getCode()]);
}

#[Route('/participants/{application}', name:'participants', methods:['GET', 'POST'])]
#[Route('/participants/{application}', name: 'participants', methods: ['GET', 'POST'])]
public function participants(Request $request, string $application): Response
{
$application = $this->getApplication($application);
Expand Down Expand Up @@ -113,7 +113,7 @@ public function participants(Request $request, string $application): Response
return new Response($content);
}

#[Route('/message/{application}', name:'message', methods:['GET', 'POST'])]
#[Route('/message/{application}', name: 'message', methods: ['GET', 'POST'])]
public function message(Rudolph $rudolph, Request $request, string $application): Response
{
$application = $this->getApplication($application);
Expand Down Expand Up @@ -171,7 +171,7 @@ public function message(Rudolph $rudolph, Request $request, string $application)
return new Response($content);
}

#[Route('/sample-message/{application}', name:'send_sample_message', methods:['GET', 'POST'])]
#[Route('/sample-message/{application}', name: 'send_sample_message', methods: ['GET', 'POST'])]
public function sendSampleMessage(Request $request, string $application): Response
{
$application = $this->getApplication($application);
Expand Down Expand Up @@ -238,7 +238,7 @@ public function sendSampleMessage(Request $request, string $application): Respon
]);
}

#[Route('/send-messages/{hash}', name:'send_messages', methods:['GET', 'POST'])]
#[Route('/send-messages/{hash}', name: 'send_messages', methods: ['GET', 'POST'])]
public function sendMessages(MessageDispatcher $messageDispatcher, Request $request, string $hash): Response
{
$secretSanta = $this->getSecretSantaOrThrow404($request, $hash);
Expand Down Expand Up @@ -299,7 +299,7 @@ public function sendMessages(MessageDispatcher $messageDispatcher, Request $requ
]);
}

#[Route('/finish/{hash}', name:'finish', methods:['GET'])]
#[Route('/finish/{hash}', name: 'finish', methods: ['GET'])]
public function finish(Request $request, string $hash): Response
{
$secretSanta = $this->getSecretSantaOrThrow404($request, $hash);
Expand All @@ -311,7 +311,7 @@ public function finish(Request $request, string $hash): Response
return new Response($content);
}

#[Route('/cancel/{application}', name:'cancel', methods:['GET'])]
#[Route('/cancel/{application}', name: 'cancel', methods: ['GET'])]
public function cancel(Request $request, string $application): Response
{
$application = $this->getApplication($application);
Expand All @@ -325,7 +325,7 @@ public function cancel(Request $request, string $application): Response
return $this->redirectToRoute('homepage');
}

#[Route('/spoil', name:'spoil', methods:['GET', 'POST'])]
#[Route('/spoil', name: 'spoil', methods: ['GET', 'POST'])]
public function spoil(Request $request, Spoiler $spoiler): Response
{
$code = $request->request->get('code');
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SlackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(string $slackClientId, string $slackClientSecret, Ro
/**
* Ask for Slack authentication and store the AccessToken in Session.
*/
#[Route('/auth/slack', name:'slack_authenticate', methods:['GET'])]
#[Route('/auth/slack', name: 'slack_authenticate', methods: ['GET'])]
public function authenticate(Request $request, SlackApplication $slackApplication, UserExtractor $userExtractor): Response
{
$session = $request->getSession();
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/ZoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function __construct(string $zoomClientId, string $zoomClientSecret, Rout
$this->zoomClientSecret = $zoomClientSecret;
}

#[Route('/intro/zoom', name:'zoom_pre_auth_warning', methods:['GET'])]
public function preAuthWarning()
#[Route('/intro/zoom', name: 'zoom_pre_auth_warning', methods: ['GET'])]
public function preAuthWarning(): Response
{
return $this->render('santa/pre_auth_warning.html.twig', [
'title' => 'Zoom Secret Santa warning',
Expand All @@ -48,7 +48,7 @@ public function preAuthWarning()
/**
* Ask for Zoom authentication and store the AccessToken in Session.
*/
#[Route('/auth/zoom', name:'zoom_authenticate', methods:['GET'])]
#[Route('/auth/zoom', name: 'zoom_authenticate', methods: ['GET'])]
public function authenticate(Request $request, ZoomApplication $zoomApplication): Response
{
if ($request->query->has('error')) {
Expand Down
6 changes: 3 additions & 3 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ protected function configureContainer(ContainerConfigurator $container): void

protected function configureRoutes(RoutingConfigurator $routes): void
{
$routes->import('../config/{routes}/'.$this->environment.'/*.yaml');
$routes->import('../config/{routes}/' . $this->environment . '/*.yaml');
$routes->import('../config/{routes}/*.yaml');

if (is_file(\dirname(__DIR__).'/config/routes.yaml')) {
if (is_file(\dirname(__DIR__) . '/config/routes.yaml')) {
$routes->import('../config/routes.yaml');
} elseif (is_file($path = \dirname(__DIR__).'/config/routes.php')) {
} elseif (is_file($path = \dirname(__DIR__) . '/config/routes.php')) {
(require $path)($routes->withPath($path), $this);
}
}
Expand Down

0 comments on commit 96e8f10

Please sign in to comment.