-
Notifications
You must be signed in to change notification settings - Fork 130
241 lines (230 loc) · 10.1 KB
/
codeigniter.yml
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
241
# GitHub Action for CodeIgniter
name: Testing Kalkun
on:
push:
branches:
- master
- devel
- 'release-**'
- 'feature-**'
pull_request:
branches: [ master, devel ]
jobs:
required_php_versions:
name: Get PHP versions to test
runs-on: ubuntu-latest
outputs:
php_versions: ${{ steps.php_ver_step.outputs.PHP_VERSIONS }}
php_versions_matrix: ${{ steps.php_ver_step.outputs.PHP_VERSIONS_matrix }}
steps:
- name: Install required packages
run: |
if ! command -v jq; then sudo apt-get update && sudo apt-get install -y jq; fi
- name: Build PHP_VERSIONS array & PHP_VERSIONS_matrix
id: php_ver_step
run: |
set -x
# Set array that will store the PHP versions for which we create a package.
PHP_VERSIONS=()
# Get all released php versions above 5.6 (in the format X.Y)
for upstream_ver in $(curl https://www.php.net/releases/?json | jq -r '.[].version' | cut -f -2 -d .); do
major=$(cut -f 1 -d . <<< "$upstream_ver")
for minor in {0..20}; do
if dpkg --compare-versions ${major}.$minor le $upstream_ver && dpkg --compare-versions ${major}.$minor ge 5.6; then
PHP_VERSIONS+=("${major}.$minor")
fi
done
done
PHP_VERSIONS_matrix=$(sed 's/\ /", "/g' <<< [\"${PHP_VERSIONS[*]}\"])
echo "PHP_VERSIONS=${PHP_VERSIONS[*]}" >> "$GITHUB_OUTPUT"
echo "PHP_VERSIONS_matrix=$PHP_VERSIONS_matrix" >> "$GITHUB_OUTPUT"
echo "PHP_VERSIONS=${PHP_VERSIONS[*]}"
echo "PHP_VERSIONS_matrix=$PHP_VERSIONS_matrix"
test:
continue-on-error: false
needs: [ required_php_versions ]
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
#php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php-versions: ${{fromJson(needs.required_php_versions.outputs.php_versions_matrix)}}
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, curl, dom
coverage: xdebug #optional
- name: Setup MySQL
uses: mirromutth/[email protected]
with:
character set server: 'utf8' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld
collation server: 'utf8_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld
mysql version: '5.7' # Optional, default value is "latest". The version of the MySQL
mysql database: 'kalkun' # Optional, default value is "test". The specified database which will be create
mysql root password: password # Required if "mysql user" is empty, default is empty. The root superuser password
- 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@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: |
composer update
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Verify mysql connection
run: |
while ! mysqladmin ping -h"127.0.0.1" -P"3306" --silent; do
sleep 1
done
- name: Download Gammu DB Schema
uses: wei/wget@v1
with:
args: -O gammu.sql https://raw.githubusercontent.com/gammu/gammu/master/docs/sql/mysql.sql
- name: Import Gammu DB Schema
run: mysql -h"127.0.0.1" -P"3306" -uroot -ppassword kalkun < gammu.sql
- name: Install/Update ci-phpunit-test
run: |
php vendor/kenjis/ci-phpunit-test/install.php --from-composer
# Workaround a bug in phpunit < 7 where the absence of application/tests/_ci_phpunit_test/ makes it fail
# with strpos(): Empty needle in vendor/phpunit/php-file-iterator/src/Iterator.php
if ! vendor/bin/phpunit --atleast-version 7; then
mkdir -vp application/tests/_ci_phpunit_test
# Below the alternative is to remove the culprit line from phpunit.xml
#sed -i -e "/<exclude>.\/_ci_phpunit_test\/<\/exclude>/ d" application/tests/phpunit.xml
fi
# Uncomment the monkey patcher function. This will search the line matching "Enabling Monkey Patching"
# then search the next "/*", delete that line, search the next "*/" and delete the line, write, and quit.
ed -s application/tests/Bootstrap.php <<EOF
/Enabling Monkey Patching/
/^\/\*$/
n
d
/^\*\/$/
n
d
w
q
EOF
rm application/tests/controllers/Welcome_test.php
# exlude the full application/view dir from coverage, otherwise coverage would fail.
# See: https://github.com/kenjis/ci-phpunit-test/issues/412
sed -i -e 's|<directory suffix=".php">../views/errors</directory>|<directory suffix=".php">../views</directory>|' application/tests/phpunit.xml
# the void return type of setUp() methods in phpunit (required since phpunit8) isn't supported
# with phpunit <= 6. For these, we remove the ": void" part of the tests
if [ $(composer show phpunit/phpunit | grep "^versions : " | rev | cut -d " " -f 1 | rev | cut -d . -f 1) -le 6 ]; then
sed -i "/public function setUp()/ s/ : void$//" application/tests/controllers/Install_test.php
fi
- name: Test with phpunit
run: vendor/bin/phpunit --coverage-text -c application/tests
check-code:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.2']
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, curl, dom
coverage: xdebug #optional
- 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@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: |
composer update --working-dir=utils
composer install --working-dir=utils --no-progress --prefer-dist --optimize-autoloader
sudo apt-get update
# html-beautify from the debian package doesn't work for some reason
# sudo apt-get install -y node-js-beautify
# Install npm and install js-beautify from there
sudo apt-get install -y npm
sudo npm update --verbose -g npm
sudo npm install --verbose -g js-beautify
- id: check_strict_comparison
name: Check that strict comparison operators are used everywhere
run: |
#git checkout utils/composer.lock
git status
utils/fix_code_style.sh strict
- id: check_style
name: Check that code follows Guidelines
if: always()
run: |
#git checkout utils/composer.lock
git status
utils/fix_code_style.sh git-diff
- name: Archive artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: Code style issues to fix
path: 'code_style_check*'
if-no-files-found: ignore
check-translation:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.2']
runs-on: ${{ matrix.operating-system }}
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, curl, dom
coverage: xdebug #optional
- 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@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: |
composer update
composer install --no-progress --prefer-dist --optimize-autoloader
- id: translation
name: Check translations
run: |
mkfifo pipe
tee translation_check_output.txt < pipe &
./utils/check_translation.php all > pipe
- name: Archive artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: Translation check output
path: 'translation_check_output.*'
if-no-files-found: ignore