• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LeTraceurSnorkLibrary / MessSaga / 23899406397

02 Apr 2026 12:01PM UTC coverage: 30.548% (-1.1%) from 31.674%
23899406397

Pull #15

github

web-flow
Merge 7f16eb62e into a7d6f3637
Pull Request #15: feat: add s3 as storage

39 of 155 new or added lines in 14 files covered. (25.16%)

4 existing lines in 4 files now uncovered.

457 of 1496 relevant lines covered (30.55%)

0.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/Http/Controllers/HealthCheckController.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\Http\Controllers;
6

7
use Illuminate\Http\JsonResponse;
8
use Illuminate\Support\Facades\Storage;
9
use Illuminate\Support\Str;
10
use Teapot\StatusCode\Http;
11
use Throwable;
12

13
class HealthCheckController extends Controller
14
{
15
    /**
16
     * Liveness- и Startup-проба
17
     *
18
     * @return JsonResponse
19
     */
20
    public function liveness(): JsonResponse
21
    {
NEW
22
        return response()->json(
×
NEW
23
            [
×
NEW
24
                'status' => 'ok',
×
NEW
25
            ],
×
NEW
26
            Http::OK
×
NEW
27
        );
×
28
    }
29

30
    /**
31
     * Readiness-проба
32
     *
33
     * @return JsonResponse
34
     */
35
    public function readiness(): JsonResponse
36
    {
NEW
37
        $mediaDiskName   = (string)config('filesystems.media_disk', config('filesystems.default'));
×
NEW
38
        $importsDiskName = (string)config('filesystems.imports_tmp_disk', 'imports_tmp');
×
39

NEW
40
        $checks = [
×
NEW
41
            'media_disk'       => $this->checkDiskWritable($mediaDiskName),
×
NEW
42
            'imports_tmp_disk' => $this->checkDiskWritable($importsDiskName),
×
NEW
43
        ];
×
44

NEW
45
        $isReady = collect($checks)
×
NEW
46
            ->every(static fn(array $check): bool => $check['ok'] === true);
×
47

NEW
48
        return response()->json(
×
NEW
49
            [
×
NEW
50
                'status' => $isReady
×
NEW
51
                    ? 'ok'
×
NEW
52
                    : 'fail',
×
NEW
53
                'checks' => $checks,
×
NEW
54
            ],
×
NEW
55
            $isReady
×
NEW
56
                ? Http::OK
×
NEW
57
                : Http::SERVICE_UNAVAILABLE
×
NEW
58
        );
×
59
    }
60

61
    /**
62
     * @return array{
63
     *     ok: bool,
64
     *     disk: string,
65
     *     error: string|null
66
     * }
67
     */
68
    private function checkDiskWritable(string $diskName): array
69
    {
NEW
70
        $probePath = sprintf(
×
NEW
71
            'healthchecks/%s-%s.txt',
×
NEW
72
            now()->format('YmdHis'),
×
NEW
73
            Str::uuid()->toString()
×
NEW
74
        );
×
75

76
        try {
NEW
77
            $disk    = Storage::disk($diskName);
×
NEW
78
            $written = $disk->put($probePath, 'ok');
×
NEW
79
            if ($written !== true) {
×
NEW
80
                return [
×
NEW
81
                    'ok'    => false,
×
NEW
82
                    'disk'  => $diskName,
×
NEW
83
                    'error' => 'write_failed',
×
NEW
84
                ];
×
85
            }
86

NEW
87
            $disk->delete($probePath);
×
88

NEW
89
            return [
×
NEW
90
                'ok'    => true,
×
NEW
91
                'disk'  => $diskName,
×
NEW
92
                'error' => null,
×
NEW
93
            ];
×
NEW
94
        } catch (Throwable $e) {
×
NEW
95
            return [
×
NEW
96
                'ok'    => false,
×
NEW
97
                'disk'  => $diskName,
×
NEW
98
                'error' => $e->getMessage(),
×
NEW
99
            ];
×
100
        }
101
    }
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc