Skip to content

Commit 6288c57

Browse files
committed
Initial commit
0 parents  commit 6288c57

15 files changed

+256
-0
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Issue template
3+
about: Help you create an effective issue and know what to expect.
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Thank you for taking the time for reporting a bug, requesting a feature, or letting me know something else about the package.
11+
12+
I create open-source packages for fun while working full-time and running my own business. That means I don't have as much time left to maintain these packages, build elaborate new features or investigate and fix bugs. If you wish to get a feature or bugfix merged it would be greatly appreciated if you can provide as much info as possible and preferably a Pull Request ready with automated tests. Realistically I check Github a few times a week, and take several days, weeks or sometimes months before finishing features/bugfixes (depending on their size of course).
13+
14+
Thanks for understanding. 😁

.github/workflows/run-tests.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Run tests
2+
3+
on:
4+
pull_request:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
php-tests:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
db: ['mysql', 'pgsql']
15+
payload:
16+
- { queue: 'github-actions-laravel9-php81', laravel: '9.*', php: '8.1', 'testbench': '7.*'}
17+
- { queue: 'github-actions-laravel9-php80', laravel: '9.*', php: '8.0', 'testbench': '7.*'}
18+
- { queue: 'github-actions-laravel8-php81', laravel: '8.*', php: '8.1', 'testbench': '6.*'}
19+
- { queue: 'github-actions-laravel8-php80', laravel: '8.*', php: '8.0', 'testbench': '6.*'}
20+
- { queue: 'github-actions-laravel8-php74', laravel: '8.*', php: '7.4', 'testbench': '6.*'}
21+
- { queue: 'github-actions-laravel7-php80', laravel: '7.*', php: '8.0', 'testbench': '5.*' }
22+
- { queue: 'github-actions-laravel7-php74', laravel: '7.*', php: '7.4', 'testbench': '5.*' }
23+
- { queue: 'github-actions-laravel6-php80', laravel: '6.*', php: '8.0', 'testbench': '4.*' }
24+
- { queue: 'github-actions-laravel6-php74', laravel: '6.*', php: '7.4', 'testbench': '4.*' }
25+
26+
name: PHP ${{ matrix.payload.php }} - Laravel ${{ matrix.payload.laravel }} - DB ${{ matrix.db }}
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v1
31+
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: ${{ matrix.payload.php }}
36+
extensions: mbstring, dom, fileinfo
37+
coverage: none
38+
39+
- name: Set up MySQL and PostgreSQL
40+
run: |
41+
MYSQL_PORT=3307 POSTGRES_PORT=5432 docker compose up ${{ matrix.db }} -d
42+
- name: Install dependencies
43+
run: |
44+
composer require "laravel/framework:${{ matrix.payload.laravel }}" "orchestra/testbench:${{ matrix.payload.testbench }}" --no-interaction --no-update
45+
composer update --prefer-stable --prefer-dist --no-interaction --no-suggest
46+
if [ "${{ matrix.db }}" = "mysql" ]; then
47+
while ! mysqladmin ping --host=127.0.0.1 --user=cloudtasks --port=3307 --password=cloudtasks --silent; do
48+
echo "Waiting for MySQL..."
49+
sleep 1
50+
done
51+
else
52+
echo "Not waiting for MySQL."
53+
fi
54+
- name: Execute tests
55+
env:
56+
DB_DRIVER: ${{ matrix.db }}
57+
CI_CLOUD_TASKS_PROJECT_ID: ${{ secrets.CI_CLOUD_TASKS_PROJECT_ID }}
58+
CI_CLOUD_TASKS_QUEUE: ${{ secrets.CI_CLOUD_TASKS_QUEUE }}
59+
CI_CLOUD_TASKS_LOCATION: ${{ secrets.CI_CLOUD_TASKS_LOCATION }}
60+
CI_CLOUD_TASKS_SERVICE_ACCOUNT_EMAIL: ${{ secrets.CI_CLOUD_TASKS_SERVICE_ACCOUNT_EMAIL }}
61+
CI_SERVICE_ACCOUNT_JSON_KEY: ${{ secrets.CI_SERVICE_ACCOUNT_JSON_KEY }}
62+
CI_CLOUD_TASKS_CUSTOM_QUEUE: ${{ matrix.payload.queue }}
63+
run: |
64+
echo $CI_SERVICE_ACCOUNT_JSON_KEY > tests/Support/gcloud-key-valid.json
65+
vendor/bin/phpunit

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor/
2+
composer.lock
3+
.idea/
4+
.phpunit.result.cache

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Releases
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
## 1.0.0 - ????-??-??
8+
9+
**Added**
10+
11+
- Initial release of the package.

