Skip to content

Commit 5b0bcd5

Browse files
committed
Merge branch '1.x' into restart
2 parents c4b6465 + 99b4850 commit 5b0bcd5

File tree

67 files changed

+607
-337
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+607
-337
lines changed

.github/workflows/pull_request.yml

+13-9
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
restore-keys: ${{ runner.os }}-package-composer
4646

4747
- name: Install dependencies
48-
run: composer update --prefer-dist --no-interaction --no-progress
48+
run: composer install --prefer-dist --no-interaction --no-progress
4949

5050
- name: Check platform
5151
run: composer check-platform-reqs
@@ -183,7 +183,7 @@ jobs:
183183
restore-keys: ${{ runner.os }}-package-composer
184184

185185
- name: Install dependencies
186-
run: composer update --prefer-dist --no-interaction --no-progress
186+
run: composer install --prefer-dist --no-interaction --no-progress
187187

188188
- name: Run Pint (CI only)
189189
run: vendor/bin/pint --config=pint.ci.json
@@ -232,7 +232,7 @@ jobs:
232232
php-version: ${{ env.minimum_supported_php_version }}
233233
extensions: ${{ env.agent_extensions }}
234234
ini-values: error_reporting=E_ALL
235-
tools: composer:v2, box:4
235+
tools: composer:v2, box:4.6.3
236236
coverage: none
237237

238238
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies
@@ -299,7 +299,7 @@ jobs:
299299
php-version: ${{ env.minimum_supported_php_version }}
300300
extensions: ${{ env.client_extensions }}
301301
ini-values: error_reporting=E_ALL
302-
tools: composer:v2, box:4
302+
tools: composer:v2, box:4.6.3
303303
coverage: none
304304

305305
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies
@@ -340,15 +340,16 @@ jobs:
340340
strategy:
341341
matrix:
342342
php: [8.2, 8.3]
343-
laravel: [11]
343+
laravel: [10, 11]
344+
prefer-lowest: ['0', '1']
344345

345346
name: Test package [PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}]
346347

347348
steps:
348349
- name: Checkout code
349350
uses: actions/checkout@v4
350351

351-
- name: Setup PHP ${{ env.minimum_supported_php_version }} and tooling
352+
- name: Setup PHP ${{ matrix.php }} and tooling
352353
uses: shivammathur/setup-php@v2
353354
with:
354355
php-version: ${{ matrix.php }}
@@ -369,8 +370,11 @@ jobs:
369370
key: ${{ runner.os }}-package-composer-${{ hashFiles('**/composer.json') }}
370371
restore-keys: ${{ runner.os }}-package-composer
371372

373+
- name: Require Laravel Version
374+
run: composer require laravel/framework:^${{ matrix.laravel }} --no-update
375+
372376
- name: Install dependencies
373-
run: composer update --prefer-dist --no-interaction --no-progress
377+
run: COMPOSER_PREFER_LOWEST=${{ matrix.prefer-lowest }} composer install --prefer-dist --no-interaction --no-progress
374378

375379
- name: Execute tests
376380
run: vendor/bin/pest --coverage --min=80
@@ -395,7 +399,7 @@ jobs:
395399
- name: Checkout code
396400
uses: actions/checkout@v4
397401

398-
- name: Setup PHP ${{ env.minimum_supported_php_version }} and tooling
402+
- name: Setup PHP ${{ matrix.php }} and tooling
399403
uses: shivammathur/setup-php@v2
400404
with:
401405
php-version: ${{ matrix.php }}
@@ -445,7 +449,7 @@ jobs:
445449
- name: Checkout code
446450
uses: actions/checkout@v4
447451

448-
- name: Setup PHP ${{ env.minimum_supported_php_version }} and tooling
452+
- name: Setup PHP ${{ matrix.php }} and tooling
449453
uses: shivammathur/setup-php@v2
450454
with:
451455
php-version: ${{ matrix.php }}

CHANGELOG.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
# Release Notes
22

