Skip to content

Commit 1b114ed

Browse files
authored
Merge pull request #1 from basakest/test
feat: add the skeleton of test code, use 'Github Actions' to run test…
2 parents 0adacd1 + 850a10d commit 1b114ed

File tree

8 files changed

+3535
-99
lines changed

8 files changed

+3535
-99
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: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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: cake_adapter
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.3, 7.4 ]
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: Install dependencies
46+
if: steps.composer-cache.outputs.cache-hit != 'true'
47+
run: |
48+
composer install --prefer-dist --no-progress --no-suggest
49+
50+
- name: install dependencies of cake app
51+
run: |
52+
cd vendor/cakephp/app
53+
composer install --prefer-dist --no-progress --no-suggest
54+
55+
- name: Run test suite
56+
run: ./vendor/bin/phpunit
57+
58+
- name: Run Coveralls
59+
env:
60+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
COVERALLS_PARALLEL: true
62+
COVERALLS_FLAG_NAME: ${{ runner.os }} - ${{ matrix.php }}
63+
run: |
64+
composer global require php-coveralls/php-coveralls:^2.4
65+
php-coveralls --coverage_clover=build/logs/clover.xml -v
66+
67+
upload-coverage:
68+
runs-on: ubuntu-latest
69+
needs: [ test ]
70+
steps:
71+
- name: Coveralls Finished
72+
uses: coverallsapp/github-action@master
73+
with:
74+
github-token: ${{ secrets.GITHUB_TOKEN }}
75+
parallel-finished: true
76+
77+
semantic-release:
78+
runs-on: ubuntu-latest
79+
needs: [ test, upload-coverage ]
80+
steps:
81+
- uses: actions/checkout@v2
82+
- uses: actions/setup-node@v1
83+
with:
84+
node-version: '12'
85+
86+
- name: Run semantic-release
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
89+
run: npx semantic-release

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"cakephp/cakephp": "3.*",
1414
"casbin/casbin": "0.*"
1515
},
16+
"require-dev": {
17+
"phpunit/phpunit": "^7.0",
18+
"cakephp/app": "3.*"
19+
},
1620
"autoload": {
1721
"psr-4": {
1822
"CasbinAdapter\\Cake\\": "src/"

0 commit comments

Comments
 (0)