Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 83 additions & 29 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,111 @@
name: PHPUnit
name: PHPUnit for MineAdmin

on: [ push, pull_request ]

env:
SWOOLE_VERSION: '5.1.1'
SWOW_VERSION: 'develop'
on:
push:
pull_request:
schedule:
- cron: '0 2 * * *'

jobs:
ci:
name: Test PHP ${{ matrix.php-version }} on ${{ matrix.engine }}
cs-fix:
name: PHP CS Fix on PHP${{ matrix.php }} ${{ matrix.swoole }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest ]
php: [ '8.1','8.2','8.3' ]
swoole: [ 'swoole']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
tools: php-cs-fixer
extensions: redis, pdo, pdo_mysql, bcmath, ${{ matrix.swoole }}
- name: Setup Packages
run: composer update -oW
- name: Run CS Fix
run: |
vendor/bin/php-cs-fixer fix src --dry-run --diff
vendor/bin/php-cs-fixer fix src --dry-run --diff
tests:
needs: cs-fix
name: Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }}
runs-on: "${{ matrix.os }}"
strategy:
matrix:
os: [ ubuntu-latest ]
php-version: ['8.1','8.2','8.3' ]
engine: [ 'swoole' ]
max-parallel: 5
services:
redis:
image: redis
ports:
- "6379:6379"
php-version: [ '8.3', '8.2', '8.1' ]
sw-version: [ 'v5.0.3', 'v5.1.2', 'master' ]
exclude:
- php-version: '8.3'
sw-version: 'v5.0.3'
max-parallel: 20
fail-fast: false
env:
SW_VERSION: ${{ matrix.sw-version }}
MYSQL_VERSION: '8.0'
PGSQL_VERSION: '14'
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Upgrade
run: |
sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade -f
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: phpize
extensions: redis, pdo, pdo_mysql, bcmath
ini-values: opcache.enable_cli=0
coverage: none
- name: Setup Swoole
if: ${{ matrix.engine == 'swoole' }}
run: |
cd /tmp
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev
wget https://github.com/swoole/swoole-src/archive/v${SWOOLE_VERSION}.tar.gz -O swoole.tar.gz
sudo apt-get install libcurl4-openssl-dev libc-ares-dev libpq-dev
wget https://github.com/swoole/swoole-src/archive/${SW_VERSION}.tar.gz -O swoole.tar.gz
mkdir -p swoole
tar -xf swoole.tar.gz -C swoole --strip-components=1
rm swoole.tar.gz
cd swoole
phpize
./configure --enable-openssl --enable-http2 --enable-swoole-curl --enable-swoole-json
./configure --enable-openssl --enable-swoole-curl --enable-cares --enable-swoole-pgsql --enable-brotli
make -j$(nproc)
sudo make install
sudo sh -c "echo extension=swoole > /etc/php/${{ matrix.php-version }}/cli/conf.d/swoole.ini"
sudo sh -c "echo swoole.use_shortname='Off' >> /etc/php/${{ matrix.php-version }}/cli/conf.d/swoole.ini"
php --ri swoole
- name: Setup Packages
run: composer update -o --no-scripts
- name: Run Test Cases
run: ./.travis/requirement.install.sh
- name: Run PHPStan
run: ./.travis/run.check.sh
- name: Setup Services
run: ./.travis/setup.services.sh
- name: Setup Mysql
run: export TRAVIS_BUILD_DIR=$(pwd) && bash ./.travis/setup.mysql.sh
- name: Setup PostgreSQL
run: export TRAVIS_BUILD_DIR=$(pwd) && bash ./.travis/setup.pgsql.sh
- name: Run Scripts Before Test
run: cp .travis/.env.example .env
- name: Print PHP Environments
run: |
vendor/bin/php-cs-fixer fix --dry-run # cs-fixer 格式化代码
composer analyse # phpstan 静态代码分析
composer test # phpunit
php -i
php -m
- name: Run Test Cases
env:
DB_DRIVER: mysql
DB_HOST: 127.0.0.1
DB_DATABASE: mineadmin
run: ./.travis/run.test.sh
# - name: Run PgSql Test Cases
# env:
# DB_DRIVER: pgsql
# DB_HOST: 127.0.0.1
# DB_PORT: 5432
# DB_USERNAME: postgres
# DB_PASSWORD: postgres
# DB_CHARSET: utf8
# DB_DATABASE: mineadmin
# run: ./.travis/run.test.sh
14 changes: 14 additions & 0 deletions .travis/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
APP_NAME=mineadmin
APP_ENV=dev
APP_DEBUG=true
SUPER_ADMIN = 1000
ADMIN_ROLE = 1000
CONSOLE_SQL = false
AMQP_HOST = 127.0.0.1
AMQP_PORT = 5672
AMQP_USER = mineadmin
AMQP_PASSWORD = mineadmin
AMQP_VHOST = /
AMQP_ENABLE = false
JWT_SECRET="mGlQxdNYoXIzVI0OkqQMaW07TpP94NUcjklspzEY6jXVeSparSQQ70kjlodwov2oINKluPuxgS7uetxaIJof4A=="
JWT_API_SECRET="HLbcdGtYle+H0b18fLSaSdXrj/sSYoFfDMW0zqF/wf0ZgS0HxlqVzoQL2ocNLTsgP+v9EbyOoGghv94A2cGhkg=="
8 changes: 8 additions & 0 deletions .travis/ci.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[opcache]
opcache.enable_cli=1

[redis]
extension = "redis.so"

[swoole]
extension = "swoole.so"
9 changes: 9 additions & 0 deletions .travis/requirement.install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env sh

set -e

set -x

composer install

php ./.travis/run.replace.php
5 changes: 5 additions & 0 deletions .travis/run.check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -e

composer analyse src
14 changes: 14 additions & 0 deletions .travis/run.code-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e
php bin/hyperf.php migrate --path=app/Setting/Database/Migrations

php bin/hyperf.php migrate --path=app/System/Database/Migrations

php bin/hyperf.php db:seed --path=app/Setting/Database/Seeders

php bin/hyperf.php db:seed --path=app/System/Database/Seeders

php bin/hyperf.php mine:update

composer coverage
15 changes: 15 additions & 0 deletions .travis/run.replace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

$messageConsumerFile = dirname(__DIR__).'/app/System/Queue/Consumer/MessageConsumer.php';
$messageProducerFile = dirname(__DIR__).'/app/System/Queue/Producer/MessageProducer.php';
$str = file_get_contents($messageConsumerFile);

$replaceStr = str_replace('// #[Consumer(exchange: "mineadmin", routingKey: "message.routing", queue: "message.queue", name: "message.queue", nums: 1)]','#[Consumer(exchange: "mineadmin", routingKey: "message.routing", queue: "message.queue", name: "message.queue", nums: 1)]',$str);
file_put_contents($messageConsumerFile,$replaceStr);

$str = file_get_contents($messageProducerFile);

$replaceStr = str_replace('// #[Producer(exchange: "mineadmin", routingKey: "message.routing")]','#[Producer(exchange: "mineadmin", routingKey: "message.routing")]',$str);

file_put_contents($messageProducerFile,$replaceStr);

5 changes: 5 additions & 0 deletions .travis/run.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -e

./vendor/bin/pest --parallel
11 changes: 11 additions & 0 deletions .travis/setup.mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}"

echo -e "Create MySQL database..."
mysql -h 127.0.0.1 -u root -e "CREATE DATABASE IF NOT EXISTS mineadmin charset=utf8mb4 collate=utf8mb4_unicode_ci;"

echo -e "Done\n"

wait
15 changes: 15 additions & 0 deletions .travis/setup.pgsql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR:-$(dirname $(dirname $CURRENT_DIR))}"

echo -e "Init PostgreSQL database..."

echo "127.0.0.1:5432:postgres:postgres:postgres" > ~/.pgpass
chmod 600 ~/.pgpass

docker exec postgres psql -d postgres -U postgres -c "create database mineadmin"

echo -e "Done\n"

