Merge branch 'develop' of https://github.com/Karaka-Management/Karaka… #1122
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |