Skip to content

Commit

Permalink
feat: add the skeleton of test code, use 'Github Actions' to run test…
Browse files Browse the repository at this point in the history
…s and auto release

change
  • Loading branch information
basakest committed May 9, 2021
1 parent 0adacd1 commit 850a10d
Show file tree
Hide file tree
Showing 8 changed files with 3,535 additions and 99 deletions.
2 changes: 2 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Always validate the PR title AND all the commits
titleAndCommits: true
89 changes: 89 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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: cake_adapter
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: true
matrix:
php: [ 7.3, 7.4 ]
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: install dependencies of cake app
run: |
cd vendor/cakephp/app
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
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"cakephp/cakephp": "3.*",
"casbin/casbin": "0.*"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"cakephp/app": "3.*"
},
"autoload": {
"psr-4": {
"CasbinAdapter\\Cake\\": "src/"
Expand Down
Loading

0 comments on commit 850a10d

Please sign in to comment.