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

Update github actions #195

Merged
merged 6 commits into from
Apr 18, 2024
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
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ jobs:
strategy:
matrix:
container: [
"kirschbaumdevelopment/laravel-test-runner:7.3",
"kirschbaumdevelopment/laravel-test-runner:7.4",
"kirschbaumdevelopment/laravel-test-runner:8.0"
"kirschbaumdevelopment/laravel-test-runner:8.2",
"kirschbaumdevelopment/laravel-test-runner:8.3"
]

container:
Expand Down Expand Up @@ -39,7 +38,7 @@ jobs:
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install composer dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Run Testsuite against MySQL
Expand All @@ -53,4 +52,4 @@ jobs:
env:
DB_CONNECTION: pgsql
DB_HOST: postgres
DB_PORT: 5432
DB_PORT: 5432
21 changes: 15 additions & 6 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
name: Format [PHP]

on: [push]
on:
pull_request:
paths:
- '**.php'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Run php-cs-fixer
uses: docker://oskarstark/php-cs-fixer-ga
uses: docker://oskarstark/php-cs-fixer-ga:3.13.0
with:
args: --config=.php-cs-fixer.php
args: --config=.php-cs-fixer.dist.php

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply php-cs-fixer changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 changes: 55 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->exclude('node_modules')
->exclude('bower_components')
->exclude('public')
->exclude('bootstrap')
->exclude('resources')
->exclude('storage')
->in(__DIR__)
->name('*.php')
->notName('*.blade.php');

$config = new PhpCsFixer\Config();

return $config
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const'
],
'sort_algorithm' => 'alpha'
],
'no_unused_imports' => true,
'no_empty_statement' => true,
'no_useless_return' => true,
'not_operator_with_successor_space' => true,
'explicit_string_variable' => true,
'simple_to_complex_string_variable' => true,
'array_indentation' => true,
'blank_line_before_statement' => [
'statements' => [
'case',
'default',
'declare',
'do',
'goto',
'if',
'include',
'include_once',
'require',
'require_once',
'switch',
'try',
]
],
])
->setFinder($finder);
20 changes: 0 additions & 20 deletions .php-cs-fixer.php

This file was deleted.

2 changes: 1 addition & 1 deletion database/factories/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TemplateFactory extends Factory
{
/** @var string */
protected $model = Template::class;

public function definition(): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public function up()

DB::table('sendportal_campaign_statuses')
->insert([
['name' => 'Draft'],
['name' => 'Queued'],
['name' => 'Sending'],
['name' => 'Sent'],
['name' => 'Draft'],
['name' => 'Queued'],
['name' => 'Sending'],
['name' => 'Sent'],
]);
}
}
2 changes: 1 addition & 1 deletion database/migrations/2020_10_16_092234_prefix_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function up()
continue;
}

