-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (144 loc) · 5.53 KB
/
tests.yaml
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Tests
on:
workflow_call:
pull_request_target:
types:
- opened
- synchronize # optional to react on PR updates
branches:
- develop
- main
env:
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
# See https://github.com/cc-fiae-2024/cc-fiae-2024/settings/secrets/actions
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_DATABASE: testing
jobs:
build:
uses: './.github/workflows/build.yaml'
php-tests:
needs: [ build ]
# See https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/choosing-the-runner-for-a-job#standard-github-hosted-runners-for-public-repositories
runs-on: ubuntu-24.04
environment: testing
strategy:
matrix:
operating-system: [ ubuntu-24.04 ]
# Limited by https://github.com/shivammathur/setup-php#github-hosted-runners
php-version: [ '8.2', '8.3', '8.4' ]
dependency-stability: [ prefer-stable ]
name: php-tests - PHP ${{ matrix.php-version }} (${{ matrix.operating-system }})
steps:
- name: Checkout code
uses: actions/checkout@v4.1.7
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Start MySQL service & create testing database
run: |
sudo systemctl start mysql.service
mysql -e "CREATE DATABASE IF NOT EXISTS $DB_DATABASE;" -u"$DB_USER" -p"$DB_PASSWORD"
- name: Install PHP
uses: shivammathur/setup-php@2.31.1
with:
php-version: ${{ matrix.php-version }}
- name: Download build artifact
id: download-build-artifact
uses: actions/download-artifact@v4.1.8
with:
# Pick up the folder from build.yaml Upload (name must match)
name: eventguru-build-${{ github.run_id }}
path: public/build
- name: Restore vendor from Cache
uses: actions/cache@v4.0.2
id: vendor-cache
with:
path: vendor
key: ${{ runner.OS }}-build-php${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
- name: Prepare Laravel Application
run: |
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
- name: Run Migrations
run: php artisan migrate
- name: Execute tests (Unit and Feature tests) via PestPHP
run: php artisan test
php-browser-tests:
needs: [ build ]
# See https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/choosing-the-runner-for-a-job#standard-github-hosted-runners-for-public-repositories
runs-on: ubuntu-24.04
environment: testing
env:
APP_LOCALE: de
APP_URL: "http://127.0.0.1:8000"
MAIL_MAILER: log
strategy:
matrix:
operating-system: [ ubuntu-24.04 ]
# Limited by https://github.com/shivammathur/setup-php#github-hosted-runners
php-version: [ '8.2', '8.3', '8.4' ]
dependency-stability: [ prefer-stable ]
name: php-browser-tests - PHP ${{ matrix.php-version }} (${{ matrix.operating-system }})
steps:
- name: Checkout code
uses: actions/checkout@v4.1.7
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Start MySQL service & create testing database
run: |
sudo systemctl start mysql.service
mysql -e "CREATE DATABASE IF NOT EXISTS $DB_DATABASE;" -u"$DB_USER" -p"$DB_PASSWORD"
- name: Install PHP
uses: shivammathur/setup-php@2.31.1
with:
php-version: ${{ matrix.php-version }}
- name: Download build artifact
id: download-build-artifact
uses: actions/download-artifact@v4.1.8
with:
# Pick up the folder from build.yaml Upload (name must match)
name: eventguru-build-${{ github.run_id }}
path: public/build
- name: Restore vendor from Cache
uses: actions/cache@v4.0.2
id: vendor-cache
with:
path: vendor
key: ${{ runner.OS }}-build-php${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
- name: Prepare Laravel Application
run: |
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
- name: Run Migrations
run: php artisan migrate
# Install the Chrome binaries required for Dusk to run tests
- name: Install Chrome binaries
run: php artisan dusk:chrome-driver --detect
# Start the Chrome driver so we're able to run browser tests with Chrome
- name: Start Chrome Driver
run: ./vendor/laravel/dusk/bin/chromedriver-linux --port=9515 &
# Start a basic Laravel server with no reloading
- name: Run Laravel Server
run: php artisan serve --no-reload &
# Run our Dusk test suite. This could be different if you don't use Pest (e.g. php artisan dusk)
- name: Execute tests
run: php artisan dusk
# If there's a failure, upload the Dusk screenshots as an artifact
- name: Upload Screenshots
if: failure()
uses: actions/upload-artifact@v4.4.0
with:
name: screenshots-${{ github.run_id }}-${{ matrix.php-version }}
path: tests/Browser/screenshots
retention-days: 7
# If there's a failure, upload the Dusk console logs as an artifact
- name: Upload Console Logs
if: failure()
uses: actions/upload-artifact@v4.4.0
with:
name: console-${{ github.run_id }}-${{ matrix.php-version }}
path: tests/Browser/console
retention-days: 7