wait
8 changes: 8 additions & 0 deletions .travis/setup.services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
docker run --name mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mysql:${MYSQL_VERSION} --bind-address=0.0.0.0 --default-authentication-plugin=mysql_native_password &
docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres:${PGSQL_VERSION} &
docker run --name redis -p 6379:6379 -d redis &
docker run -d --restart=always --name rabbitmq -e RABBITMQ_DEFAULT_USER=mineadmin -e RABBITMQ_DEFAULT_PASS=123456 -p 4369:4369 -p 5672:5672 -p 15672:15672 -p 25672:25672 rabbitmq:management-alpine &
wait
sleep 10
docker ps -a
7 changes: 7 additions & 0 deletions CHANGELOG-2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# v2.0 - TBD

# v2.0.0-RC 25 March 2024

## Added

- [#53](https://github.com/mineadmin/components/pull/53) Splitting components http-server
7 changes: 7 additions & 0 deletions CHANGELOG-2.0.zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# v2.0 - TBD

# v2.0.0-RC 2024年3月25日

## Added

- [#53](https://github.com/mineadmin/components/pull/53) 拆分组件 http-server
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 项目介绍

<p align="center">
<img src="https://doc.mineadmin.com/logo.svg" width="120" />
</p>
<p align="center">
<a href="https://www.mineadmin.com" target="_blank">官网</a> |
<a href="https://doc.mineadmin.com" target="_blank">文档</a> |
<a href="https://demo.mineadmin.com" target="_blank">演示</a> |
<a href="https://hyperf.wiki/3.0/#/" target="_blank">Hyperf官方文档</a>
</p>

<p align="center">
<img src="https://gitee.com/xmo/MineAdmin/badge/star.svg?theme=dark" />
<img src="https://gitee.com/xmo/MineAdmin/badge/fork.svg?theme=dark" />
<img src="https://svg.hamm.cn/badge.svg?key=License&value=Apache-2.0&color=da4a00" />
<img src="https://svg.hamm.cn/badge.svg?key=MineAdmin&value=v2.0 LTS" />
</p>
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"Mine\\Helper\\": "src/mine-helpers/src",
"Mine\\Generator\\": "src/mine-generator/src",
"Xmo\\AppStore\\": "src/app-store/src",
"Mine\\NextCoreX\\": "src/next-core-x/src"
"Mine\\NextCoreX\\": "src/next-core-x/src",
"Mine\\HttpServer\\": "src/HttpServer/src"
},
"files": [
"src/mine-helpers/src/functions.php"
Expand All @@ -30,7 +31,8 @@
"Mine\\Tests\\": "tests",
"Xmo\\AppStore\\Tests\\": "src/app-store/tests",
"Xmo\\MineCore\\Tests\\": "src/mine-core/tests",
"Mine\\NextCoreX\\Tests\\": "src/next-core-x/tests"
"Mine\\NextCoreX\\Tests\\": "src/next-core-x/tests",
"Mine\\HttpServer\\Tests\\": "src/HttpServer/tests"
}
},
"authors": [
Expand All @@ -54,7 +56,8 @@
"xmo/mine-helpers": "*",
"xmo/mine-genertor": "*",
"xmo/app-store": "*",
"mine/next-core-x": "*"
"mine/next-core-x": "*",
"mineadmin/http-server": "*"
},
"require": {
"php": ">=8.1",
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ parameters:
- src/mine-core/tests/*
- src/tests/
- src/app-store/test/
- src/httpServer/tests/
ignoreErrors:
- '#Unsafe usage of new static\(\)#'
- '#Call to static method find\(\) on an unknown class#'
Expand Down
9 changes: 1 addition & 8 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
<coverage/>
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./src/HttpServer/tests</directory>
<directory suffix="Test.php">./src/app-store/tests</directory>
<directory suffix="Test.php">./src/mine-core/tests</directory>
<directory suffix="Test.php">./src/next-core-x/tests</directory>
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src/app-store/tests</directory>
<directory suffix=".php">./src/mine-core/tests</directory>
<directory suffix=".php">./src/next-core-x/tests</directory>
<directory suffix=".php">./tests</directory>
</include>
</source>
</phpunit>
13 changes: 13 additions & 0 deletions src/HttpServer/.github/workflows/close-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Close Pull Request

on:
pull_request_target:
types: [ opened ]

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: "Hi, this is a READ-ONLY repository, please submit your PR on the https://github.com/mineadmin/components repository.<br><br> This Pull Request will close automatically.<br><br> Thanks! "
Loading