Skip to content

Commit

Permalink
Update GH Action, fix CS, fix phpstan issues, fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrech committed Nov 21, 2024
1 parent 8c75136 commit 280262d
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 62 deletions.
85 changes: 44 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,59 @@
name: Continuous Integration

'on':
"on":
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]
schedule:
- cron: '0 0 * * MON'
- cron: "0 0 * * MON"

permissions:
contents: read
packages: read

env:
# Fix for symfony/color detection. We know GitHub Actions can handle it
ANSICON: 1
CASTOR_CONTEXT: ci

jobs:
check-dockerfiles:
name: Check Dockerfile
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check php/Dockerfile
uses: hadolint/[email protected]
with:
dockerfile: infrastructure/docker/services/php/Dockerfile

ci:
name: Continuous Integration
runs-on: ubuntu-latest
env:
BUILDKIT_PROGRESS: plain
DOCKER_BUILDKIT: 1
CI: 1
steps:
-
name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: 'ghcr.io'
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

-
uses: actions/checkout@v3

-
name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: jolicode/castor

-
name: 'Build and start the infrastructure'
run: castor start

-
name: 'Run PHP-CS-Fixer'
run: castor qa:cs --dry-run

-
name: 'Run PHPStan'
run: castor qa:phpstan

-
name: 'Run PHPUnit'
run: castor qa:phpunit
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: 'ghcr.io'
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v4

- name: setup-castor
uses: castor-php/[email protected]

- name: "Build and start the infrastructure"
run: "castor start"

- name: "Check PHP coding standards"
run: "castor qa:cs --dry-run"

- name: "Run PHPStan"
run: "castor qa:phpstan"

- name: "Run PHPUnit"
run: "castor qa:phpunit"
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@

# Infra stuff
/.castor.stub.php
/infrastructure/docker/.env
/infrastructure/docker/docker-compose.override.yml
/infrastructure/docker/services/router/certs/*
/infrastructure/docker/services/router/certs/*.pem
Empty file.
17 changes: 9 additions & 8 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@ parameters:
level: 8
paths:
- src
- public
- castor.php
- .castor/
scanFiles:
- .castor.stub.php
tmpDir: 'var/phpstan/tmp'
tmpDir: tools/phpstan/var
inferPrivatePropertyTypeFromConstructor: true
excludePaths:
analyse: []
ignoreErrors:
- '{Property .* type has no value type specified in iterable type array\.}'
- '{Method .* return type has no value type specified in iterable type array\.}'
- '{Method .* has parameter .* with no value type specified in iterable type array\.}'

symfony:
container_xml_path: 'var/cache/dev/App_KernelDevDebugContainer.xml'

typeAliases:
ContextData: '''
array{
project_name: int,
root_domain: int,
project_name: string,
root_domain: string,
extra_domains: string[],
php_version: string,
project_directory: string,
php_version: string,
docker_compose_files: string[],
project_directory: string,
macos: bool,
power_shell: bool,
user_id: int,
root_dir: string,
env: string,
composer_cache_dir: string,
}
'''
2 changes: 1 addition & 1 deletion src/ControlTower/DebtCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function createDebtIfNeeded(array $payload): ?Debt
{
$this->em->getConnection()->beginTransaction();
$tableName = $this->em->getClassMetadata(Event::class)->getTableName();
$this->em->getConnection()->exec("LOCK {$tableName} IN ACCESS EXCLUSIVE MODE");
$this->em->getConnection()->executeStatement("LOCK {$tableName} IN ACCESS EXCLUSIVE MODE");

$event = $this->insertEvent($payload);
$debt = $this->doCreateDebtIfNeeded($event);
Expand Down
6 changes: 3 additions & 3 deletions src/ControlTower/NewDebtNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ private function buildBlocks(Debt $debt): array
if ('message' === $event->getType()) {
$explanation = 'message posted';
} elseif ('reaction_added' === $event->getType()) {
$explanation = sprintf('reaction "%s" added', $event->getContent());
$explanation = \sprintf('reaction "%s" added', $event->getContent());
}

if ($explanation) {
$explanation = sprintf(' Reason: %s.', $explanation);
$explanation = \sprintf(' Reason: %s.', $explanation);
}

return [
Expand All @@ -39,7 +39,7 @@ private function buildBlocks(Debt $debt): array
'elements' => [
[
'type' => 'mrkdwn',
'text' => sprintf('Thanks <@%s> for the next breakfast!%s', $event->getAuthor(), $explanation),
'text' => \sprintf('Thanks <@%s> for the next breakfast!%s', $event->getAuthor(), $explanation),
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Type/DateTimeImmutableWithMillis.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): mixe
throw ConversionException::conversionFailedInvalidType($value, $this->getName(), ['null', \DateTime::class]);
}

public function convertToPHPValue($value, AbstractPlatform $platform): null|\DateTimeInterface|\DateTimeImmutable
public function convertToPHPValue($value, AbstractPlatform $platform): \DateTimeInterface|\DateTimeImmutable|null
{
if (null === $value || $value instanceof \DateTimeInterface) {
return $value;
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Amnesty.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function redeem(int $threshold): void
}

if (($c = \count($this->userIds)) < $threshold) {
throw new \DomainException(sprintf('More people need to ask for amnesty to complete it! (%d/%d)', $c, $threshold));
throw new \DomainException(\sprintf('More people need to ask for amnesty to complete it! (%d/%d)', $c, $threshold));
}

$this->redeemed = true;
Expand Down
4 changes: 2 additions & 2 deletions src/Slack/DebtAckPoster.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
class DebtAckPoster
{
public function __construct(
private readonly MessagePoster $messagePoster
private readonly MessagePoster $messagePoster,
) {
}

public function postDebtAck(Debt $debt, string $user): void
{
$message = sprintf("<@%s>'s debt was marked as paid by <@%s> !", $debt->getAuthor(), $user);
$message = \sprintf("<@%s>'s debt was marked as paid by <@%s> !", $debt->getAuthor(), $user);

$this->messagePoster->postMessage($message);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Slack/DebtListBlockBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function buildBlocks(string $usedId): array
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => sprintf('<@%s>, %s days ago.', $event->getAuthor(), (new \DateTime())->diff($event->getCreatedAt())->format('%a')),
'text' => \sprintf('<@%s>, %s days ago.', $event->getAuthor(), (new \DateTime())->diff($event->getCreatedAt())->format('%a')),
],
];

Expand Down
2 changes: 1 addition & 1 deletion src/Slack/DebtListPoster.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function __construct(
) {
}

public function postDebtList(string $userId, string $responseUrl = null): void
public function postDebtList(string $userId, ?string $responseUrl = null): void
{
$blocks = $this->blockBuilder->buildBlocks($userId);

Expand Down
2 changes: 1 addition & 1 deletion src/Slack/MessagePoster.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
) {
}

public function postMessage(string $text, array $blocks = [], string $responseUrl = null): void
public function postMessage(string $text, array $blocks = [], ?string $responseUrl = null): void
{
$headers = [
'headers' => [
Expand Down

0 comments on commit 280262d

Please sign in to comment.