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

224 lines
4.7 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
2023-05-31 12:23:26 +02:00
echo >> /usr/local/etc/php/php.ini
echo 'phar.readonly = 0' >> /usr/local/etc/php/php.ini
2023-05-28 19:41:46 +02:00
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer
2023-05-31 12:33:24 +02:00
apk add procps git unzip github-cli openssh
2021-10-24 19:24:25 +02:00
2024-07-21 16:25:10 +02:00
git config --global --add safe.directory $PWD
2023-11-17 18:45:52 +01:00
echo "$CI_COMMIT_TAG" | grep -q '\.9999' && exit 0 || true
echo "$CI_COMMIT_TAG" | grep -q '\.9998' && exit 0 || true
2022-06-04 21:23:34 +02:00
PHP_MAJOR_VERSION=$(php -r 'echo PHP_MAJOR_VERSION;')
PHP_MINOR_VERSION=$(php -r 'echo PHP_MINOR_VERSION;')
2021-09-05 00:12:42 +02:00
php=$PHP_MAJOR_VERSION$PHP_MINOR_VERSION
2019-09-21 20:43:01 +02:00
2021-12-03 19:24:56 +01:00
COMMIT="$(git log -1 --pretty=%H)"
BRANCH=$(git rev-parse --abbrev-ref HEAD)
COMMIT_MESSAGE="$(git log -1 --pretty=%B HEAD)"
2019-12-27 14:47:20 +01:00
2022-06-04 18:25:44 +02:00
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "Github Actions"
2023-11-17 18:45:52 +01:00
if [ "$CI_COMMIT_TAG" == "" ]; then
2023-11-17 18:53:12 +01:00
export CI_COMMIT_TAG=7777
2023-11-17 18:45:52 +01:00
git tag "$CI_COMMIT_TAG"
git checkout "$CI_COMMIT_TAG"
2022-06-23 15:01:22 +02:00
fi
2023-11-17 18:45:52 +01:00
if [ "$CI_COMMIT_TAG" != "7777" ]; then
grep -q "const RELEASE = '$CI_COMMIT_TAG'" src/API.php || {
2023-05-29 15:10:42 +02:00
echo "The RELEASE constant is not up to date!"
exit 1
}
fi
2022-11-07 15:00:06 +01:00
export TEST_SECRET_CHAT=test
export TEST_USERNAME=danogentili
export TEST_DESTINATION_GROUPS='["@danogentili"]'
export MTPROTO_SETTINGS='{"logger":{"logger_level":5}}'
2021-10-24 19:24:25 +02:00
echo "PHP: $php"
2021-09-04 18:07:22 +02:00
echo "Branch: $BRANCH"
echo "Commit: $COMMIT"
2023-11-17 18:45:52 +01:00
echo "Latest tag: $CI_COMMIT_TAG"
2021-04-05 22:54:08 +02:00
2019-06-18 12:31:44 +02:00
# Clean up
madelinePath=$PWD
2021-12-03 19:24:56 +01:00
dd if=/dev/random of=tests/60 bs=1M count=60
2021-12-25 13:13:24 +01:00
k()
{
while :; do pkill -f "MadelineProto worker $(pwd)/tests/../testing.madeline" || break && sleep 1; done
}
k
2023-03-26 20:10:51 +02:00
rm -rf madeline.phar testing.madeline*
2021-12-03 19:24:56 +01:00
2022-11-07 15:00:06 +01:00
composer update
2023-08-05 23:34:40 +02:00
#composer test
2022-11-07 15:54:43 +01:00
#vendor/bin/phpunit tests/danog/MadelineProto/EntitiesTest.php
2020-01-19 14:29:53 +01:00
2023-11-17 18:45:52 +01:00
COMPOSER_TAG="$CI_COMMIT_TAG"
2022-10-08 18:35:42 +02:00
2022-05-01 01:54:49 +02:00
rm -rf vendor*
git reset --hard
2022-10-08 18:44:22 +02:00
git checkout "$COMPOSER_TAG"
2021-09-04 17:42:31 +02:00
2021-09-04 17:22:45 +02:00
cd ..
rm -rf phar
mkdir phar
2021-03-30 16:10:37 +02:00
2021-09-04 17:22:45 +02:00
cd phar
2021-03-30 21:35:07 +02:00
2019-06-18 12:31:44 +02:00
# Install
2023-01-20 18:05:29 +01:00
2023-03-09 14:19:33 +01:00
mkdir -p ~/.composer
2023-01-20 18:13:59 +01:00
echo '{"github-oauth": {"github.com": "'$GITHUB_TOKEN'"}}' > ~/.composer/auth.json
2023-01-20 18:05:29 +01:00
2018-02-21 12:55:42 +01:00
echo '{
2021-09-04 17:22:45 +02:00
"name": "danog/madelineprotophar",
"require": {
2023-01-21 21:47:35 +01:00
"danog/madelineproto": "'$COMPOSER_TAG'"
},
"authors": [
{
"name": "Daniil Gentili",
"email": "daniil@daniil.it"
}
2021-09-04 17:22:45 +02:00
],
2024-04-06 20:08:14 +02:00
"config": {
"allow-plugins": {
"symfony/thanks": true
}
2024-04-06 20:11:37 +02:00
},
2021-09-04 17:22:45 +02:00
"repositories": [
{
"type": "path",
2021-09-04 18:16:00 +02:00
"url": "'$madelinePath'",
2022-06-04 18:03:51 +02:00
"options": {"symlink": false}
2021-09-04 17:22:45 +02:00
}
2022-11-04 14:16:30 +01:00
]
}' > composer.json
2023-01-20 18:02:03 +01:00
php $(which composer) update --no-cache
2021-10-24 19:27:04 +02:00
php $(which composer) dumpautoload --optimize
2022-11-04 14:16:30 +01:00
rm -rf vendor/danog/madelineproto/docs vendor/danog/madelineproto/vendor-bin
2023-01-27 19:30:08 +01:00
mkdir -p vendor/danog/madelineproto/src/danog/MadelineProto/Ipc/Runner
cp vendor/danog/madelineproto/src/Ipc/Runner/entry.php vendor/danog/madelineproto/src/danog/MadelineProto/Ipc/Runner
2021-03-30 23:02:58 +02:00
2021-03-30 21:18:38 +02:00
branch="-$BRANCH"
cd $madelinePath
2019-09-21 17:11:37 +02:00
2022-06-23 14:37:54 +02:00
db()
{
2023-05-27 12:03:09 +02:00
php tests/db.php $1 $2
2022-06-23 14:37:54 +02:00
}
cycledb()
{
2023-05-27 12:03:09 +02:00
for f in serialize igbinary; do
db memory $f
db mysql $f
db postgres $f
db redis $f
db memory $f
done
2022-06-23 14:37:54 +02:00
}
2023-01-15 21:35:33 +01:00
runTestSimple()
2020-02-04 17:34:02 +01:00
{
2023-03-17 20:54:04 +01:00
{
echo "n
n
n
"; } | tests/testing.php
2020-02-04 17:34:02 +01:00
}
2023-01-15 21:35:33 +01:00
runTest()
{
{
2023-06-18 21:02:43 +02:00
echo "$BOT_TOKEN
2023-01-15 21:35:33 +01:00
n
n
n
"; } | $p tests/testing.php
}
2023-06-19 01:15:22 +02:00
runTestOld()
{
{
echo "b
$BOT_TOKEN
n
n
n
"; } | $p tests/testing.php
}
2020-02-04 17:34:02 +01:00
2021-06-11 20:38:39 +02:00
k
2021-04-06 17:21:03 +02:00
rm -f madeline.phar testing.madeline*
2021-04-06 00:11:32 +02:00
tail -F MadelineProto.log &
2024-04-07 00:06:16 +02:00
tail -F tests/MadelineProto.log &
2023-08-13 16:57:42 +02:00
2020-02-04 17:34:02 +01:00
echo "Testing with previous version..."
2022-07-26 19:47:57 +02:00
export ACTIONS_FORCE_PREVIOUS=1
cp tools/phar.php madeline.php
2023-06-19 10:24:36 +02:00
runTest
2023-05-27 12:03:09 +02:00
db mysql serialize
2022-07-26 19:47:57 +02:00
k
2023-08-13 16:57:42 +02:00
2020-02-04 17:34:02 +01:00
echo "Testing with new version (upgrade)..."
2023-05-27 01:22:26 +02:00
rm -f madeline-*phar madeline.version
2023-05-27 01:06:31 +02:00
2022-12-29 21:48:37 +01:00
php tools/makephar.php $madelinePath/../phar "madeline$php$branch.phar" "$COMMIT-81"
2023-05-27 01:22:26 +02:00
cp "madeline$php$branch.phar" "madeline-TESTING.phar"
echo -n "TESTING" > "madeline.version"
2023-05-27 00:57:50 +02:00
echo 0.0.0.0 phar.madelineproto.xyz > /etc/hosts
cp tools/phar.php madeline.php
2021-09-06 16:52:05 +02:00
export ACTIONS_PHAR=1
2023-08-13 16:57:42 +02:00
runTestSimple
#runTest
2022-06-25 19:29:01 +02:00
cycledb
2021-12-15 12:47:10 +01:00
k
2020-02-04 17:34:02 +01:00
echo "Testing with new version (restart)"
2023-03-26 20:10:51 +02:00
rm -rf testing.madeline || echo
2020-02-04 17:34:02 +01:00
runTest
echo "Testing with new version (reload)"
2023-01-15 21:35:33 +01:00
runTestSimple
2021-04-07 18:58:25 +02:00
k
2021-04-05 17:58:35 +02:00
echo "Testing with new version (kill+reload)"
2023-01-15 21:35:33 +01:00
runTestSimple
2021-12-15 11:55:30 +01:00
k
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
2021-10-02 17:18:25 +02:00
input=$PWD
2022-04-30 21:54:03 +02:00
cd "$madelinePath"
2023-11-17 18:45:52 +01:00
if [ "$CI_COMMIT_TAG" == "7777" ]; then exit 0; fi
2023-05-29 14:25:32 +02:00
cp "$input/madeline$php$branch.phar" "madeline81.phar"
git remote add hub https://github.com/danog/MadelineProto
2023-06-12 22:54:21 +02:00
2023-11-17 18:45:52 +01:00
echo -n "$CI_COMMIT_TAG" > release
2023-06-13 01:02:38 +02:00
cp tools/phar.php madeline.php
2023-06-12 22:54:21 +02:00
2023-11-17 18:45:52 +01:00
gh release upload "$CI_COMMIT_TAG" "madeline81.phar"
gh release upload "$CI_COMMIT_TAG" "release"
gh release upload "$CI_COMMIT_TAG" "madeline.php"
2023-05-29 14:25:32 +02:00
2023-11-17 18:45:52 +01:00
gh release edit --prerelease=false "$CI_COMMIT_TAG"
gh release edit --latest=true "$CI_COMMIT_TAG"
2023-05-29 14:25:32 +02:00