mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
158 lines
5.1 KiB
YAML
158 lines
5.1 KiB
YAML
name: Cypress
|
|
on:
|
|
pull_request:
|
|
branches: [develop]
|
|
push:
|
|
branches: [develop]
|
|
|
|
jobs:
|
|
cypress:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
mysql:
|
|
image: mysql:8.0
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: root
|
|
MYSQL_DATABASE: myaac
|
|
MYSQL_USER: myaac
|
|
MYSQL_PASSWORD: myaac
|
|
ports:
|
|
- 3306/tcp
|
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
php-versions: [ '8.1', '8.2', '8.3' ]
|
|
ots: ['tfs-1.4', 'canary-3.1.2'] # TODO: add 'tfs-master' (actually doesn't work cause AAC doesn't support reading .env configuration)
|
|
name: Cypress on PHP ${{ matrix.php-versions }} - ${{ matrix.ots }}
|
|
steps:
|
|
- name: 📌 MySQL Start & init & show db
|
|
run: |
|
|
sudo /etc/init.d/mysql start
|
|
mysql -e 'CREATE DATABASE myaac;' -uroot -proot
|
|
mysql -e "SHOW DATABASES" -uroot -proot
|
|
|
|
- name: Checkout MyAAC
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: develop
|
|
|
|
- name: Checkout TFS
|
|
uses: actions/checkout@v4
|
|
if: matrix.ots == 'tfs-1.4'
|
|
with:
|
|
repository: otland/forgottenserver
|
|
ref: 1.4
|
|
path: ots
|
|
|
|
- name: Checkout TFS
|
|
uses: actions/checkout@v4
|
|
if: matrix.ots == 'tfs-master'
|
|
with:
|
|
repository: otland/forgottenserver
|
|
ref: master
|
|
path: ots
|
|
|
|
- name: Checkout Canary
|
|
uses: actions/checkout@v4
|
|
if: matrix.ots == 'canary-3.1.2'
|
|
with:
|
|
repository: opentibiabr/canary
|
|
ref: v3.1.2
|
|
path: ots
|
|
|
|
- name: Import OTS Schema
|
|
run: |
|
|
mysql -uroot -proot myaac < ots/schema.sql
|
|
|
|
- name: Rename config.lua
|
|
run: mv ots/config.lua.dist ots/config.lua
|
|
|
|
- name: Replace mysqlUser (TFS 1.4)
|
|
uses: jacobtomlinson/gha-find-replace@v3
|
|
if: matrix.ots == 'tfs-1.4'
|
|
with:
|
|
find: 'mysqlUser = "forgottenserver"'
|
|
replace: 'mysqlUser = "root"'
|
|
regex: false
|
|
include: 'ots/config.lua'
|
|
|
|
- name: Replace mysqlPass (TFS 1.4)
|
|
uses: jacobtomlinson/gha-find-replace@v3
|
|
if: matrix.ots == 'tfs-1.4'
|
|
with:
|
|
find: 'mysqlPass = ""'
|
|
replace: 'mysqlPass = "root"'
|
|
regex: false
|
|
include: 'ots/config.lua'
|
|
|
|
- name: Replace mysqlDatabase (TFS 1.4)
|
|
uses: jacobtomlinson/gha-find-replace@v3
|
|
if: matrix.ots == 'tfs-1.4'
|
|
with:
|
|
find: 'mysqlDatabase = "forgottenserver"'
|
|
replace: 'mysqlDatabase = "myaac"'
|
|
regex: false
|
|
include: 'ots/config.lua'
|
|
|
|
- name: Replace mysqlDatabase (Canary)
|
|
uses: jacobtomlinson/gha-find-replace@v3
|
|
if: matrix.ots == 'canary-3.1.2'
|
|
with:
|
|
find: 'mysqlDatabase = "otservbr-global"'
|
|
replace: 'mysqlDatabase = "myaac"'
|
|
regex: false
|
|
include: 'ots/config.lua'
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ matrix.php-versions }}
|
|
extensions: mbstring, dom, fileinfo, mysql, json, xml, pdo, pdo_mysql
|
|
|
|
- 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-${{ hashFiles('**/composer.json') }}
|
|
|
|
- name: Install Composer dependencies
|
|
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
|
|
|
- name: Run PHP server
|
|
run: nohup php -S localhost:8080 > php.log 2>&1 &
|
|
|
|
- name: Cypress Run
|
|
uses: cypress-io/github-action@v6
|
|
env:
|
|
CYPRESS_URL: http://localhost:8080
|
|
CYPRESS_SERVER_PATH: /home/runner/work/myaac/myaac/ots
|
|
|
|
- name: Save screenshots
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: cypress-screenshots-${{ matrix.php-versions }}-${{ matrix.ots }}
|
|
path: cypress/screenshots
|
|
|
|
- name: Upload Cypress Videos
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: cypress-videos-${{ matrix.php-versions }}-${{ matrix.ots }}
|
|
path: cypress/videos
|
|
|
|
- name: Upload PHP Logs
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: php-log-${{ matrix.php-versions }}-${{ matrix.ots }}
|
|
path: php.log
|