From 18a77aad27eab4c0223b80fed1cde61a099b4e25 Mon Sep 17 00:00:00 2001
From: basakest <ab1652759879@gmail.com>
Date: Sat, 10 Apr 2021 19:29:48 +0800
Subject: [PATCH 1/3] feat: use 'Github Actions' to run tests and auto release

feat: use 'Github Actions' to run tests and auto release
---
 .github/semantic.yml        |  2 +
 .github/workflows/build.yml | 84 +++++++++++++++++++++++++++++++++++++
 .releaserc.yml              |  4 ++
 .travis.yml                 | 24 -----------
 composer.json               |  3 +-
 phpunit.xml.dist            |  2 +-
 tests/travis/Database.php   | 24 -----------
 7 files changed, 92 insertions(+), 51 deletions(-)
 create mode 100644 .github/semantic.yml
 create mode 100644 .github/workflows/build.yml
 create mode 100644 .releaserc.yml
 delete mode 100755 .travis.yml
 delete mode 100755 tests/travis/Database.php

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..ead8cfa
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,84 @@
+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 ]
+        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/composer.json b/composer.json
index b2f5016..059b99e 100755
--- a/composer.json
+++ b/composer.json
@@ -33,8 +33,7 @@
         }
     },
     "require-dev": {
-        "phpunit/phpunit": "^7.0",
-        "php-coveralls/php-coveralls": "^2.1"
+        "phpunit/phpunit": "^7.0"
     },
     "autoload-dev": {
         "psr-4": {
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

From 832641ff9670b57c296a743e56dde1614b0710b2 Mon Sep 17 00:00:00 2001
From: Jon <techlee@qq.com>
Date: Tue, 20 Sep 2022 23:52:52 +0800
Subject: [PATCH 2/3] Update .github/workflows/build.yml

---
 .github/workflows/build.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ead8cfa..3cf0651 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -23,7 +23,8 @@ jobs:
     strategy:
       fail-fast: true
       matrix:
-        php: [ 7.2, 7.3 ]
+        php: [ 7.2, 7.3,7.4,8.0 ]
+
         stability: [ prefer-lowest, prefer-stable ]            
 
     name: PHP ${{ matrix.php }} - ${{ matrix.stability }}

From 6078fad38ceea91c892c6f848ca559ad7cc034ac Mon Sep 17 00:00:00 2001
From: Jon <techlee@qq.com>
Date: Tue, 20 Sep 2022 23:53:08 +0800
Subject: [PATCH 3/3] Update composer.json

---
 composer.json | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/composer.json b/composer.json
index 059b99e..b2f5016 100755
--- a/composer.json
+++ b/composer.json
@@ -33,7 +33,8 @@
         }
     },
     "require-dev": {
-        "phpunit/phpunit": "^7.0"
+        "phpunit/phpunit": "^7.0",
+        "php-coveralls/php-coveralls": "^2.1"
     },
     "autoload-dev": {
         "psr-4": {