3-
## [Unreleased](https://github.com/laravel/nightwatch/compare/v1.0.4...1.x)
3+
## [Unreleased](https://github.com/laravel/nightwatch/compare/v1.0.7...1.x)
4+
5+
## [v1.0.7](https://github.com/laravel/nightwatch/compare/v1.0.6...v1.0.7) - 2025-03-03
6+
7+
### What's Changed
8+
9+
* Fix class declaration by [@timacdonald](https://github.com/timacdonald) in https://github.com/laravel/nightwatch/pull/123
10+
11+
**Full Changelog**: https://github.com/laravel/nightwatch/compare/v1.0.6...v1.0.7
12+
13+
## [v1.0.6](https://github.com/laravel/nightwatch/compare/v1.0.5...v1.0.6) - 2025-03-03
14+
15+
### What's Changed
16+
17+
* Improve deterministic builds by [@timacdonald](https://github.com/timacdonald) in https://github.com/laravel/nightwatch/pull/121
18+
* Allow longer job names by [@timacdonald](https://github.com/timacdonald) in https://github.com/laravel/nightwatch/pull/122
19+
20+
**Full Changelog**: https://github.com/laravel/nightwatch/compare/v1.0.5...v1.0.6
21+
22+
## [v1.0.5](https://github.com/laravel/nightwatch/compare/v1.0.4...v1.0.5) - 2025-02-27
23+
24+
### What's Changed
25+
26+
* Use more performant hashing algorithm by [@timacdonald](https://github.com/timacdonald) in https://github.com/laravel/nightwatch/pull/116
27+
* Improve deterministic builds by [@timacdonald](https://github.com/timacdonald) in https://github.com/laravel/nightwatch/pull/117
28+
* Send package version in the user agent header by [@timacdonald](https://github.com/timacdonald) in https://github.com/laravel/nightwatch/pull/118
29+
30+
**Full Changelog**: https://github.com/laravel/nightwatch/compare/v1.0.4...v1.0.5
431

532
## [v1.0.4](https://github.com/laravel/nightwatch/compare/v1.0.3...v1.0.4) - 2025-02-25
633

agent/box.json.dist

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"banner": false,
99
"shebang": false,
1010
"compactors": [
11-
"KevinGH\\Box\\Compactor\\Php",
1211
"KevinGH\\Box\\Compactor\\PhpScoper"
1312
]
1413
}

agent/build/agent.phar

359 KB
Binary file not shown.

agent/build/signature.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5D45C291DAC3F017D4FF67CE57A1579E4064D787DCEDFB29DFE0FC5039040648747D5939609EEF6431FD578D47B512FE5A354E1C3CC50F94CC0995919BEB4189
1+
C0978882D751DC34E15523FF52762FD07A38E47F79482287AFAEABF1CB797FBF38747687A11CE7C65BA97F7F682A8683E58EDA5AD509E84F981354F675858369

agent/src/Factories/IngestDetailsRepositoryFactory.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Closure;
66
use Laravel\NightwatchAgent\IngestDetails;
77
use Laravel\NightwatchAgent\IngestDetailsRepository;
8+
use Laravel\NightwatchAgent\PackageVersionRepository;
89
use React\Http\Browser;
910
use React\Socket\Connector;
1011
use Throwable;
@@ -24,6 +25,8 @@ public function __invoke(
2425
float $timeout,
2526
int $preemptivelyRefreshInSeconds,
2627
int $minRefreshDurationInSeconds,
28+
string $server,
29+
PackageVersionRepository $packageVersion,
2730
Closure $onAuthenticationSuccess,
2831
Closure $onAuthenticationError,
2932
): IngestDetailsRepository {
@@ -32,14 +35,15 @@ public function __invoke(
3235
$browser = (new Browser($connector))
3336
->withTimeout($timeout)
3437
->withHeader('authorization', "Bearer {$refreshToken}")
35-
->withHeader('user-agent', 'NightwatchAgent/1')
3638
->withHeader('content-type', 'application/json')
39+
->withHeader('nightwatch-server', $server)
3740
->withBase(rtrim($baseUrl, '/').'/api/agent-auth');
3841

3942
return new IngestDetailsRepository(
4043
browser: $browser,
4144
preemptivelyRefreshInSeconds: $preemptivelyRefreshInSeconds,
4245
minRefreshDurationInSeconds: $minRefreshDurationInSeconds,
46+
packageVersion: $packageVersion,
4347
onAuthenticationSuccess: $onAuthenticationSuccess,
4448
onAuthenticationError: $onAuthenticationError,
4549
);

agent/src/Factories/IngestFactory.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Closure;
66
use Laravel\NightwatchAgent\Ingest;
77
use Laravel\NightwatchAgent\IngestDetailsRepository;
8+
use Laravel\NightwatchAgent\PackageVersionRepository;
89
use Laravel\NightwatchAgent\StreamBuffer;
910
use Psr\Http\Message\ResponseInterface;
1011
use React\Http\Browser;
@@ -25,16 +26,18 @@ public function __invoke(
2526
int $threshold,
2627
int $concurrentRequestLimit,
2728
int $maxBufferDurationInSeconds,
29+
string $server,
30+
PackageVersionRepository $packageVersion,
2831
Closure $onIngestSuccess,
2932
Closure $onIngestError,
3033
): Ingest {
3134
$connector = new Connector(['timeout' => $connectionTimeout]);
3235

3336
$browser = (new Browser($connector))
3437
->withTimeout($timeout)
35-
->withHeader('user-agent', 'NightwatchAgent/1')
3638
->withHeader('content-type', 'application/octet-stream')
37-
->withHeader('content-encoding', 'gzip');
39+
->withHeader('content-encoding', 'gzip')
40+
->withHeader('nightwatch-server', $server);
3841

3942
if ($debug) {
4043
$browser = $browser->withHeader('nightwatch-debug', '1');
@@ -48,6 +51,7 @@ public function __invoke(
4851
buffer: $buffer,
4952
concurrentRequestLimit: $concurrentRequestLimit,
5053
maxBufferDurationInSeconds: $debug ? 1 : $maxBufferDurationInSeconds,
54+
packageVersion: $packageVersion,
5155
onIngestSuccess: $onIngestSuccess,
5256
onIngestError: $onIngestError,
5357
);

agent/src/Ingest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function __construct(
3131
private StreamBuffer $buffer,
3232
private int $concurrentRequestLimit,
3333
private int $maxBufferDurationInSeconds,
34+
private PackageVersionRepository $packageVersion,
3435
private Closure $onIngestSuccess,
3536
private Closure $onIngestError,
3637
) {
@@ -91,7 +92,10 @@ private function ingest(string $payload): void
9192

9293
return $this->browser->post(
9394
url: $ingestDetails->ingestUrl,
94-
headers: ['authorization' => "Bearer {$ingestDetails->token}"],
95+
headers: [
96+
'authorization' => "Bearer {$ingestDetails->token}",
97+
'user-agent' => 'NightwatchAgent/'.$this->packageVersion->get(),
98+
],
9599
body: $payload,
96100
)->then(
97101
function (ResponseInterface $response) use ($start): void {

agent/src/IngestDetailsRepository.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function __construct(
3535
private Browser $browser,
3636
private int $preemptivelyRefreshInSeconds,
3737
private int $minRefreshDurationInSeconds,
38+
private PackageVersionRepository $packageVersion,
3839
private Closure $onAuthenticationSuccess,
3940
private Closure $onAuthenticationError,
4041
) {
@@ -61,7 +62,9 @@ private function refresh(): PromiseInterface
6162
{
6263
$start = microtime(true);
6364

64-
return $this->browser->post('')->then(function (ResponseInterface $response) use ($start): IngestDetails {
65+
return $this->browser->post('', headers: [
66+
'user-agent' => 'NightwatchAgent/'.$this->packageVersion->get(),
67+
])->then(function (ResponseInterface $response) use ($start): IngestDetails {
6568
$duration = microtime(true) - $start;
6669

6770
$data = json_decode($response->getBody()->getContents(), associative: true, flags: JSON_THROW_ON_ERROR);
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Laravel\NightwatchAgent;
4+
5+
use Throwable;
6+
7+
use function file_get_contents;
8+
use function trim;
9+
10+
class PackageVersionRepository
11+
{
12+
public function __construct(
13+
private string $path,
14+
) {
15+
//
16+
}
17+
18+
public function get(): string
19+
{
20+
try {
21+
$version = file_get_contents($this->path);
22+
23+
if ($version === false) {
24+
return '';
25+
}
26+
27+
return trim($version);
28+
} catch (Throwable $e) {
29+
return '';
30+
}
31+
}
32+
}

agent/src/agent.php

+11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Throwable;
1111

1212
use function date;
13+
use function gethostname;
1314
use function round;
1415
use function str_replace;
1516

@@ -36,6 +37,8 @@
3637
$ingestConnectionTimeout ??= 5;
3738
/** @var ?float $ingestTimeout */
3839
$ingestTimeout ??= 10;
40+
/** @var ?string $server */
41+
$server ??= (string) gethostname();
3942

4043
/*
4144
* Internal state...
@@ -59,13 +62,19 @@
5962
* Initialize services...
6063
*/
6164

65+
$packageVersion = new PackageVersionRepository(
66+
path: $basePath.'/../../version.txt',
67+
);
68+
6269
$ingestDetails = (new IngestDetailsRepositoryFactory)(
6370
baseUrl: $baseUrl,
6471
refreshToken: $refreshToken,
6572
connectionTimeout: $authenticationConnectionTimeout,
6673
timeout: $authenticationTimeout,
6774
preemptivelyRefreshInSeconds: 60,
6875
minRefreshDurationInSeconds: 60,
76+
server: $server,
77+
packageVersion: $packageVersion,
6978
onAuthenticationSuccess: static fn (IngestDetails $ingestDetails, float $duration) => $info('Authentication successful against ['.$baseUrl.'] ['.round($duration, 3).'s]'),
7079
onAuthenticationError: static fn (Throwable $e, float $duration) => $info('Authentication failed against ['.$baseUrl.'] ['.round($duration, 3).'s]: '.$e->getMessage()),
7180
);
@@ -78,6 +87,8 @@
7887
threshold: 6_000_000,
7988
concurrentRequestLimit: 2,
8089
maxBufferDurationInSeconds: 10,
90+
server: $server,
91+
packageVersion: $packageVersion,
8192
onIngestSuccess: static fn (ResponseInterface $response, float $duration) => $info('Ingest successful ['.round($duration, 3).'s]'),
8293
onIngestError: static fn (Throwable $e, float $duration) => $info('Ingest failed ['.round($duration, 3).'s]: '.$e->getMessage()),
8394
);

client/box.json.dist

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"banner": false,
99
"shebang": false,
1010
"compactors": [
11-
"KevinGH\\Box\\Compactor\\Php",
1211
"KevinGH\\Box\\Compactor\\PhpScoper"
1312
]
1413
}

client/build/client.phar

225 KB
Binary file not shown.

client/build/signature.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
B53311EA72F09FFB7975024C4941F38D47FC0E85523D00479457711092912C42FF31A92A27944719E49CEBC5F14504402CD103C0253325D6EBEC9F9C7A13B895
1+
7AE8F775A90FE7651BDCB1BB577AEAB19B350B3902F9DD4A99D778DDD5B056D1D2FC78A31E0133FDDE502CC9F71BC5DB2E7541C2608FEED7D237A2B3F8C6BC28

client/scoper.inc.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// is only ever required once to fix this issue manually.
1010
static function (string $filePath, string $prefix, string $content): string {
1111
if ($filePath === 'vendor/composer/InstalledVersions.php') {
12-
$content = str_replace('class InstalledVersions', "\nif (class_exists(InstalledVersions::class, autoload: false)) { return; }\n\nclass InstalledVersions", $content);
12+
$content = str_replace('class InstalledVersions', "\nif (! class_exists(InstalledVersions::class, autoload: false)) {\nclass InstalledVersions", $content).'}'.PHP_EOL;
1313
}
1414

1515
return $content;

composer.json

+12-11
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,28 @@
2323
"nesbot/carbon": "^2.0|^3.0",
2424
"psr/http-message": "^1.0|^2.0",
2525
"psr/log": "^1.0|^2.0|^3.0",
26-
"symfony/console": "^7.0",
27-
"symfony/http-foundation": "^7.0"
26+
"symfony/console": "^6.0|^7.0",
27+
"symfony/http-foundation": "^6.0|^7.0"
2828
},
2929
"require-dev": {
30+
"guzzlehttp/guzzle": "^7.0",
3031
"guzzlehttp/promises": "^2.0",
3132
"guzzlehttp/psr7": "^2.0",
3233
"laravel/pint": "1.21.0",
3334
"mockery/mockery": "^1.0",
3435
"mongodb/laravel-mongodb": "^5.0",
35-
"orchestra/pest-plugin-testbench": "^3.0",
36-
"orchestra/testbench": "^9.0",
37-
"orchestra/testbench-core": "^9.0",
38-
"pestphp/pest": "^3.0",
39-
"pestphp/pest-plugin-arch": "^3.0",
40-
"pestphp/pest-plugin-laravel": "^3.0",
36+
"orchestra/pest-plugin-testbench": "^2.0|^3.0",
37+
"orchestra/testbench": "^8.0|^9.0",
38+
"orchestra/testbench-core": "^8.0|^9.0",
39+
"pestphp/pest": "^2.0|^3.0",
40+
"pestphp/pest-plugin-arch": "^2.0|^3.0",
41+
"pestphp/pest-plugin-laravel": "^2.0|^3.0",
4142
"phpstan/phpstan": "^1.0",
4243
"ramsey/uuid": "^4.0",
4344
"spatie/laravel-ignition": "^2.0",
44-
"symfony/mailer": "^7.0",
45-
"symfony/mime": "^7.0",
46-
"symfony/var-dumper": "^7.0"
45+
"symfony/mailer": "^6.0|^7.0",
46+
"symfony/mime": "^6.0|^7.0",
47+
"symfony/var-dumper": "^6.0|^7.0"
4748
},
4849
"autoload": {
4950
"psr-4": {

phpunit.xml.dist

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
</source>
1919
<php>
2020
<env name="APP_KEY" value="base64:uz4B1RtFO57QGzbZX1kRYX9hIRB50+QzqFeg9zbFJlY="/>
21+
<env name="DB_CONNECTION" value="sqlite" />
2122
<env name="DB_DATABASE" value="tests/database.sqlite" />
23+
<env name="MAIL_MAILER" value="array" />
2224
</php>
2325
</phpunit>

0 commit comments

Comments
 (0)