Skip to content

Commit

Permalink
Merge pull request #80 from botuniverse/develop
Browse files Browse the repository at this point in the history
0.5.0 release
  • Loading branch information
crazywhalecc authored Dec 26, 2022
2 parents e0a374b + a49f66d commit 76f88a3
Show file tree
Hide file tree
Showing 137 changed files with 2,688 additions and 3,758 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/coding-style-analysis.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Code Style

on:
push:
pull_request:
workflow_dispatch:

jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v4
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
paths: '["src/**", "tests/**"]'
do_not_skip: '["workflow_dispatch", "schedule"]'

cs-fix:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Code Style
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: 8.0
php-extensions: swoole, posix, json
operating-system: ubuntu-latest
use-cache: true

- name: Code Style
uses: sunxyw/workflows/coding-style@main
59 changes: 0 additions & 59 deletions .github/workflows/integration-test.yaml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Static Analysis

on:
push:
pull_request:
workflow_dispatch:

jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v4
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
paths: '["src/**", "tests/**"]'
do_not_skip: '["workflow_dispatch", "schedule"]'

analyse:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: 7.4
php-extensions: swoole, posix, json
operating-system: ubuntu-latest
use-cache: true

- name: Static Analysis
uses: sunxyw/workflows/static-analysis@main
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test

on:
push:
branches:
- main
- develop
- '*-dev*'
pull_request:
types:
- opened
- reopened
- review_requested
workflow_dispatch:

jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v4
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
paths: '["src/**", "tests/**", "bin/phpunit-zm"]'
do_not_skip: '["workflow_dispatch", "schedule"]'

test:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
php-version: [ 7.4, 8.0, 8.1 ]
name: PHP ${{ matrix.php-version }} Test (${{ matrix.operating-system }})
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: ${{ matrix.php-version }}
php-extensions: swoole, posix, json
operating-system: ${{ matrix.operating-system }}
use-cache: true

- name: Test
uses: sunxyw/workflows/test@main
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ cghooks.lock
### Phive ###
tools
.phive

### pcov coverage report
build/

data/
2 changes: 2 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
'types_spaces' => false,
'braces' => false,
'blank_line_between_import_groups' => false,
'phpdoc_order' => ['order' => ['param', 'throws', 'return']],
'php_unit_test_class_requires_covers' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $ob->setLogger(new \OneBot\Logger\Console\ConsoleLogger());
$ob->setDriver(
// 此处也可以在 Linux 系统下安装 swoole 扩展后使用 SwooleDriver() 拥有协程能力
new \OneBot\Driver\Workerman\WorkermanDriver(),
new \OneBot\V12\Config\Config('demo.json')
new \OneBot\Config\Repository('demo.json')
);
$ob->setActionHandlerClass(\OneBot\V12\Action\ReplAction::class);
$ob->run();
Expand Down
32 changes: 32 additions & 0 deletions choir-test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/** @noinspection PhpComposerExtensionStubsInspection */

declare(strict_types=1);

require_once 'vendor/autoload.php';

$server = new \Choir\Http\Server('0.0.0.0', 20001, false, [
'worker-num' => 8,
// 'logger-level' => 'debug',
]);

$server->on('workerstart', function () {
// xhprof_enable();
});

$server->on('workerstop', function () {
// $data = xhprof_disable();
// $x = new XHProfRuns_Default();
// $id = $x->save_run($data, 'xhprof_testing');
// echo "http://127.0.0.1:8080/index.php?run={$id}&source=xhprof_testing\n";
});

$server->on('request', function (Choir\Protocol\HttpConnection $connection) {
$connection->end('hello world');
});

require_once '/private/tmp/xhprof-2.3.8/xhprof_lib/utils/xhprof_lib.php';
require_once '/private/tmp/xhprof-2.3.8/xhprof_lib/utils/xhprof_runs.php';

$server->start();
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
"wiki": "https://github.com/botuniverse/php-libonebot/wiki"
},
"require": {
"php": "^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1",
"php": "^7.4 || ^8.0 || ^8.1 || ^8.2",
"ext-json": "*",
"psr/cache": "^1.0",
"psr/event-dispatcher": "^1.0",
"psr/http-client": "^1.0",
"psr/log": "^1.1",
"rybakit/msgpack": "^0.9.0",
"choir/psr-http": "^1.0",
"workerman/workerman": "^4.0",
"zhamao/logger": "^1.0"
},
Expand Down
10 changes: 7 additions & 3 deletions demo/repl.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

use OneBot\Driver\Event\DriverInitEvent;
use OneBot\Util\Utils;
use OneBot\V12\Action\ActionResponse;
use OneBot\V12\Object\Action;
use OneBot\V12\Object\Event\Message\PrivateMessageEvent;
use OneBot\V12\Object\ActionResponse;
use OneBot\V12\OneBot;
use OneBot\V12\OneBotBuilder;
use OneBot\V12\Validator;
Expand Down Expand Up @@ -82,7 +81,12 @@ function message_id(): string
$event->getDriver()->getEventLoop()->delReadEvent($x);
return;
}
$event = new PrivateMessageEvent('tty', trim($s));
$event = (new \OneBot\V12\EventBuilder('message', 'private'))
->feed('message', trim($s))
->feed('alt_message', trim($s))
->feed('message_id', message_id())
->feed('user_id', 'tty')
->build();
OneBot::getInstance()->dispatchEvent($event);
});
}, 0);
Expand Down
Loading

0 comments on commit 76f88a3

Please sign in to comment.