-
Notifications
You must be signed in to change notification settings - Fork 4
158 lines (125 loc) · 4.33 KB
/
Copy pathtests.yml
File metadata and controls
158 lines (125 loc) · 4.33 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
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
147
148
149
150
151
152
153
154
155
156
157
158
name: tests
on:
push:
branches:
- main
pull_request:
# Read-only. This repository accepts pull requests from forks, so no workflow
# here may be granted write access to the repository or to secrets.
permissions:
contents: read
jobs:
php:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ["8.4", "8.5"]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
coverage: none
- name: Resolve the Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer downloads
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ hashFiles('composer.lock') }}
restore-keys: composer-${{ runner.os }}-
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Copy environment file
run: cp .env.example .env
- name: Generate application key
run: php artisan key:generate
- name: Tests
run: ./vendor/bin/pest
frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
- name: Install dependencies
run: npm ci
- name: Typecheck
run: npm run typecheck
- name: Build
run: npm run build
# HomepageRenderTest is the only test that needs a built SSR bundle and a
# running SSR service, and it skips itself when either is missing. The `php`
# job above provides neither, so every assertion in that file silently
# skipped on every run. This job is the one place it actually executes;
# REQUIRE_SSR turns those skips into failures so it cannot go quiet again.
ssr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
tools: composer:v2
coverage: none
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
- name: Resolve the Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer downloads
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ hashFiles('composer.lock') }}
restore-keys: composer-${{ runner.os }}-
- name: Install PHP dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Install Node dependencies
run: npm ci
- name: Copy environment file
run: cp .env.example .env
- name: Generate application key
run: php artisan key:generate
- name: Build client and SSR bundles
run: npm run build
# The port is read from .env rather than repeated here: .env.example
# already carries INERTIA_SSR_URL and INERTIA_SSR_PORT, and its own
# comment requires the two to agree. A third copy would be a third thing
# to keep in sync.
- name: Start the SSR service
run: |
port="$(grep '^INERTIA_SSR_PORT=' .env | cut -d= -f2)"
nohup php artisan inertia:start-ssr > /tmp/ssr.log 2>&1 &
for _ in $(seq 1 30); do
if (exec 3<>"/dev/tcp/127.0.0.1/${port}") 2>/dev/null; then
exec 3<&-
echo "SSR service listening on ${port}"
exit 0
fi
sleep 1
done
echo "SSR service did not open port ${port} within 30s" >&2
cat /tmp/ssr.log >&2 || true
exit 1
- name: SSR render tests
env:
REQUIRE_SSR: 1
run: ./vendor/bin/pest tests/Feature/Landing/HomepageRenderTest.php
- name: SSR service log
if: always()
run: cat /tmp/ssr.log || true