diff --git a/.github/semantic.yml b/.github/semantic.yml new file mode 100644 index 0000000..96f9233 --- /dev/null +++ b/.github/semantic.yml @@ -0,0 +1,2 @@ +# Always validate the PR title AND all the commits +titleAndCommits: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3cf0651 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,85 @@ +name: build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: casbin + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + strategy: + fail-fast: true + matrix: + php: [ 7.2, 7.3,7.4,8.0 ] + + stability: [ prefer-lowest, prefer-stable ] + + name: PHP ${{ matrix.php }} - ${{ matrix.stability }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + coverage: xdebug + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: | + composer install --prefer-dist --no-progress --no-suggest + + - name: Run test suite + run: ./vendor/bin/phpunit + + - name: Run Coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_PARALLEL: true + COVERALLS_FLAG_NAME: ${{ runner.os }} - ${{ matrix.php }} + run: | + composer global require php-coveralls/php-coveralls:^2.4 + php-coveralls --coverage_clover=build/logs/clover.xml -v + + upload-coverage: + runs-on: ubuntu-latest + needs: [ test ] + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true + + semantic-release: + runs-on: ubuntu-latest + needs: [ test, upload-coverage ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '12' + + - name: Run semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + run: npx semantic-release \ No newline at end of file diff --git a/.releaserc.yml b/.releaserc.yml new file mode 100644 index 0000000..2bd44ca --- /dev/null +++ b/.releaserc.yml @@ -0,0 +1,4 @@ +plugins: + - "@semantic-release/commit-analyzer" + - "@semantic-release/release-notes-generator" + - "@semantic-release/github" \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100755 index 517f101..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: php -sudo: false - -php: - - 7.2 - - 7.3 - -services: - - mysql - -before_install: - - travis_retry composer self-update - - mysql -e 'create database if not exists casbin;' - -install: - - travis_retry composer install --no-suggest --no-interaction - -script: - - vendor/bin/phpunit --version - - mkdir -p build/logs - - vendor/bin/phpunit - -after_script: - - travis_retry vendor/bin/php-coveralls -v \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 76ec2d0..14d138a 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit bootstrap="vendor/codeigniter4/framework/tests/_support/_bootstrap.php" +<phpunit bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php" backupGlobals="false" colors="true" convertErrorsToExceptions="true" diff --git a/tests/travis/Database.php b/tests/travis/Database.php deleted file mode 100755 index 8d93903..0000000 --- a/tests/travis/Database.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php -// $dbconfig =[ -// 'tests' => [ -// 'DSN' => '', -// 'hostname' => 'localhost', -// 'username' => getenv('DB_USERNAME') ?: 'root', -// 'password' => getenv('DB_PASSWORD') ?: '', -// 'database' => getenv('DB_DATABASE') ?: 'test', -// 'DBDriver' => 'MySQLi', -// 'DBPrefix' => '', -// 'pConnect' => false, -// 'DBDebug' => (ENVIRONMENT !== 'production'), -// 'cacheOn' => false, -// 'cacheDir' => '', -// 'charset' => 'utf8', -// 'DBCollat' => 'utf8_general_ci', -// 'swapPre' => '', -// 'encrypt' => false, -// 'compress' => false, -// 'strictOn' => false, -// 'failover' => [], -// 'port' => 3306, -// ] -// ]; \ No newline at end of file