Skip to content

Commit 79f46bd

Browse files
authored
Merge pull request #1 from basakest/githubAction
feat: use 'Github Actions' to run tests and auto release
2 parents 34cd588 + 08ecf43 commit 79f46bd

File tree

6 files changed

+109
-35
lines changed

6 files changed

+109
-35
lines changed

.github/semantic.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Always validate the PR title AND all the commits
2+
titleAndCommits: true

.github/workflows/build.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
mysql:
15+
image: mysql:5.7
16+
env:
17+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
18+
MYSQL_DATABASE: casbin
19+
ports:
20+
- 3306:3306
21+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
22+
23+
postgres:
24+
image: postgres
25+
env:
26+
POSTGRES_PASSWORD: postgres
27+
POSTGRES_USER: postgres
28+
POSTGRES_DB: casbin
29+
ports:
30+
- 5432:5432
31+
options:
32+
--health-cmd pg_isready
33+
--health-interval 10s
34+
--health-timeout 5s
35+
--health-retries 5
36+
37+
strategy:
38+
fail-fast: true
39+
matrix:
40+
php: [ 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 ]
41+
stability: [ prefer-lowest, prefer-stable ]
42+
43+
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
44+
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v2
48+
49+
- name: Setup PHP
50+
uses: shivammathur/setup-php@v2
51+
with:
52+
php-version: ${{ matrix.php }}
53+
tools: composer:v2
54+
coverage: xdebug
55+
56+
- name: Validate composer.json and composer.lock
57+
run: composer validate
58+
59+
- name: Install dependencies
60+
if: steps.composer-cache.outputs.cache-hit != 'true'
61+
run: |
62+
composer install --prefer-dist --no-progress --no-suggest
63+
64+
- name: Run test suite
65+
run: ./vendor/bin/phpunit
66+
67+
- name: Run Coveralls
68+
env:
69+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
COVERALLS_PARALLEL: true
71+
COVERALLS_FLAG_NAME: ${{ runner.os }} - ${{ matrix.php }}
72+
run: |
73+
composer global require php-coveralls/php-coveralls:^2.4
74+
php-coveralls --coverage_clover=build/logs/clover.xml -v
75+
76+
upload-coverage:
77+
runs-on: ubuntu-latest
78+
needs: [ test ]
79+
steps:
80+
- name: Coveralls Finished
81+
uses: coverallsapp/github-action@master
82+
with:
83+
github-token: ${{ secrets.GITHUB_TOKEN }}
84+
parallel-finished: true
85+
86+
semantic-release:
87+
runs-on: ubuntu-latest
88+
needs: [ test, upload-coverage ]
89+
steps:
90+
- uses: actions/checkout@v2
91+
- uses: actions/setup-node@v1
92+
with:
93+
node-version: '12'
94+
95+
- name: Run semantic-release
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
98+
run: npx semantic-release

.releaserc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
plugins:
2+
- "@semantic-release/commit-analyzer"
3+
- "@semantic-release/release-notes-generator"
4+
- "@semantic-release/github"

.travis.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/AdapterPgsqlTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ protected function initConfig()
88
{
99
$this->config = [
1010
'driver' => 'Pdo_Pgsql',
11-
'hostname' => $this->env('DB_PORT', '127.0.0.1'),
11+
'hostname' => $this->env('DB_HOST', '127.0.0.1'),
1212
'database' => $this->env('DB_DATABASE', 'casbin'),
1313
'username' => $this->env('DB_USERNAME', 'postgres'),
14-
'password' => $this->env('DB_PASSWORD', ''),
14+
'password' => $this->env('DB_PASSWORD', 'postgres'),
1515
'port' => $this->env('DB_PORT', 5432),
1616
];
1717
}

tests/AdapterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function initConfig()
2424
{
2525
$this->config = [
2626
'driver' => 'Pdo_Mysql', // Mysqli, Sqlsrv, Pdo_Sqlite, Pdo_Mysql, Pdo(= Other PDO Driver)
27-
'hostname' => $this->env('DB_PORT', '127.0.0.1'),
27+
'hostname' => $this->env('DB_HOST', '127.0.0.1'),
2828
'database' => $this->env('DB_DATABASE', 'casbin'),
2929
'username' => $this->env('DB_USERNAME', 'root'),
3030
'password' => $this->env('DB_PASSWORD', ''),
@@ -49,7 +49,7 @@ protected function initialize()
4949

5050
try {
5151
$laminasDbAdapter->query(
52-
$sql->getSqlStringForSqlObject($ddl),
52+
$sql->buildSqlString($ddl),
5353
$laminasDbAdapter::QUERY_MODE_EXECUTE
5454
);
5555
} catch (\Exception $e) {
@@ -65,7 +65,7 @@ protected function initialize()
6565
$table->addColumn(new Varchar('v5', 255, true));
6666

6767
$laminasDbAdapter->query(
68-
$sql->getSqlStringForSqlObject($table),
68+
$sql->buildSqlString($table),
6969
$laminasDbAdapter::QUERY_MODE_EXECUTE
7070
);
7171
$tableGateway->delete('1 = 1');

0 commit comments

Comments
 (0)