Skip to content

Commit ca6f818

Browse files
committed
feat: use 'Github Actions' to run tests and auto release
1 parent cda7b57 commit ca6f818

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

.github/workflows/default.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Default
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.1, 7.2, 7.3, 7.4, 8.0 ]
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: Setup PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ matrix.php }}
39+
tools: composer:v2
40+
coverage: xdebug
41+
42+
- name: Validate composer.json and composer.lock
43+
run: composer validate
44+
45+
- name: Cache Composer packages
46+
id: composer-cache
47+
uses: actions/cache@v2
48+
with:
49+
path: vendor
50+
key: ${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
51+
restore-keys: |
52+
${{ runner.os }}-${{ matrix.php }}-
53+
54+
- name: Install dependencies
55+
if: steps.composer-cache.outputs.cache-hit != 'true'
56+
run: composer install --prefer-dist --no-progress --no-suggest
57+
58+
- name: Run test suite
59+
run: ./vendor/bin/phpunit
60+
61+
semantic-release:
62+
runs-on: ubuntu-latest
63+
needs: [ test ]
64+
steps:
65+
- uses: actions/checkout@v2
66+
- uses: actions/setup-node@v1
67+
with:
68+
node-version: '12'
69+
70+
- name: Run semantic-release
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
73+
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"

0 commit comments

Comments
 (0)