Skip to content

Commit 82f3586

Browse files
committed
Set a sensible default deployment config value
1 parent 69c70cf commit 82f3586

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

config/nightwatch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
return [
44
'enabled' => env('NIGHTWATCH_ENABLED', true),
55
'token' => env('NIGHTWATCH_TOKEN'),
6-
'deployment' => env('NIGHTWATCH_DEPLOY'),
6+
'deployment' => env('NIGHTWATCH_DEPLOY', rescue(static fn () => trim((string) shell_exec('git describe --tags --always 2>/dev/null')), '', false)),
77
'server' => env('NIGHTWATCH_SERVER', (string) gethostname()),
88
'capture_exception_source_code' => env('NIGHTWATCH_CAPTURE_EXCEPTION_SOURCE_CODE', true),
99
'redact_headers' => explode(',', env('NIGHTWATCH_REDACT_HEADERS', 'Authorization,Cookie,Proxy-Authorization,X-XSRF-TOKEN')),

tests/Unit/CoreTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Models\User;
66
use Carbon\CarbonImmutable;
77
use Illuminate\Support\Facades\Auth;
8+
use Illuminate\Support\Facades\Route;
89
use Laravel\Nightwatch\ExecutionStage;
910
use Laravel\Nightwatch\Facades\Nightwatch;
1011
use Orchestra\Testbench\Attributes\WithEnv;
@@ -15,6 +16,7 @@
1516

1617
use function dirname;
1718
use function hash;
19+
use function trim;
1820

1921
class CoreTest extends TestCase
2022
{
@@ -89,4 +91,18 @@ public function test_it_ingests_fatal_errors_immediately(): void
8991
],
9092
]);
9193
}
94+
95+
#[WithEnv('NIGHTWATCH_FORCE_REQUEST', '1')]
96+
public function test_it_uses_git_refs_for_deployments_by_default(): void
97+
{
98+
$ingest = $this->fakeIngest();
99+
Route::get('/test', function () {
100+
return 'OK';
101+
});
102+
103+
$this->get('/test')->assertOk();
104+
105+
$ingest->assertWrittenTimes(1);
106+
$ingest->assertLatestWrite('request:0.deploy', trim(`git describe --tags --always`));
107+
}
92108
}

0 commit comments

Comments
 (0)