LICENCE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Stackkit ([email protected])
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This package is work in progress

UPGRADING.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Upgrading
2+
3+
No contents yet.

assets/cloud-tasks-home.png

1.04 MB
Loading

assets/dashboard.png

875 KB
Loading

assets/logo.png

48.2 KB
Loading

composer.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "stackkit/laravel-google-cloud-logging",
3+
"license": "MIT",
4+
"authors": [
5+
{
6+
"name": "Marick van Tuil",
7+
"email": "[email protected]"
8+
}
9+
],
10+
"require": {
11+
"google/cloud-logging": "^1.10"
12+
},
13+
"autoload": {
14+
"psr-4": {
15+
"Stackkit\\LaravelGoogleCloudLogging\\": "src/"
16+
}
17+
},
18+
"autoload-dev": {
19+
"psr-4": {
20+
"Tests\\": "tests/",
21+
"Factories\\": "factories/"
22+
}
23+
},
24+
"extra": {
25+
"laravel": {
26+
"providers": [
27+
"Stackkit\\LaravelGoogleCloudLogging\\LoggingServiceProvider"
28+
]
29+
}
30+
}
31+
}

phpstan.neon

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
includes:
2+
- ./vendor/nunomaduro/larastan/extension.neon
3+
- ./vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
4+
parameters:
5+
paths:
6+
- src
7+
level: 9
8+
checkMissingIterableValueType: false
9+
ignoreErrors:
10+
- '/Cannot call method when\(\) on mixed/'

phpunit.xml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false">
11+
<testsuites>
12+
<testsuite name="Testsuite">
13+
<file>./tests/ConfigTest.php</file>
14+
<file>./tests/TaskHandlerTest.php</file>
15+
<file>./tests/CloudTasksApiTest.php</file>
16+
<file>./tests/CloudTasksDashboardTest.php</file>
17+
</testsuite>
18+
</testsuites>
19+
<php>
20+
<env name="APP_DEBUG" value="1"/>
21+
<env name="APP_ENV" value="testing"/>
22+
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
23+
<env name="CACHE_DRIVER" value="array"/>
24+
<env name="SESSION_DRIVER" value="array"/>
25+
<env name="MAIL_DRIVER" value="log"/>
26+
<env name="GOOGLE_APPLICATION_CREDENTIALS" value="./tests/Support/gcloud-key-valid.json" />
27+
<env name="QUEUE_DRIVER" value="cloudtasks"/>
28+
<env name="DB_DRIVER" value="mysql" />
29+
</php>
30+
</phpunit>

src/ViaGoogleCloudLogger.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Stackkit\LaravelGoogleCloudLogging;
6+
7+
use Google\Cloud\Logging\LoggingClient;
8+
use Google\Cloud\Logging\PsrLogger;
9+
10+
class ViaGoogleCloudLogger
11+
{
12+
public function __invoke(array $config): PsrLogger
13+
{
14+
$logger = LoggingClient::psrBatchLogger('app', [
15+
'clientConfig' => [
16+
'projectId' => $config['project_id'],
17+
],
18+
'resource' => $this->resource($config),
19+
'labels' => [
20+
'source' => 'laravel-log',
21+
],
22+
]);
23+
24+
return $logger;
25+
}
26+
27+
private function resource(array $config): array
28+
{
29+
if (env('K_SERVICE') && env('K_REVISION')) {
30+
return [
31+
'type' => 'cloud_run_revision',
32+
'labels' => [
33+
'projectId' => $config['project_id'],
34+
'service_name' => env('K_SERVICE'),
35+
'revision_name' => env('K_REVISION'),
36+
]
37+
];
38+
}
39+
40+
return [];
41+
}
42+
}

tests/TestCase.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Tests;
4+
5+
class TestCase extends \Orchestra\Testbench\TestCase
6+
{
7+
protected function getPackageProviders($app)
8+
{
9+
return [
10+
\Stackkit\LaravelGoogleCloudLogging\LoggingServiceProvider::class,
11+
];
12+
}
13+
14+
protected function defineDatabaseMigrations()
15+
{
16+
$this->loadMigrationsFrom(__DIR__ . '/../migrations');
17+
$this->loadMigrationsFrom(__DIR__ . '/../vendor/orchestra/testbench-core/laravel/migrations');
18+
}
19+
20+
protected function getEnvironmentSetUp($app)
21+
{
22+
// $app['config']->set('cloud-tasks.dashboard.enabled', false);
23+
}
24+
}

0 commit comments

Comments
 (0)