Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 487eb8f

Browse files
committedApr 10, 2021
feat: use 'Github Actions' to run tests and auto release
1 parent 4023c6d commit 487eb8f

File tree

6 files changed

+106
-50
lines changed

6 files changed

+106
-50
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: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
strategy:
24+
fail-fast: true
25+
matrix:
26+
php: [ 7.2, 7.3 ]
27+
stability: [ prefer-lowest, prefer-stable ]
28+
29+
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v2
34+
35+
- name: create db_rules table
36+
run: |
37+
sudo apt-get install -y mysql-client
38+
mysql --host 127.0.0.1 --port 3306 -u root -p -e "USE casbin; CREATE TABLE if not exists db_rules (
39+
id BigInt(20) unsigned NOT NULL AUTO_INCREMENT,
40+
ptype varchar(255) DEFAULT NULL,
41+
v0 varchar(255) DEFAULT NULL,
42+
v1 varchar(255) DEFAULT NULL,
43+
v2 varchar(255) DEFAULT NULL,
44+
v3 varchar(255) DEFAULT NULL,
45+
v4 varchar(255) DEFAULT NULL,
46+
v5 varchar(255) DEFAULT NULL,
47+
PRIMARY KEY (id)
48+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
49+
50+
- name: Setup PHP
51+
uses: shivammathur/setup-php@v2
52+
with:
53+
php-version: ${{ matrix.php }}
54+
tools: composer:v2
55+
coverage: xdebug
56+
57+
- name: Validate composer.json and composer.lock
58+
run: composer validate
59+
60+
- name: Install dependencies
61+
if: steps.composer-cache.outputs.cache-hit != 'true'
62+
run: |
63+
composer install --prefer-dist --no-progress --no-suggest
64+
65+
- name: Run test suite
66+
run: ./vendor/bin/phpunit
67+
68+
- name: Run Coveralls
69+
env:
70+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
COVERALLS_PARALLEL: true
72+
COVERALLS_FLAG_NAME: ${{ runner.os }} - ${{ matrix.php }}
73+
run: |
74+
composer global require php-coveralls/php-coveralls:^2.4
75+
php-coveralls --coverage_clover=build/logs/clover.xml -v
76+
77+
upload-coverage:
78+
runs-on: ubuntu-latest
79+
needs: [ test ]
80+
steps:
81+
- name: Coveralls Finished
82+
uses: coverallsapp/github-action@master
83+
with:
84+
github-token: ${{ secrets.GITHUB_TOKEN }}
85+
parallel-finished: true
86+
87+
semantic-release:
88+
runs-on: ubuntu-latest
89+
needs: [ test, upload-coverage ]
90+
steps:
91+
- uses: actions/checkout@v2
92+
- uses: actions/setup-node@v1
93+
with:
94+
node-version: '12'
95+
96+
- name: Run semantic-release
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
99+
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 & 24 deletions
This file was deleted.

‎composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
}
3434
},
3535
"require-dev": {
36-
"phpunit/phpunit": "^7.0",
37-
"php-coveralls/php-coveralls": "^2.1"
36+
"phpunit/phpunit": "^7.0"
3837
},
3938
"autoload-dev": {
4039
"psr-4": {

‎tests/travis/Database.php

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

0 commit comments

Comments
 (0)
Please sign in to comment.