-
-
Notifications
You must be signed in to change notification settings - Fork 103
240 lines (220 loc) · 9.28 KB
/
ci.yml
File metadata and controls
240 lines (220 loc) · 9.28 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: CI Weblinks
on:
push:
branches: [ main, 5.x-dev ]
pull_request:
branches: [ main, 5.x-dev ]
jobs:
composer:
runs-on: ubuntu-latest
container:
image: joomlaprojects/docker-images:php8.3
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-dependencies
phpcs:
runs-on: ubuntu-latest
needs: composer
container:
image: joomlaprojects/docker-images:php8.3
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-dependencies
- name: Run PHP CS Fixer and PHPCS
run: |
./vendor/bin/php-cs-fixer fix -vvv --dry-run --diff
./vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml src/
npm:
runs-on: ubuntu-latest
needs: phpcs
container:
image: joomlaprojects/docker-images:php8.3
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-dependencies
with:
npm-cache: 'true'
prepare_tests:
runs-on: ubuntu-latest
needs: npm
strategy:
matrix:
joomla-version: ['5.4', '6.0', '6.1', '6.2']
container:
image: joomlaprojects/docker-images:cypress8.3
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-dependencies
with:
npm-cache: 'true'
- uses: ./.github/actions/setup-cypress
- name: Determine Nightly URL for Joomla ${{ matrix.joomla-version }}
id: joomla-info
run: |
URL=$(curl -s "https://api.github.com/repos/joomla/joomla-cms/releases" | \
grep -oP '"browser_download_url":\s*"[^"]*'"${{ matrix.joomla-version }}"'[^"]*Full_Package\.zip"' | \
sed 's/"browser_download_url":\s*"//;s/"$//' | \
head -1)
if [ -z "$URL" ]; then
echo "::error::Could not find URL for version ${{ matrix.joomla-version }} in joomla/joomla-cms releases."
exit 1
fi
echo "📦 Joomla ${{ matrix.joomla-version }} URL: $URL"
echo "url=$URL" >> $GITHUB_OUTPUT
echo "url_hash=$(echo -n "$URL" | md5sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: Cache Joomla Zip
id: cache-joomla
uses: actions/cache@v5
with:
path: joomla.zip
key: joomla-core-${{ matrix.joomla-version }}-${{ steps.joomla-info.outputs.url_hash }}
- name: Download Joomla ${{ matrix.joomla-version }}
if: steps.cache-joomla.outputs.cache-hit != 'true'
run: |
echo "⬇️ Downloading from: ${{ steps.joomla-info.outputs.url }}"
curl -LfsS "${{ steps.joomla-info.outputs.url }}" -o joomla.zip
- name: Build and Verify
run: |
echo "📦 Downloaded Joomla! ${{ matrix.joomla-version }} from: ${{ steps.joomla-info.outputs.url }}"
vendor/bin/robo build
if ! unzip -t joomla.zip > /dev/null; then
unzip -t joomla.zip > /dev/null
echo "ERROR: joomla.zip is invalid or not found."
exit 1
fi
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: build-artifacts-j${{ matrix.joomla-version }}
path: |
dist/
joomla.zip
retention-days: 1
phpstan:
runs-on: ubuntu-latest
needs: prepare_tests
strategy:
matrix:
joomla-version: ['5.4', '6.0', '6.1', '6.2']
container:
image: joomlaprojects/docker-images:php8.3
steps:
- uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: build-artifacts-j${{ matrix.joomla-version }}
- uses: ./.github/actions/setup-dependencies
- name: Run PHPStan
continue-on-error: true
run: |
unzip -q joomla.zip -d joomla
./vendor/bin/phpstan analyse src --level=5 --no-progress --no-interaction
system-tests:
runs-on: ubuntu-latest
needs: [prepare_tests, phpstan]
strategy:
fail-fast: false
matrix:
joomla-version: ['5.4', '6.0', '6.1', '6.2']
php-version: ['8.2', '8.3', '8.4', '8.5']
db: [mysql, mariadb, pgsql]
include:
- db: mysql
db-type: mysqli
db-host: mysql
image: mysql:8.0
db-prefix: mysql_
alter-user-cmd: |
apt-get update && apt-get install -y default-mysql-client
mysql -h mysql -u root -proot --skip-ssl -e "ALTER USER 'joomla_ut'@'%' IDENTIFIED WITH mysql_native_password BY 'joomla_ut'; FLUSH PRIVILEGES;"
- db: mariadb
db-type: mysqli
db-host: mariadb
db-prefix: mariadb_
image: mariadb:10.4
alter-user-cmd: "apt-get update && apt-get install -y mariadb-client"
- db: pgsql
db-type: pgsql
db-host: postgres
db-prefix: pgsql_
image: postgres:12-alpine
alter-user-cmd: "apt-get update && apt-get install -y postgresql-client"
- joomla-version: '6.1'
db: mariadb
image: mariadb:10.6
- joomla-version: '6.1'
db: mariadb
image: mariadb:10.6
exclude:
- joomla-version: '5.4'
php-version: '8.5'
- joomla-version: '6.0'
php-version: '8.2'
- joomla-version: '6.1'
php-version: '8.2'
- joomla-version: '6.2'
php-version: '8.2'
container:
image: joomlaprojects/docker-images:cypress${{ matrix.php-version }}
services:
mysql:
image: ${{ matrix.db == 'mysql' && matrix.image || 'mysql:8.0' }}
env:
MYSQL_ROOT_PASSWORD: ${{ matrix.db == 'mysql' && 'root' || 'unused' }}
MYSQL_USER: ${{ matrix.db == 'mysql' && 'joomla_ut' || 'unused' }}
MYSQL_PASSWORD: ${{ matrix.db == 'mysql' && 'joomla_ut' || 'unused' }}
MYSQL_DATABASE: ${{ matrix.db == 'mysql' && 'test_joomla' || 'unused' }}
mariadb:
image: ${{ matrix.db == 'mariadb' && matrix.image || 'mariadb:10.4' }}
env:
MARIADB_ROOT_PASSWORD: ${{ matrix.db == 'mariadb' && 'root' || 'unused' }}
MARIADB_USER: ${{ matrix.db == 'mariadb' && 'joomla_ut' || 'unused' }}
MARIADB_PASSWORD: ${{ matrix.db == 'mariadb' && 'joomla_ut' || 'unused' }}
MARIADB_DATABASE: ${{ matrix.db == 'mariadb' && 'test_joomla' || 'unused' }}
postgres:
image: ${{ matrix.db == 'pgsql' && 'postgres:12-alpine' || 'postgres:12-alpine' }}
env:
POSTGRES_USER: ${{ matrix.db == 'pgsql' && 'root' || 'unused' }}
POSTGRES_PASSWORD: ${{ matrix.db == 'pgsql' && 'root' || 'unused' }}
POSTGRES_DB: ${{ matrix.db == 'pgsql' && 'test_joomla' || 'unused' }}
steps:
- uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: build-artifacts-j${{ matrix.joomla-version }}
- uses: ./.github/actions/setup-dependencies
with:
npm-cache: 'true'
- name: Extract Joomla
run: unzip -q joomla.zip -d joomla
- uses: ./.github/actions/setup-cypress
- name: Setup and run ${{ matrix.db }}
run: |
${{ matrix.alter-user-cmd }}
DB_USER=${{ matrix.db == 'pgsql' && 'root' || 'joomla_ut' }}
DB_PASS=${{ matrix.db == 'pgsql' && 'root' || 'joomla_ut' }}
cp -r joomla /tests/www/${{ matrix.db }}
cp dist/pkg-weblinks-current.zip /tests/www/${{ matrix.db }}/
cd /tests/www/${{ matrix.db }}/
apache2ctl -D FOREGROUND &
php installation/joomla.php install --verbose --site-name="Joomla test" --admin-email=admin@example.org --admin-username=ci-admin --admin-user="jane doe" --admin-password=joomla-17082005 --db-type=${{ matrix.db-type }} --db-host=${{ matrix.db-host }} --db-name=test_joomla --db-pass=$DB_PASS --db-user=$DB_USER --db-encryption=0 --db-prefix=${{ matrix.db-prefix }}
php cli/joomla.php extension:install --path=/tests/www/${{ matrix.db }}/pkg-weblinks-current.zip
mkdir -p tmp/api_rate_limit tmp/plg_system_ratelimit
chown -R www-data:www-data /tests/www/${{ matrix.db }}/
chmod -R 777 /tests/www/${{ matrix.db }}/
echo "=== Test Environment ==="
php cli/joomla.php --version | head -1
php -v | head -1
[ "${{ matrix.db }}" = "pgsql" ] && psql -h ${{ matrix.db-host }} -U $DB_USER -d test_joomla -t -c 'SELECT version();' | head -1 | xargs || mysql -h ${{ matrix.db-host }} -u $DB_USER -p$DB_PASS --skip-ssl -e 'SELECT VERSION();' -s -N
echo "========================"
cd $GITHUB_WORKSPACE
npx cypress run --browser=chrome --e2e --config video=false --expose cmsPath=/tests/www/${{ matrix.db }},db_type=${{ matrix.db-type }},db_host=${{ matrix.db-host }},db_name=test_joomla,db_user=$DB_USER,db_password=$DB_PASS,db_prefix=${{ matrix.db-prefix }},logFile=/var/log/apache2/error.log --config baseUrl=http://localhost/${{ matrix.db }}
- name: Upload Screenshots on Failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots-j${{ matrix.joomla-version }}-${{ matrix.db }}-php${{ matrix.php-version }}
path: tests/cypress/output/screenshots
retention-days: 7