-
Notifications
You must be signed in to change notification settings - Fork 59
119 lines (102 loc) · 4.35 KB
/
Copy pathtests.yml
File metadata and controls
119 lines (102 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Authentication Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ["8.2", "8.3", "8.4", "8.5"]
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, xml, ctype, iconv, mysql, imagick
- name: Cache Composer Packages
uses: actions/cache@v5
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }}
restore-keys: |
${{ runner.os }}-composer-git-${{ matrix.php-version }}
- name: Setup Laravel Application
run: composer create-project --prefer-dist --no-progress laravel/laravel laravel_app_${{ matrix.php-version }} --no-interaction
- name: Install DevDojo Auth from local checkout
run: |
composer config repositories.local-auth '{"type": "path", "url": "../", "options": {"symlink": false}}'
composer require 'devdojo/auth:@dev' --with-all-dependencies --no-progress
working-directory: ./laravel_app_${{ matrix.php-version }}
- name: Publish DevDojo Auth Assets and Config
run: |
php artisan vendor:publish --tag=auth:assets
php artisan vendor:publish --tag=auth:config
php artisan vendor:publish --tag=auth:migrations
working-directory: ./laravel_app_${{ matrix.php-version }}
- name: Setup test environment
run: |
rm -rf tests
ln -s vendor/devdojo/auth/tests tests
touch database/database_${{ matrix.php-version }}.sqlite
sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/' .env
sed -i 's/^DB_DATABASE=laravel/DB_DATABASE=database\/database_${{ matrix.php-version }}.sqlite/' .env
working-directory: ./laravel_app_${{ matrix.php-version }}
- name: Install dependencies and run migrations
run: |
composer require doctrine/dbal --no-progress
php artisan migrate
working-directory: ./laravel_app_${{ matrix.php-version }}
- name: Clean up composer.json - Remove PHPUnit
run: |
php -r '
$json = json_decode(file_get_contents("composer.json"), true);
if (!$json) { echo "Failed to decode composer.json"; exit(1); }
unset($json["require-dev"]["phpunit/phpunit"]);
file_put_contents("composer.json", json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
'
working-directory: ./laravel_app_${{ matrix.php-version }}
- name: Reinstall dependencies
run: |
rm composer.lock
rm -rf vendor
composer install --no-scripts --no-progress
composer dump-autoload
working-directory: ./laravel_app_${{ matrix.php-version }}
- name: Install test dependencies
run: |
composer require --dev --no-progress --with-all-dependencies \
pestphp/pest \
larastan/larastan:^3.1 \
laravel/dusk \
alebatistella/duskapiconf \
protonemedia/laravel-dusk-fakes:^1.6
working-directory: ./laravel_app_${{ matrix.php-version }}
- name: Set port number based on PHP version
run: |
if [[ "${{ matrix.php-version }}" == "8.2" ]]; then
echo "SERVER_PORT=8000" >> $GITHUB_ENV
elif [[ "${{ matrix.php-version }}" == "8.3" ]]; then
echo "SERVER_PORT=8001" >> $GITHUB_ENV
else
echo "SERVER_PORT=8002" >> $GITHUB_ENV
fi
- name: Start Chrome Driver and PHP Server
run: |
php artisan dusk:chrome-driver --detect &
./vendor/laravel/dusk/bin/chromedriver-linux &
php artisan serve --port=${{ env.SERVER_PORT }} --no-reload &
working-directory: ./laravel_app_${{ matrix.php-version }}
- name: Run Tests
run: ./vendor/bin/pest --parallel
working-directory: ./laravel_app_${{ matrix.php-version }}
- name: Run Dusk Tests
env:
APP_URL: "http://127.0.0.1:${{ env.SERVER_PORT }}"
APP_ENV: testing
run: php artisan dusk -vvv
working-directory: ./laravel_app_${{ matrix.php-version }}