1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 02:34:39 +01:00
MadelineProto/tests/makephar.sh

198 lines
4.6 KiB
Bash
Raw Normal View History

2019-12-26 22:02:36 +01:00
#!/bin/bash -e
2019-06-18 12:31:44 +02:00
# Configure
PHP_MAJOR_VERSION=$(php -r 'echo PHP_MAJOR_VERSION;')
PHP_MINOR_VERSION=$(php -r 'echo PHP_MINOR_VERSION;')
2019-09-21 20:43:01 +02:00
2021-03-30 21:23:48 +02:00
BRANCH=$(git rev-parse --abbrev-ref HEAD)
TAG=$(git tag --points-at HEAD)
COMMIT_MESSAGE="$(git log -1 --pretty=%B HEAD)"
2021-03-30 21:18:38 +02:00
[ "$(git rev-list --tags --max-count=1)" == "$GITHUB_SHA" ] && IS_RELEASE=y || IS_RELEASE=n
2019-12-27 14:47:20 +01:00
echo "Is release: $IS_RELEASE"
2019-06-18 12:31:44 +02:00
# Clean up
2018-02-21 12:55:42 +01:00
rm -rf phar7 phar5 MadelineProtoPhar
madelinePath=$PWD
cd
rm -rf phar7 phar5 MadelineProtoPhar
2021-04-01 22:58:03 +02:00
mkdir phar7
2018-02-21 12:55:42 +01:00
cd phar7
2019-06-18 12:31:44 +02:00
2021-03-30 22:25:00 +02:00
[ "$IS_RELEASE" == "y" ] && composer=$BRANCH || composer="dev-$BRANCH#$GITHUB_SHA"
2020-01-19 14:29:53 +01:00
2021-03-30 21:40:46 +02:00
composer() {
php8.0 $(which composer) --no-plugins "$@"
}
2021-03-30 16:10:37 +02:00
2021-03-30 21:35:07 +02:00
php8.0 -v
2021-03-30 22:39:46 +02:00
php -v
2021-03-30 21:35:07 +02:00
2019-06-18 12:31:44 +02:00
# Install
2018-02-21 12:55:42 +01:00
echo '{
"name": "danog/madelineprototests",
"minimum-stability":"dev",
"require": {
2020-01-19 14:29:53 +01:00
"danog/madelineproto": "'$composer'",
2021-03-30 22:25:00 +02:00
"phabel/phabel": "dev-master"
},
"authors": [
{
"name": "Daniil Gentili",
"email": "daniil@daniil.it"
}
]
}' > composer.json
2021-04-05 18:29:46 +02:00
composer config platform.php "8.0"
composer clearcache
2021-04-05 17:58:35 +02:00
composer update --ignore-platform-reqs
2019-12-26 22:43:09 +01:00
cp -a $madelinePath/src vendor/danog/madelineproto
2018-02-21 12:55:42 +01:00
cd ..
2021-03-30 16:10:37 +02:00
phabel() {
2021-04-01 23:10:02 +02:00
mkdir phar5
2021-03-30 16:10:37 +02:00
cd phar7
2021-04-05 17:58:35 +02:00
composer require symfony/polyfill-php80 --ignore-platform-reqs
composer require symfony/polyfill-php74 --ignore-platform-reqs
composer require symfony/polyfill-php73 --ignore-platform-reqs
composer require symfony/polyfill-php72 --ignore-platform-reqs
composer require symfony/polyfill-php71 --ignore-platform-reqs
composer require symfony/polyfill-php70 --ignore-platform-reqs
2021-03-30 23:12:53 +02:00
rm -rf vendor/phabel/phabel/testsGenerated
2021-03-30 23:02:58 +02:00
php8.0 vendor/bin/phabel . ../phar5
2021-03-30 16:10:37 +02:00
cd ..
}
export PHABEL_TARGET="$PHP_MAJOR_VERSION$PHP_MINOR_VERSION"
php=$PHABEL_TARGET
[ $PHP_MAJOR_VERSION -eq 5 ] && {
2019-12-26 19:47:24 +01:00
cd phar7
2019-12-26 20:35:49 +01:00
ls
2019-12-26 20:05:06 +01:00
$madelinePath/tests/conversion/prepare-5.sh
2019-12-26 19:47:24 +01:00
cd ..
2021-03-30 16:10:37 +02:00
phabel
2019-12-26 19:47:24 +01:00
cd phar5
2019-12-26 20:35:49 +01:00
ls
2019-12-26 19:47:24 +01:00
$madelinePath/tests/conversion/after-5.sh
cd ..
}
[ $PHP_MAJOR_VERSION -eq 7 ] && {
2021-03-30 16:10:37 +02:00
cd phar7
2019-12-26 20:35:49 +01:00
ls
2021-03-30 16:10:37 +02:00
$madelinePath/tests/conversion/prepare-70.sh
cd ..
phabel
cd phar5
2019-12-26 20:35:49 +01:00
ls
2021-03-30 16:10:37 +02:00
$madelinePath/tests/conversion/after-70.sh
cd ..
} || {
cp -a phar7 phar5
}
2021-03-30 23:02:58 +02:00
cd phar5
2021-04-05 17:58:35 +02:00
composer dumpautoload --optimize --ignore-platform-reqs
2021-03-30 23:02:58 +02:00
cd ..
2019-06-19 11:18:51 +02:00
# Make sure conversion worked
2019-12-26 20:35:49 +01:00
# Not needed anymore, tests/testing.php preloads all classes
#for f in $(find phar5 -type f -name '*.php'); do php -l $f;done
2019-06-19 11:18:51 +02:00
2021-03-30 21:18:38 +02:00
branch="-$BRANCH"
cd $madelinePath
2019-09-21 17:11:37 +02:00
2019-06-16 21:20:29 +02:00
export TEST_SECRET_CHAT=test
export TEST_USERNAME=danogentili
2019-06-17 12:19:46 +02:00
export TEST_DESTINATION_GROUPS='["@danogentili"]'
2019-09-04 18:33:27 +02:00
export MTPROTO_SETTINGS='{"logger":{"logger_level":5}}'
2019-06-16 21:20:29 +02:00
2020-02-04 17:34:02 +01:00
runTestSimple()
{
tests/testing.php
}
runTest()
{
2021-04-05 17:58:35 +02:00
[ "$1" != "" ] && p="$1" || p=php
$p tests/testing.php <<EOF
2019-06-17 12:19:46 +02:00
m
$API_ID
$API_HASH
b
$BOT_TOKEN
n
n
n
EOF
2020-02-04 17:34:02 +01:00
}
echo "Testing with previous version..."
cp tests/testing.php tests/testingBackup.php
2021-04-05 17:58:35 +02:00
runTest php8.0
pkill -f 'MadelineProto .*'
2020-02-04 17:34:02 +01:00
echo "Testing with new version (upgrade)..."
2021-03-30 21:18:38 +02:00
php tools/makephar.php $HOME/phar5 "madeline$php$branch.phar" $GITHUB_SHA
export ACTIONS_PHAR="madeline$php$branch.phar"
2020-02-04 17:34:02 +01:00
runTestSimple
2021-04-05 17:58:35 +02:00
pkill -f 'MadelineProto .*'
2020-02-04 17:34:02 +01:00
echo "Testing with new version (restart)"
cp tests/testingBackup.php tests/testing.php
2021-04-05 17:58:35 +02:00
rm testing.madeline*
2020-02-04 17:34:02 +01:00
runTest
echo "Testing with new version (reload)"
2019-12-29 14:44:03 +01:00
cp tests/testingBackup.php tests/testing.php
2020-02-04 17:34:02 +01:00
runTestSimple
2021-04-05 17:58:35 +02:00
pkill -f 'MadelineProto .*'
echo "Testing with new version (kill+reload)"
cp tests/testingBackup.php tests/testing.php
runTestSimple
2020-02-04 17:34:02 +01:00
2021-03-30 20:57:10 +02:00
echo "Checking syntax of madeline.php"
php -l ./tools/phar.php
2019-06-16 21:20:29 +02:00
2018-02-21 12:55:42 +01:00
git clone git@github.com:danog/MadelineProtoPhar
cd MadelineProtoPhar
2019-09-04 22:16:35 +02:00
cp "../madeline$php$branch.phar" .
2019-10-28 22:39:23 +01:00
cp ../tools/phar.php ../examples/mtproxyd .
2021-03-30 21:18:38 +02:00
echo -n "$GITHUB_SHA-$php" > release$php$branch
2019-06-21 21:20:44 +02:00
2019-09-21 20:43:01 +02:00
[ "$IS_RELEASE" == "y" ] && {
2019-06-21 21:20:44 +02:00
cp release$php$branch release$php
cp madeline$php$branch.phar madeline$php.phar
}
git add -A
2021-03-30 21:18:38 +02:00
git commit -am "Release $BRANCH - $COMMIT_MESSAGE"
2021-03-30 16:10:37 +02:00
while :; do
git push origin master && break || {
git fetch
git rebase origin/master
}
done
2019-09-04 19:17:16 +02:00
2018-02-21 12:55:42 +01:00
cd ..
2021-03-30 21:18:38 +02:00
echo "$COMMIT_MESSAGE" | grep "Apply fixes from StyleCI" && exit
2018-02-20 13:15:32 +01:00
[ -d JSON.sh ] || git clone https://github.com/dominictarr/JSON.sh
2021-03-30 23:24:05 +02:00
for chat_id in $DESTINATIONS;do
2021-03-30 21:18:38 +02:00
ID=$(curl -s https://api.telegram.org/bot$BOT_TOKEN/sendMessage -F disable_web_page_preview=1 -F text=" <b>Recent Commits to MadelineProto:$BRANCH</b>
<a href=\"https://github.com/danog/MadelineProto/commit/$GITHUB_SHA\">$COMMIT_MESSAGE (PHP $PHP_MAJOR_VERSION.$PHP_MINOR_VERSION)</a>
2019-12-25 19:38:44 +01:00
2021-03-30 21:18:38 +02:00
$COMMIT_MESSAGE" -F parse_mode="HTML" -F chat_id=$chat_id | JSON.sh/JSON.sh -s | egrep '\["result","message_id"\]' | cut -f 2 | cut -d '"' -f 2)
2019-12-25 19:38:44 +01:00
2018-02-20 13:15:32 +01:00
done