Skip to content

Development #2

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

Merged
merged 5 commits into from
Oct 11, 2020
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
6 changes: 5 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ jobs:
strategy:
matrix:
php: [7.4, 7.3, 7.2]
laravel: [7.*, 6.*, 5.8.*, 5.7.*, 5.6.*]
laravel: [8.*, 7.*, 6.*, 5.8.*, 5.7.*, 5.6.*]
os: [ubuntu-latest]
include:
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*
- laravel: 6.*
Expand All @@ -26,6 +28,8 @@ jobs:
- laravel: 5.6.*
testbench: 3.6.*
exclude:
- laravel: 8.*
php: 7.2
- laravel: 5.7.*
php: 7.4
- laravel: 5.6.*
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 2.0.0 - 2020-10-11

**Added**

- Support for Laravel 8

**Changed**

- Change authentication method from config value path to Application Default Standard

## 1.0.0 - 2020-06-20

**Added**
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Please check the table below for supported Laravel and PHP versions:
| 5.8 | 7.2 or 7.3 or 7.4
| 6.x | 7.2 or 7.3 or 7.4
| 7.x | 7.2 or 7.3 or 7.4
| 8.x | 7.3 or 7.4

# Installation

Expand All @@ -52,7 +53,6 @@ composer require stackkit/laravel-google-cloud-tasks-queue
```
'cloudtasks' => [
'driver' => 'cloudtasks',
'credentials' => base_path('gcloud-key.json'),
'project' => env('STACKKIT_CLOUD_TASKS_PROJECT', ''),
'location' => env('STACKKIT_CLOUD_TASKS_LOCATION', ''),
'handler' => env('STACKKIT_CLOUD_TASKS_HANDLER', ''),
Expand Down Expand Up @@ -85,6 +85,12 @@ Please check the table below on what the values mean and what their value should
|`STACKKIT_CLOUD_TASKS_QUEUE`|The queue a job will be added to|`emails`
|`STACKKIT_CLOUD_TASKS_SERVICE_EMAIL`|The email address of the AppEngine service account. Important, it should have the *Cloud Tasks Enqueuer* role. This is used for securing the handler.|`[email protected]`

# Authentication

Set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable with a path to the credentials file.

More info: https://cloud.google.com/docs/authentication/production

# Configuring the queue

When you first create a queue using `gcloud tasks queues create`, the default settings will look something like this:
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<env name="SESSION_DRIVER" value="array"/>
<env name="MAIL_DRIVER" value="log"/>
<env name="QUEUE_DRIVER" value="cloudtasks"/>
<env name="GOOGLE_APPLICATION_CREDENTIALS" value="./tests/Support/gcloud-key-valid.json" />
</php>

<filter>
Expand Down
4 changes: 1 addition & 3 deletions src/CloudTasksServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ public function boot(QueueManager $queue, Router $router)
private function registerClient()
{
$this->app->singleton(CloudTasksClient::class, function () {
return new CloudTasksClient([
'credentials' => Config::credentials(),
]);
return new CloudTasksClient();
});
}

Expand Down
8 changes: 0 additions & 8 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ public static function serviceAccountEmail()

public static function validate(array $config)
{
if (empty($config['credentials'])) {
throw new Error(Errors::invalidCredentials());
}

if (!file_exists($config['credentials'])) {
throw new Error(Errors::credentialsFileDoesNotExist());
}

if (empty($config['project'])) {
throw new Error(Errors::invalidProject());
}
Expand Down
22 changes: 0 additions & 22 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,6 @@

class ConfigTest extends TestCase
{
/** @test */
public function credentials_are_required()
{
$this->setConfigValue('credentials', '');

$this->expectException(Error::class);
$this->expectExceptionMessage(Errors::invalidCredentials());

SimpleJob::dispatch();
}

/** @test */
public function credentials_file_must_exist()
{
$this->setConfigValue('credentials', 'doesnotexist.json');

$this->expectException(Error::class);
$this->expectExceptionMessage(Errors::credentialsFileDoesNotExist());

SimpleJob::dispatch();
}

/** @test */
public function project_is_required()
{
Expand Down
4 changes: 1 addition & 3 deletions tests/TaskHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ protected function setUp(): void
$googlePublicKey->shouldReceive('getKidFromOpenIdToken')->andReturnNull();

$this->handler = new TaskHandler(
new CloudTasksClient([
'credentials' => __DIR__ . '/Support/gcloud-key-valid.json'
]),
new CloudTasksClient(),
request(),
$this->jwt,
$googlePublicKey
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ protected function getEnvironmentSetUp($app)
$app['config']->set('queue.default', 'cloudtasks');
$app['config']->set('queue.connections.cloudtasks', [
'driver' => 'cloudtasks',
'credentials' => __DIR__ . '/Support/gcloud-key-valid.json',
'queue' => 'test-queue',
'project' => 'test-project',
'location' => 'europe-west6',
Expand Down