Skip to content

Commit 8c0758c

Browse files
authored
[Feature] Tests and a CI pipeline (alexjustesen#2101)
1 parent 1bb1ad7 commit 8c0758c

File tree

18 files changed

+1351
-151
lines changed

18 files changed

+1351
-151
lines changed

.env.example

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ LOG_DEPRECATIONS_CHANNEL=null
2121
LOG_LEVEL=debug
2222

2323
DB_CONNECTION=sqlite
24-
# DB_HOST=127.0.0.1
25-
# DB_PORT=3306
26-
# DB_DATABASE=speedtest_tracker
27-
# DB_USERNAME=
28-
# DB_PASSWORD=
2924

3025
BROADCAST_CONNECTION=log
3126
CACHE_STORE=database

.env.testing

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# .github/workflows/tests.yml
2+
name: Tests
3+
4+
on:
5+
push:
6+
branches:
7+
- '!main'
8+
- '!release-**'
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
lint-app:
14+
runs-on: ubuntu-24.04
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: "duster"
20+
uses: tighten/duster-action@v3
21+
with:
22+
args: lint --using=pint -v
23+
24+
test-app:
25+
needs: lint-app
26+
runs-on: ubuntu-24.04
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: '8.3'
35+
36+
- name: Create SQLite Database
37+
run: |
38+
touch database/testing.sqlite
39+
40+
- name: Install Dependencies
41+
run: |
42+
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
43+
npm ci && npm run build
44+
45+
- name: Copy Environment File
46+
run: cp .env.example .env
47+
48+
- name: Generate App Key
49+
run: php artisan key:generate --quiet
50+
51+
- name: Run Tests
52+
run: php artisan test --parallel

.github/workflows/tests.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,21 @@
66
use App\Models\Result;
77
use Illuminate\Http\Request;
88

9-
class HomeController extends Controller
9+
class PagesController extends Controller
1010
{
11-
/**
12-
* Handle the incoming request.
13-
*/
14-
public function __invoke(Request $request)
11+
public function gettingStarted()
12+
{
13+
return view('getting-started');
14+
}
15+
16+
public function home(Request $request)
1517
{
1618
$latestResult = Result::query()
1719
->select(['id', 'ping', 'download', 'upload', 'status', 'created_at'])
1820
->where('status', '=', ResultStatus::Completed)
1921
->latest()
2022
->first();
2123

22-
if (! $latestResult) {
23-
return view('get-started');
24-
}
25-
2624
return view('dashboard', [
2725
'latestResult' => $latestResult,
2826
]);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use App\Enums\ResultStatus;
6+
use App\Models\Result;
7+
use Closure;
8+
use Illuminate\Http\Request;
9+
use Symfony\Component\HttpFoundation\Response;
10+
11+
class GettingStarted
12+
{
13+
/**
14+
* Handle an incoming request.
15+
*
16+
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
17+
*/
18+
public function handle(Request $request, Closure $next): Response
19+
{
20+
if (Result::where('status', '=', ResultStatus::Completed)->doesntExist()) {
21+
return redirect()->route('getting-started');
22+
}
23+
24+
return $next($request);
25+
}
26+
}

bootstrap/app.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
use App\Http\Middleware\PublicDashboard;
43
use App\Providers\AppServiceProvider;
54
use Illuminate\Foundation\Application;
65
use Illuminate\Foundation\Configuration\Exceptions;
@@ -16,10 +15,11 @@
1615
)
1716
->withMiddleware(function (Middleware $middleware) {
1817
$middleware->alias([
19-
'public-dashboard' => PublicDashboard::class,
18+
'getting-started' => App\Http\Middleware\GettingStarted::class,
19+
'public-dashboard' => App\Http\Middleware\PublicDashboard::class,
2020
]);
2121

22-
$middleware->redirectGuestsTo(fn () => route('admin/login'));
22+
$middleware->redirectGuestsTo(fn () => route('filament.admin.auth.login'));
2323
$middleware->redirectUsersTo(AppServiceProvider::HOME);
2424

2525
$middleware->trustProxies(at: '*');

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@
4040
},
4141
"require-dev": {
4242
"fakerphp/faker": "^1.24.1",
43+
"laravel/pail": "^1.2.2",
4344
"laravel/pint": "^1.21.2",
4445
"laravel/sail": "^1.41.0",
4546
"laravel/telescope": "^5.6.0",
4647
"mockery/mockery": "^1.6.12",
4748
"nunomaduro/collision": "^8.7.0",
48-
"phpunit/phpunit": "^11.5.13",
49+
"pestphp/pest": "^3.7.4",
50+
"pestphp/pest-plugin-laravel": "^3.1",
4951
"spatie/laravel-ignition": "^2.9.1",
50-
"tightenco/duster": "^3.1.0",
51-
"laravel/pail": "^1.2.2"
52+
"tightenco/duster": "^3.1.0"
5253
},
5354
"autoload": {
5455
"files": [

0 commit comments

Comments
 (0)