Skip to content

Commit 12c8562

Browse files
committed
Initial attempt to use GitHub Actions for tests
1 parent 627c199 commit 12c8562

File tree

8 files changed

+80
-60
lines changed

8 files changed

+80
-60
lines changed

Diff for: .github/workflows/tests.yaml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
pull_request:
7+
branches: [ master, develop ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
tests:
14+
name: PHP ${{ matrix.php }} Test
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
php: ['7.3', '7.4', '8.0', '8.1']
20+
21+
services:
22+
mariadb:
23+
image: mariadb:10.3
24+
ports:
25+
- 3306:3306
26+
env:
27+
MYSQL_ROOT_PASSWORD: root
28+
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
34+
- name: Test migrations
35+
run: |
36+
git fetch origin 0.44.1 && git checkout FETCH_HEAD -- structure.sql
37+
mysql -h127.0.0.1 -P3306 -uroot -proot -e "create database telegrambot_migrations; use telegrambot_migrations; source structure.sql;"
38+
git checkout HEAD -- structure.sql
39+
mysql -h127.0.0.1 -P3306 -uroot -proot -e "create database telegrambot; use telegrambot; source structure.sql;"
40+
for SCHEMA_UPDATE_FILE in $(ls utils/db-schema-update); do mysql -h127.0.0.1 -P3306 -uroot -proot -e "use telegrambot_migrations; source utils/db-schema-update/${SCHEMA_UPDATE_FILE};"; done;
41+
42+
- name: Install PHP
43+
uses: shivammathur/setup-php@v2
44+
with:
45+
php-version: ${{ matrix.php }}
46+
extensions: pdo_mysql
47+
48+
- name: Cache Composer packages
49+
id: composer-cache
50+
uses: actions/cache@v3
51+
with:
52+
path: vendor
53+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
54+
restore-keys: |
55+
${{ runner.os }}-php-
56+
57+
- name: Validate composer.json and composer.lock
58+
run: composer validate --strict
59+
60+
- name: Install dependencies
61+
run: composer install --prefer-dist --no-progress
62+
63+
- name: Check PHP code
64+
run: composer check-code
65+
66+
- name: Run test suite
67+
if: ${{ matrix.php != '7.3'}}
68+
run: composer test-cov
69+
70+
- name: Run test suite (with coverage)
71+
if: ${{ matrix.php == '7.3'}}
72+
run: |
73+
composer test-cov
74+
composer test-cov-upload

Diff for: .travis.yml

-51
This file was deleted.

Diff for: phpcs.xml.dist

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@
1313
<file>tests/</file>
1414
<file>utils/</file>
1515

16-
<rule ref="PSR12"/>
16+
<rule ref="PSR12">
17+
<exclude name="PSR12.Classes.OpeningBraceSpace.Found"/>
18+
</rule>
1719
</ruleset>

Diff for: phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<const name="PHPUNIT_DB_PORT" value="3306"/>
1717
<const name="PHPUNIT_DB_NAME" value="telegrambot"/>
1818
<const name="PHPUNIT_DB_USER" value="root"/>
19-
<const name="PHPUNIT_DB_PASS" value=""/>
19+
<const name="PHPUNIT_DB_PASS" value="root"/>
2020
</php>
2121
<testsuites>
2222
<testsuite name="Package Test Suite">

Diff for: src/Entities/ChatJoinRequest.php

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
class ChatJoinRequest extends Entity
1919
{
20-
2120
protected function subEntities(): array
2221
{
2322
return [
@@ -26,5 +25,4 @@ protected function subEntities(): array
2625
'invite_link' => ChatInviteLink::class,
2726
];
2827
}
29-
3028
}

Diff for: src/Entities/MenuButton/Factory.php

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
class Factory extends \Longman\TelegramBot\Entities\Factory
88
{
9-
109
public static function make(array $data, string $bot_username): Entity
1110
{
1211
$type = [

Diff for: src/Entities/MenuButton/MenuButtonWebApp.php

-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,4 @@ protected function subEntities(): array
2727
'web_app' => WebAppInfo::class,
2828
];
2929
}
30-
31-
3230
}

Diff for: tests/Unit/Entities/KeyboardTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,12 @@ public function testKeyboardAddRows(): void
186186
$keyboard = $keyboard_obj->getProperty('keyboard');
187187
self::assertSame('Button Text 4', $keyboard[2][0]->getText());
188188
}
189-
189+
190190
public function testSetterMethods(): void
191191
{
192192
$keyboard = (new Keyboard(
193193
[
194-
['text' => 'One']
194+
['text' => 'One'],
195195
]
196196
))->setResizeKeyboard(true);
197197

0 commit comments

Comments
 (0)