@@ -2,35 +2,57 @@ name: Feature Tests
22
33on :
44 push :
5- branches : [master]
5+ branches :
6+ - master
67 pull_request :
78 workflow_dispatch :
89
10+ env :
11+ APP_NAME : " Computer Science Resources"
12+ APP_ENV : testing
13+ APP_KEY : base64:7aYe15aBsSh6a2ScVwj1JfYjQKUmz9Z5X/GSe64joHA=
14+ APP_DEBUG : ' true'
15+ APP_TIMEZONE : UTC
16+ APP_URL : http://localhost
17+
18+ DB_CONNECTION : mysql
19+ DB_HOST : 127.0.0.1
20+ DB_PORT : 3306
21+ DB_DATABASE : testing
22+ DB_USERNAME : root
23+ DB_PASSWORD : password
24+
925jobs :
26+ # --------------------------------------------------------------
27+ # 1. PHP dependencies setup
28+ # --------------------------------------------------------------
1029 php-setup :
1130 runs-on : ubuntu-latest
1231 steps :
1332 - name : Checkout code
1433 uses : actions/checkout@v4
15-
34+
1635 - name : Set up PHP & Composer
1736 uses : shivammathur/setup-php@v2
1837 with :
1938 php-version : 8.3
2039 extensions : mbstring, pdo, mysql, bcmath, tokenizer
2140 tools : composer
22-
23- - name : Install Composer dependencies
24- run : composer install --no-interaction --prefer-dist
25-
41+
2642 - name : Cache Composer dependencies
2743 uses : actions/cache@v3
2844 with :
2945 path : vendor
30- key : ${{ runner.os }}-php -${{ hashFiles('composer.lock') }}
46+ key : ${{ runner.os }}-composer -${{ hashFiles('composer.lock') }}
3147 restore-keys : |
32- ${{ runner.os }}-php-
48+ ${{ runner.os }}-composer-
49+
50+ - name : Install Composer dependencies
51+ run : composer install --no-interaction --prefer-dist
3352
53+ # --------------------------------------------------------------
54+ # 2. Node/Vite build
55+ # --------------------------------------------------------------
3456 frontend-setup :
3557 runs-on : ubuntu-latest
3658 steps :
@@ -60,13 +82,15 @@ jobs:
6082 uses : actions/cache@v3
6183 with :
6284 path : public/build
63- key : ${{ runner.os }}-vite-${{ hashFiles('package-lock.json', 'vite.config.js') }}
64- restore-keys : |
65- ${{ runner.os }}-vite-
85+ key : ${{ runner.os }}-vite-${{ github.sha }}
6686
67- test-setup :
87+ # --------------------------------------------------------------
88+ # 3. Run tests
89+ # --------------------------------------------------------------
90+ run-feature-tests :
6891 runs-on : ubuntu-latest
6992 needs : [php-setup, frontend-setup]
93+
7094 services :
7195 mysql :
7296 image : mysql:8.0
@@ -80,53 +104,31 @@ jobs:
80104 --health-interval=10s
81105 --health-timeout=5s
82106 --health-retries=5
83-
84- env :
85- APP_NAME : " Computer Science Resources"
86- APP_ENV : testing
87- APP_KEY : base64:7aYe15aBsSh6a2ScVwj1JfYjQKUmz9Z5X/GSe64joHA=
88- APP_DEBUG : ' true'
89- APP_TIMEZONE : UTC
90- APP_URL : http://localhost
91- DB_CONNECTION : mysql
92- DB_HOST : 127.0.0.1
93- DB_PORT : 3306
94- DB_DATABASE : testing
95- DB_USERNAME : root
96- DB_PASSWORD : password
97-
107+
98108 steps :
99109 - name : Checkout code
100110 uses : actions/checkout@v4
101111
102- - name : Set up PHP
112+ - name : Set up PHP & Composer
103113 uses : shivammathur/setup-php@v2
104114 with :
105115 php-version : 8.3
106116 extensions : mbstring, pdo, mysql, bcmath, tokenizer
117+ tools : composer
107118
108- - name : Restore Composer cache
109- uses : actions/cache@v3
110- with :
111- path : vendor
112- key : ${{ runner.os }}-php-${{ hashFiles('composer.lock') }}
119+ - name : Install Composer dependencies
120+ run : composer install --no-interaction --prefer-dist
113121
114122 - name : Setup Node.js
115123 uses : actions/setup-node@v3
116124 with :
117125 node-version : 20
118126
119- - name : Restore node modules cache
120- uses : actions/cache@v3
121- with :
122- path : node_modules
123- key : ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
127+ - name : Install NPM dependencies
128+ run : npm ci
124129
125- - name : Restore Vite build cache
126- uses : actions/cache@v3
127- with :
128- path : public/build
129- key : ${{ runner.os }}-vite-${{ hashFiles('package-lock.json', 'vite.config.js') }}
130+ - name : Build assets
131+ run : npm run build
130132
131133 - name : Wait for MySQL to be ready
132134 run : |
@@ -141,44 +143,5 @@ jobs:
141143 - name : Run database migrations
142144 run : php artisan migrate --force
143145
144- run-tests :
145- runs-on : ubuntu-latest
146- needs : test-setup
147- env :
148- APP_NAME : " Computer Science Resources"
149- APP_ENV : testing
150- APP_KEY : base64:7aYe15aBsSh6a2ScVwj1JfYjQKUmz9Z5X/GSe64joHA=
151- APP_DEBUG : ' true'
152- APP_TIMEZONE : UTC
153- APP_URL : http://localhost
154- DB_CONNECTION : mysql
155- DB_HOST : 127.0.0.1
156- DB_PORT : 3306
157- DB_DATABASE : testing
158- DB_USERNAME : root
159- DB_PASSWORD : password
160-
161- steps :
162- - name : Checkout code
163- uses : actions/checkout@v4
164-
165- - name : Set up PHP
166- uses : shivammathur/setup-php@v2
167- with :
168- php-version : 8.3
169- extensions : mbstring, pdo, mysql, bcmath, tokenizer
170-
171- - name : Restore Composer cache
172- uses : actions/cache@v3
173- with :
174- path : vendor
175- key : ${{ runner.os }}-php-${{ hashFiles('composer.lock') }}
176-
177- - name : Restore Vite build cache
178- uses : actions/cache@v3
179- with :
180- path : public/build
181- key : ${{ runner.os }}-vite-${{ hashFiles('package-lock.json', 'vite.config.js') }}
182-
183- - name : Run Laravel tests
146+ - name : Run feature & unit tests
184147 run : php artisan test
0 commit comments