if (!Schema::hasTable("{$table}")) {
if (! Schema::hasTable("{$table}")) {
continue;
}

Expand Down
13 changes: 5 additions & 8 deletions src/Adapters/PostalAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,38 @@

use DomainException;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Postal\Client;
use Postal\SendMessage;
use Sendportal\Base\Services\Messages\MessageTrackingOptions;
use Symfony\Component\HttpFoundation\Response;

class PostalAdapter extends BaseMailAdapter
{

/**
* @throws TypeException
* @throws \Throwable
*/
public function send(string $fromEmail, string $fromName, string $toEmail, string $subject, MessageTrackingOptions $trackingOptions, string $content): string
{
$client = new Client('https://' . Arr::get($this->config, 'postal_host'), Arr::get($this->config, 'key'));

$message = new SendMessage($client);
$message->to($toEmail);
$message->from($fromName.' <'.$fromEmail.'>');
$message->subject($subject);
$message->htmlBody($content);
$response = $message->send();

return $this->resolveMessageId($response);
}



protected function resolveMessageId($response): string
{
foreach ($response->recipients() as $email => $message) {
return (string) $message->id();
return (string) $message->id();
}

throw new DomainException('Unable to resolve message ID');
}
}
2 changes: 1 addition & 1 deletion src/Adapters/SendgridMailAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function send(string $fromEmail, string $fromName, string $toEmail, strin
$response = $this->resolveClient()->send($email);

throw_if(
!in_array($response->statusCode(), [Response::HTTP_OK, Response::HTTP_ACCEPTED]),
! in_array($response->statusCode(), [Response::HTTP_OK, Response::HTTP_ACCEPTED]),
new DomainException($response->body(), $response->statusCode())
);

Expand Down
2 changes: 1 addition & 1 deletion src/Adapters/SmtpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function resolveTransport(): EsmtpTransport

$encryption = Arr::get($this->config, 'encryption');

$scheme = !is_null($encryption) && $encryption === 'tls'
$scheme = ! is_null($encryption) && $encryption === 'tls'
? ((Arr::get($this->config, 'port') == 465) ? 'smtps' : 'smtp')
: '';

Expand Down
4 changes: 3 additions & 1 deletion src/Events/MessageDispatchEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

class MessageDispatchEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

/**
* @var Message
Expand Down
4 changes: 3 additions & 1 deletion src/Events/SubscriberAddedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

class SubscriberAddedEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

/** @var Subscriber */
public $subscriber;
Expand Down
4 changes: 3 additions & 1 deletion src/Events/Webhooks/MailgunWebhookReceived.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

class MailgunWebhookReceived
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

/** @var array */
public $payload;
Expand Down
1 change: 0 additions & 1 deletion src/Facades/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class Helper extends Facade
{

/**
* @return string
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Factories/MailAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
use InvalidArgumentException;
use Sendportal\Base\Adapters\MailgunMailAdapter;
use Sendportal\Base\Adapters\MailjetAdapter;
use Sendportal\Base\Adapters\PostalAdapter;
use Sendportal\Base\Adapters\PostmarkMailAdapter;
use Sendportal\Base\Adapters\SendgridMailAdapter;
use Sendportal\Base\Adapters\SesMailAdapter;
use Sendportal\Base\Adapters\SmtpAdapter;
use Sendportal\Base\Adapters\PostalAdapter;
use Sendportal\Base\Interfaces\MailAdapterInterface;
use Sendportal\Base\Models\EmailService;
use Sendportal\Base\Models\EmailServiceType;
Expand Down Expand Up @@ -57,13 +57,13 @@ private function cache(MailAdapterInterface $adapter, EmailService $emailService
*/
private function resolve(EmailService $emailService): MailAdapterInterface
{
if (!$emailServiceType = EmailServiceType::resolve($emailService->type_id)) {
throw new InvalidArgumentException("Unable to resolve mail provider type from ID [$emailService->type_id].");
if (! $emailServiceType = EmailServiceType::resolve($emailService->type_id)) {
throw new InvalidArgumentException("Unable to resolve mail provider type from ID [{$emailService->type_id}].");
}

$adapterClass = self::$adapterMap[$emailService->type_id] ?? null;

if (!$adapterClass) {
if (! $adapterClass) {
throw new InvalidArgumentException("Mail adapter type [{$emailServiceType}] is not supported.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Sendportal\Base\Http\Controllers\Api\Webhooks;

use Illuminate\Support\Arr;

use Illuminate\Http\Response;
use Illuminate\Support\Facades\Log;
use Sendportal\Base\Events\Webhooks\PostalWebhookReceived;
Expand All @@ -20,7 +18,7 @@ public function handle(): Response
Log::info('Postal webhook received');

event(new PostalWebhookReceived($payload));


return response('OK');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function handle(): Response

$payloadType = $payload['Type'] ?? null;

if (!in_array($payloadType, ['SubscriptionConfirmation', 'Notification'], true)) {
if (! in_array($payloadType, ['SubscriptionConfirmation', 'Notification'], true)) {
return response('OK (not processed).');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

class RegisterController extends Controller
{
use RegistersUsers,
ChecksInvitations;
use RegistersUsers;
use ChecksInvitations;

/** @var AcceptInvitation */
private $acceptInvitation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public function cancel(int $campaignId)
$campaign = $this->campaignRepository->find(Sendportal::currentWorkspaceId(), $campaignId, ['status']);
$originalStatus = $campaign->status;

if (!$campaign->canBeCancelled()) {
if (! $campaign->canBeCancelled()) {
throw ValidationException::withMessages([
'campaignStatus' => "{$campaign->status->name} campaigns cannot be cancelled.",
])->redirectTo(route('sendportal.campaigns.index'));
}

if ($campaign->save_as_draft && !$campaign->allDraftsCreated()) {
if ($campaign->save_as_draft && ! $campaign->allDraftsCreated()) {
throw ValidationException::withMessages([
'messagesPendingDraft' => __('Campaigns that save draft messages cannot be cancelled until all drafts have been created.'),
])->redirectTo(route('sendportal.campaigns.index'));
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Campaigns/CampaignDeleteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function confirm(int $id)
{
$campaign = $this->campaigns->find(Sendportal::currentWorkspaceId(), $id);

if (!$campaign->draft) {
if (! $campaign->draft) {
return redirect()->route('sendportal.campaigns.index')
->withErrors(__('Unable to delete a campaign that is not in draft status'));
}
Expand All @@ -49,7 +49,7 @@ public function destroy(Request $request): RedirectResponse
{
$campaign = $this->campaigns->find(Sendportal::currentWorkspaceId(), $request->get('id'));

if (!$campaign->draft) {
if (! $campaign->draft) {
return redirect()->route('sendportal.campaigns.index')
->withErrors(__('Unable to delete a campaign that is not in draft status'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function send(CampaignDispatchRequest $request, int $id): RedirectRespons
return redirect()->route('sendportal.campaigns.status', $id);
}

if (!$campaign->email_service_id) {
if (! $campaign->email_service_id) {
return redirect()->route('sendportal.campaigns.edit', $id)
->withErrors(__('Please select an Email Service'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/Campaigns/CampaignTestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function handle(CampaignTestRequest $request, int $campaignId): RedirectR
{
$messageId = $this->dispatchTestMessage->handle(Sendportal::currentWorkspaceId(), $campaignId, $request->get('recipient_email'));

if (!$messageId) {
if (! $messageId) {
return redirect()->route('sendportal.campaigns.preview', $campaignId)
->withInput()
->with(['error', __('Failed to dispatch test email.')]);
Expand Down
Loading
Loading