-
-
Notifications
You must be signed in to change notification settings - Fork 8
146 lines (127 loc) · 4.35 KB
/
tests.yml
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Tests
on:
push:
paths:
- "**.js"
- "**.jsx"
- "**.php"
- "**.vue"
- "**/composer.json"
- "**/package-lock.json"
- "demo-app/{.env.example,phpunit.xml.dist}"
- ".github/workflows/tests.yml"
jobs:
tests:
name: Dusk Test Inertia ${{ matrix.inertia }} - Stack ${{ matrix.stack }}
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
inertia: [v1, v2]
stack: [react, vue]
env:
APP_URL: "http://127.0.0.1:8000"
DB_CONNECTION: sqlite
APP_STACK: ${{ matrix.stack }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, mysql, mysqli, pdo_mysql
coverage: none
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
${{ steps.composer-cache.outputs.dir }}
~/.npm
key: ${{ runner.os }}-${{ matrix.stack }}-${{ matrix.inertia }}-${{ hashFiles('**/composer.lock', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-${{ matrix.stack }}-${{ matrix.inertia }}-
${{ runner.os }}-${{ matrix.stack }}-
${{ runner.os }}-
- name: Prepare The Environment
run: |
cd demo-app
cp .env.example .env
- name: Set React Environment Variables
if: ${{ matrix.stack == 'react' }}
run: |
cd demo-app
sed -i -e "s|APP_STACK=vue|APP_STACK=react|g" .env
- name: Build React library
if: ${{ matrix.stack == 'react' }}
run: |
# we need eslint-plugin-vue for files like helpers.js
cd vue
npm ci
npm install @inertiajs/vue3@${{ matrix.inertia == 'v1' && '1.2.0' || 'next' }}
cd ../react
npm ci
npm install @inertiajs/react@${{ matrix.inertia == 'v1' && '1.2.0' || 'next' }}
npm run build
# - name: Test React library
# if: ${{ matrix.stack == 'react' }}
# run: |
# cd react
# npm run test
- name: Build Vue library
if: ${{ matrix.stack == 'vue' }}
run: |
cd vue
npm ci
npm install @inertiajs/vue3@${{ matrix.inertia == 'v1' && '1.2.0' || 'next' }}
npm run build
- name: Test Vue library
if: ${{ matrix.stack == 'vue' }}
run: |
cd vue
npm run test
- name: Prepare Laravel app
run: |
cd demo-app
composer install --no-progress --prefer-dist --optimize-autoloader
composer require inertiajs/inertia-laravel:${{ matrix.inertia == 'v1' && '^1.3' || '2.x-dev' }}
php artisan about
npm ci
npm install @inertiajs/react@${{ matrix.inertia == 'v1' && '1.2.0' || 'next' }} @inertiajs/vue3@${{ matrix.inertia == 'v1' && '1.2.0' || 'next' }}
npm install --install-links ../react
npm install --install-links ../vue
test -d node_modules/@inertiaui/modal-react || exit 1
test -d node_modules/@inertiaui/modal-vue || exit 1
npm run build
php artisan key:generate
touch database/database.sqlite
php artisan migrate:fresh --seed
php artisan dusk:chrome-driver --detect
- name: Run tests
run: |
cd demo-app
php artisan test
- name: Start servers
run: |
cd demo-app
php artisan serve --no-reload &
./vendor/laravel/dusk/bin/chromedriver-linux --port=9515 &
- name: Run Dusk tests
run: |
cd demo-app
php artisan migrate:fresh --seed
php artisan dusk
- name: Upload artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: dusk-artifacts
path: |
demo-app/tests/Browser/screenshots
demo-app/tests/Browser/__snapshots__
demo-app/tests/Browser/console
demo-app/storage/logs