-
-
Notifications
You must be signed in to change notification settings - Fork 2
executable file
·295 lines (293 loc) · 12.2 KB
/
main.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: CI
on: [push, pull_request]
jobs:
build_release:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'NO_CI')"
steps:
- name: Checkout Repository
uses: actions/checkout@main
with:
fetch-depth: 1
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Cache dependencies
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node
- name: Install dependencies
run: npm install
- name: Compile CSS
run: |
npx sass Install/Application/Backend/Themes/Default/css/backend-small.scss Install/Application/Backend/Themes/Default/css/backend-small.css --style=compressed --no-source-map
npx sass Install/Application/Backend/Themes/Default/css/backend-dark.scss Install/Application/Backend/Themes/Default/css/backend-dark.css --style=compressed --no-source-map
npx sass Install/Application/Backend/Themes/Default/css/logout-small.scss Install/Application/Backend/Themes/Default/css/logout-small.css --style=compressed --no-source-map
- name: Compile JS
run: npx esbuild Install/Application/Backend/js/backend.js --bundle --outfile=Install/Application/Backend/js/backend.min.js --minify
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD -- *.{scss,css}; then echo "false"; else echo "true"; fi)
- name: Push changes
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Build Bot'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}
git add *.css
git commit -m "Automatic css build" || true
git push || true
php-tests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'NO_CI')"
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_USER: test
MYSQL_PASSWORD: orange
MYSQL_ROOT_PASSWORD: orange
MYSQL_DATABASE: omt
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:10.8
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: orange
POSTGRES_DB: omt
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
redis:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server
memcached:
image: memcached
ports:
- 11211:11211
strategy:
fail-fast: false
max-parallel: 3
matrix:
php-versions: ['8.3']
steps:
- name: Checkout Repository
uses: actions/checkout@main
with:
fetch-depth: 1
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Setup mssql
uses: potatoqualitee/[email protected]
with:
install: sqlengine, sqlpackage
version: 2017
sa-password: c0MplicatedP@ssword
show-log: true
collation: Latin1_General_BIN
- name: Run sqlcmd
run: sqlcmd -S localhost -U sa -P c0MplicatedP@ssword -Q "CREATE DATABASE oms;"
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached, sqlsrv
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
coverage: pcov
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Composer
run: composer install
- name: phpunit
run: vendor/bin/phpunit --coverage-clover tests/coverage.xml --configuration tests/phpunit_no_coverage.xml
js-tests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'NO_CI')"
steps:
- name: Checkout Repository
uses: actions/checkout@main
with:
fetch-depth: 1
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Install NPM
uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'npm'
- name: Cache dependencies
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node
- run: npm install
- name: jasmine
run: |
chmod +x ./Build/Config/jasmine_build.sh
./Build/Config/jasmine_build.sh ./jsOMS/tests
cd jsOMS
npx jasmine --config=../Build/Config/jasmine.json
cpp-tests:
if: "!contains(github.event.head_commit.message, 'NO_CI')"
strategy:
matrix:
platform: [x86, x64]
os: [ubuntu-latest]
runs-on: '${{ matrix.os }}'
name: 'cOMS Test: ${{ matrix.os }} / ${{ matrix.platform }}'
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 1
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: latest
platform: '${{ matrix.platform }}'
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install curl libcurl4-openssl-dev
- name: Run tests
run: |
chmod +x ./cOMS/tests/test.sh
./cOMS/tests/test.sh
static-tests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'NO_CI')"
strategy:
fail-fast: false
max-parallel: 3
matrix:
php-versions: ['8.3']
steps:
- name: Checkout Repository
uses: actions/checkout@main
with:
fetch-depth: 1
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Composer
run: composer install
- name: phpstan
run: vendor/bin/phpstan analyse --no-progress -l 9 -c Build/Config/phpstan.neon ./
codestyle-tests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'NO_CI')"
strategy:
fail-fast: false
max-parallel: 3
matrix:
php-versions: ['8.3']
steps:
- name: Checkout Repository
uses: actions/checkout@main
with:
fetch-depth: 1
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Composer
run: composer install
- name: phpcs
run: vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml" -s --report=full
- name: rector
run: vendor/bin/rector process --dry-run --config Build/Config/rector.php ./
- name: Install NPM
uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'npm'
- run: npm install
- name: eslint
run: npx eslint ./jsOMS -c Build/Config/.eslintrc.json
custom:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'NO_CI')"
strategy:
fail-fast: false
max-parallel: 3
matrix:
php-versions: ['8.3']
steps:
- name: Checkout Repository
uses: actions/checkout@main
with:
fetch-depth: 1
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
- name: Php strict
run: if [[ $(grep -r -L "declare(strict_types=1);" --include=*.php --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ./phpOMS ./Web ./Modules ./Model) -ne "" ]]; then exit 1; fi
- name: Html inspection
run: |
if [[ $(find ./Web ./Install ./Modules -name "*tpl.php" | xargs sed -z 's/\n/,/g;s/,$/\n/' | grep -zoP '(\<img)((?!.*?alt=).){0,1000}(\"|>|d)(>)') -ne "" ]]; then exit 1; fi
if [[ $(find ./Web ./Install ./Modules -name "*tpl.php" | xargs sed -z 's/\n/,/g;s/,$/\n/' | grep -zoP '(<input)((?!.*?type=).){0,1000}(\"|>|d)(>)') -ne "" ]]; then exit 1; fi
if [[ $(find ./Web ./Install ./Modules -name "*tpl.php" | xargs sed -z 's/\n/,/g;s/,$/\n/' | grep -zoP '(<input|<select|<textarea)((?!.*?name=).){0,1000}(\"|>|d)(>)') -ne "" ]]; then exit 1; fi
if [[ $(find ./Web ./Install ./Modules -name "*tpl.php" | xargs sed -z 's/\n/,/g;s/,$/\n/' | grep -zoP '(\<td\\>|\<th\\>|\<caption\\>|\<label.*?(\"|l)\\>)') -ne "" ]]; then exit 1; fi
# if [[ $(find ./Web ./Install ./Modules -name "*tpl.php" | xargs sed -z 's/\n/,/g;s/,$/\n/' | grep -zoP '(style=)') -ne "" ]]; then exit 1; fi
# if [[ $(find ./Web ./Install ./Modules -name "*tpl.php" | xargs sed -z 's/\n/,/g;s/,$/\n/' | grep -zoP '(value|title|alt|aria\-label)(=\")((?!\<\?).){0,1000}("|>|d)(>)') -ne "" ]]; then exit 1; fi
- name: Js inspection
run: |
if [[ $(grep -rlni "onafterprint=\|onbeforeprint=\|onbeforeunload=\|onerror=\|onhaschange=\|onload=\|onmessage=\|onoffline=\|ononline=\|onpagehide=\|onpageshow=\|onpopstate=\|onredo=\|onresize=\|onstorage=\|onund=o\|onunload=\|onblur=\|onchage=\|oncontextmenu=\|onfocus=\|onformchange=\|onforminput=\|oninput=\|oninvalid=\|onreset=\|onselect=\|onsubmit=\|onkeydown=\|onkeypress=\|onkeyup=\|onclick=\|ondblclic=k\|ondrag=\|ondragend=\|ondragenter=\|ondragleave=\|ondragover=\|ondragstart=\|ondrop=\|onmousedown=\|onmousemove=\|onmouseout=\|onmouseover=\|onmouseup=\|onmousewheel=\|onscroll=\|onabor=t\|oncanplay=\|oncanplaythrough=\|ondurationchange=\|onemptied=\|onended=\|onerror=\|onloadeddata=\|onloadedmetadata=\|onloadstart=\|onpause=\|onplay=\|onplaying=\|onprogress=\|onratechange=\|onreadystatechange=\|onseeked=\|onseeking=\|onstalled=\|onsuspend=\|ontimeupdate=\|onvolumechange=" --include=*.js ./jsOMS ./Modules ./Web) -ne "" ]]; then exit 1; fi