Skip to content

Commit

Permalink
Merge pull request #16 from joanhey/gh-action
Browse files Browse the repository at this point in the history
Github action to test the setup and frameworks
  • Loading branch information
myaaghubi committed Jul 23, 2023
2 parents 5450155 + a821d4d commit 05ff7de
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 9 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test PHP benchmark
on: [ push, pull_request ]

jobs:
setup:
name: Check PHP frameworks
runs-on: ubuntu-22.04

steps:

- uses: actions/checkout@v3

- name: Install WRK
run: sudo apt-get install wrk w3m

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, ctype, iconv, intl
coverage: none

- name: Install Apache mod_php
run: |
LC_ALL=C.UTF-8 sudo apt-add-repository http://ppa.launchpad.net/ondrej/php/ubuntu
sudo apt install libapache2-mod-php8.2
sudo a2enmod php8.2 rewrite
shell: bash

- name: Setup frameworks
run: bash setup.sh

- name: Copy files to web root
run: |
sudo mkdir /var/www/html/PHP-Frameworks-Bench
sudo cp -R ./* /var/www/html/PHP-Frameworks-Bench/
sudo chown -R www-data:www-data /var/www/html
- name: Restart apache server
run: sudo service apache2 restart

- name: Check frameworks
run: bash check.sh

28 changes: 23 additions & 5 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,38 @@
. ./benchmark.config
. ./base/option_target.sh

OK='\U2714'
ERROR='\U274C'

GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color

FAIL=0

for fw in `echo $param_targets`
do
if [ -d "$fw" ]; then
echo -n "/------- $fw: checking... "
. "$fw/_benchmark/hello_world.sh"

url_output=$(curl -s "$url")

# expected to get the Hello World! + libs/output_data.php
if ! [[ "$url_output" =~ ^('Hello World!')(.*)(([0-9]*):(([0-9]+([.][0-9]*)?|[.][0-9]+)):([0-9]*))$ ]]; then
echo -e "error: \n$url"
echo "$url_output"
echo -e "${RED}${ERROR} $fw ${NC}"
echo "$url"

if [ -x "$(command -v w3m)" ]; then
echo "$url_output" | w3m -dump -T text/html
else
echo "$url_output"
fi

FAIL=1
else
echo "done."
echo -e "${GREEN}${OK} $fw ${NC}"
fi
fi
done
done

exit $FAIL
Empty file.
4 changes: 2 additions & 2 deletions laravel-10.0/_benchmark/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ yes|cp -rf _benchmark/laravel/. ./
# some enhancements
composer install --optimize-autoloader --no-dev
chmod o+w storage/*
sudo chmod o+w storage/framework/*
php artisan optimize
chmod o+w storage/framework/*
#php artisan optimize
rm ./public/.htaccess
4 changes: 2 additions & 2 deletions laravel-10.0/_benchmark/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ yes|cp -rf _benchmark/laravel/. ./
# some enhancements
composer install --optimize-autoloader --no-dev
chmod o+w storage/*
sudo chmod o+w storage/framework/*
php artisan optimize
chmod o+w storage/framework/*
#php artisan optimize
rm ./public/.htaccess

0 comments on commit 05ff7de

Please sign in to comment.