-
Notifications
You must be signed in to change notification settings - Fork 286
134 lines (120 loc) · 4.62 KB
/
test-countries.yml
File metadata and controls
134 lines (120 loc) · 4.62 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
name: PHPUnit Tests - Country Configurations
on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
env:
DB_NAME: facturascripts_test
DB_USER: root
DB_PASS: root
DB_HOST: 127.0.0.1
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
country:
- code: COL
name: Colombia
lang: es_CO
timezone: America/Bogota
- code: DOM
name: Dominican Republic
lang: es_DO
timezone: America/Santo_Domingo
- code: ECU
name: Ecuador
lang: es_EC
timezone: America/Guayaquil
- code: GTM
name: Guatemala
lang: es_GT
timezone: America/Guatemala
- code: MEX
name: Mexico
lang: es_MX
timezone: America/Mexico_City
database:
- type: mysql
version: '8.0'
port: 3306
fail-fast: false
name: ${{ matrix.country.name }} (${{ matrix.country.code }}) - ${{ matrix.database.type }} ${{ matrix.database.version }}
services:
mysql:
image: mysql:${{ matrix.database.version }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: facturascripts_test
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Setup PHP 8.3
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: bcmath, curl, gd, iconv, mysqli, pdo_mysql, pdo_pgsql, pgsql, soap, zip, fileinfo, openssl, simplexml, mbstring, intl
coverage: xdebug
tools: composer:v2
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest --optimize-autoloader
- name: Verify database connection
run: |
echo "Testing ${{ matrix.database.type }} ${{ matrix.database.version }} connection..."
mysql --host=${{ env.DB_HOST }} --user=${{ env.DB_USER }} --password=${{ env.DB_PASS }} -e "SHOW DATABASES;"
mysql --host=${{ env.DB_HOST }} --user=${{ env.DB_USER }} --password=${{ env.DB_PASS }} -e "SELECT VERSION();"
- name: Create application config for ${{ matrix.country.name }}
run: |
cat > config.php << 'EOF'
<?php
define('FS_COOKIES_EXPIRE', 31536000);
define('FS_ROUTE', '');
define('FS_DB_TYPE', 'mysql');
define('FS_DB_HOST', '${{ env.DB_HOST }}');
define('FS_DB_PORT', 3306);
define('FS_DB_NAME', '${{ env.DB_NAME }}');
define('FS_DB_USER', '${{ env.DB_USER }}');
define('FS_DB_PASS', '${{ env.DB_PASS }}');
define('FS_DB_FOREIGN_KEYS', true);
define('FS_DB_TYPE_CHECK', true);
define('FS_MYSQL_CHARSET', 'utf8mb4');
define('FS_MYSQL_COLLATE', 'utf8mb4_unicode_520_ci');
define('FS_LANG', '${{ matrix.country.lang }}');
define('FS_TIMEZONE', '${{ matrix.country.timezone }}');
define('FS_INITIAL_CODPAIS', '${{ matrix.country.code }}');
define('FS_HIDDEN_PLUGINS', '');
define('FS_DEBUG', true);
define('FS_DISABLE_ADD_PLUGINS', false);
define('FS_DISABLE_RM_PLUGINS', false);
EOF
echo "Configuration created for ${{ matrix.country.name }} (${{ matrix.country.code }})"
echo "Language: ${{ matrix.country.lang }}"
echo "Timezone: ${{ matrix.country.timezone }}"
- name: Run PHPUnit tests for ${{ matrix.country.name }}
run: |
echo "Running tests with ${{ matrix.country.name }} configuration..."
if [ -f phpunit.xml ] || [ -f phpunit.xml.dist ]; then
vendor/bin/phpunit --coverage-text --coverage-clover=coverage-${{ matrix.country.code }}.xml
else
echo "No PHPUnit configuration found. Running with default settings..."
vendor/bin/phpunit --bootstrap vendor/autoload.php tests/
fi