Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
pascalbaljet committed Aug 2, 2022
commit b3b164cc00748ded7a1cc7b0ac553e312959cf15
31 changes: 24 additions & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-2019]
os: [ubuntu-latest, windows-latest]
php: [8.1, 8.0]
laravel: [9.*]
dependency-version: [prefer-lowest, prefer-stable]
Expand All @@ -159,7 +159,7 @@ jobs:
- name: Remove installed Splade (Windows)
run: rd "vendor/protonemedia/laravel-splade" /s /q
shell: cmd
if: matrix.os == 'windows-2019'
if: matrix.os == 'windows-latest'

- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -186,21 +186,38 @@ jobs:
mkdir "node_modules/@protonemedia/laravel-splade/dist"
xcopy "vendor/protonemedia/laravel-splade/dist" "node_modules/@protonemedia/laravel-splade/dist" /E /I
shell: cmd
if: matrix.os == 'windows-2019'
if: matrix.os == 'windows-latest'

- name: Compile assets
run: npm run build

- name: Run Laravel Server
- name: Run Laravel Server (Unix)
run: php artisan serve &
if: matrix.os == 'ubuntu-latest'

- name: Run Test
- name: Run Test (Unix)
run: php vendor/protonemedia/laravel-splade/TestStubs.php
if: matrix.os == 'ubuntu-latest'

- name: Start SSR server
- name: Run Laravel Server (Windows) and Run Test
run: |
start /b cmd /v:on /c "(php artisan serve) &"
php vendor/protonemedia/laravel-splade/TestStubs.php
shell: cmd
if: matrix.os == 'windows-latest'

- name: Start SSR server (Unix)
run: |
echo "SPLADE_SSR_ENABLED=true" >> .env
node bootstrap/ssr/ssr.mjs &

- name: Run Test command
- name: Run Test command (Unix)
run: php artisan splade:ssr-test
if: matrix.os == 'ubuntu-latest'

- name: Start SSR server (Windows) and Run Test command
run: |
echo "SPLADE_SSR_ENABLED=true" >> .env
node bootstrap/ssr/ssr.mjs &
php artisan splade:ssr-test
if: matrix.os == 'windows-latest'
51 changes: 50 additions & 1 deletion TestStubs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
<?php

$home = file_get_contents('http://127.0.0.1:8000/');
function value($value, ...$args)
{
return $value instanceof \Closure ? $value(...$args) : $value;
}

function retry($times, callable $callback, $sleepMilliseconds = 0, $when = null)
{
$attempts = 0;

$backoff = [];

if (is_array($times)) {
$backoff = $times;

$times = count($times) + 1;
}

beginning:
$attempts++;
$times--;

try {
return $callback($attempts);
} catch (Exception $e) {
if ($times < 1 || ($when && ! $when($e))) {
throw $e;
}

$sleepMilliseconds = $backoff[$attempts - 1] ?? $sleepMilliseconds;

if ($sleepMilliseconds) {
usleep(value($sleepMilliseconds, $attempts, $e) * 1000);
}

goto beginning;
}
}

function get()
{
$contents = file_get_contents('http://127.0.0.1:8000/');

if (!$contents) {
throw new Exception("No contents");
}

return $contents;
}

$home = retry(10, fn () => get(), 1000);

$needles = [
'<div id="app" data-components="',
Expand Down