Skip to content

Commit

Permalink
Add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 committed Dec 12, 2023
1 parent c8d59d4 commit 8a9bd98
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Expand Up @@ -12,3 +12,4 @@
/.scrutinizer.yml export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.github export-ignore
36 changes: 36 additions & 0 deletions .github/workflows/imports.yml
@@ -0,0 +1,36 @@
name: Check Imports

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Check Imports
run: ./vendor/bin/check_imports
71 changes: 71 additions & 0 deletions .github/workflows/tests.yml
@@ -0,0 +1,71 @@
name: tests

# Controls when the workflow will run
on:
push:
branches: [master]
pull_request:
branches: [master]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3]
laravel: [^6.0, ^7.0, ^8.0, ^9.0, ^10.0]
exclude:
- php: 7.2
laravel: ^8.0
- php: 7.2
laravel: ^9.0
- php: 7.2
laravel: ^10.0
- php: 7.3
laravel: ^9.0
- php: 7.3
laravel: ^10.0
- php: 7.4
laravel: ^9.0
- php: 7.4
laravel: ^10.0
- php: 8.0
laravel: ^10.0
- php: 8.1
laravel: ^6.0
- php: 8.1
laravel: ^7.0
- php: 8.2
laravel: ^7.0
- php: 8.2
laravel: ^6.0
- php: 8.3
laravel: ^7.0
- php: 8.3
laravel: ^6.0

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, exif, iconv, tokenizer
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework=${{ matrix.laravel }}" --no-update
composer update --prefer-dist --no-interaction --no-progress
- name: Execute tests
run: ./vendor/bin/phpunit
3 changes: 1 addition & 2 deletions .styleci.yml
@@ -1,2 +1 @@
php:
preset: laravel
preset: laravel
11 changes: 6 additions & 5 deletions README.md
Expand Up @@ -9,7 +9,8 @@
<a href="https://scrutinizer-ci.com/g/imanghafoori1/laravel-heyman"><img src="https://img.shields.io/scrutinizer/g/imanghafoori1/laravel-heyman.svg?style=round-square" alt="Quality Score"></img></a>
[![code coverage](https://codecov.io/gh/imanghafoori1/laravel-heyman/branch/master/graph/badge.svg)](https://codecov.io/gh/imanghafoori1/laravel-heyman)
[![Maintainability](https://api.codeclimate.com/v1/badges/9d6be7b057103cb14410/maintainability)](https://codeclimate.com/github/imanghafoori1/laravel-heyman/maintainability)
[![Build Status](https://travis-ci.org/imanghafoori1/laravel-heyman.svg?branch=master)](https://travis-ci.org/imanghafoori1/laravel-heyman)
[![Imports](https://github.com/imanghafoori1/laravel-heyman/actions/workflows/imports.yml/badge.svg?branch=master)](https://github.com/imanghafoori1/laravel-heyman/actions/workflows/imports.yml)
[![Test](https://github.com/imanghafoori1/laravel-heyman/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/imanghafoori1/laravel-heyman/actions/workflows/tests.yml)
[![StyleCI](https://github.styleci.io/repos/139709518/shield?branch=master)](https://github.styleci.io/repos/139709518)
[![Latest Stable Version](https://poser.pugx.org/imanghafoori/laravel-heyman/v/stable)](https://packagist.org/packages/imanghafoori/laravel-heyman)
[![Daily Downloads](https://poser.pugx.org/imanghafoori/laravel-heyman/d/daily)](https://packagist.org/packages/imanghafoori/laravel-heyman)
Expand All @@ -24,9 +25,9 @@

#### Built with :heart: for every smart laravel developer

Very well tested, optimized and production ready!
Very well-tested, optimized, and production-ready!

In fact, We have tackled a lot of `complexity` behind the scenes, to provide you with a lot of `simplicity`.
We have tackled a lot of `complexity` behind the scenes, to provide you with a lot of `simplicity`.

- Integrated with laravel-debugbar package out of the box: <a href="https://github.com/barryvdh/laravel-debugbar">laravel debugbar</a>

Expand Down Expand Up @@ -148,7 +149,7 @@ You are telling the framework what to do in certain situations rather than getti
> — Alec Sharp `

3- This approach is paticularly useful when you for example write a package which needs ACL but you want to allow your package users to override and apply they own ACL (or validation) rules into your package routes...
3- This approach is particularly useful when you for example write a package which needs ACL but you want to allow your package users to override and apply they own ACL (or validation) rules into your package routes...

And that becomes possible when you use laravel-HeyMan for ACL. The users can easily cancel out the default rules and re-write their favorite acl or validation stuff in a regular ServiceProviders.

Expand Down Expand Up @@ -355,7 +356,7 @@ HeyMan::whenYouHitRouteName('welcome.name')

#### 5- Check points:

You can also declare some check points some where, within your application code:
You can also declare some check points somewhere, within your application code:

```php

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -43,7 +43,8 @@
"imanghafoori/laravel-terminator": "Gives you opportunity to refactor your controllers."
},
"scripts": {
"test": "./vendor/bin/phpunit"
"test": "./vendor/bin/phpunit",
"imports": "./vendor/bin/check_imports"
},
"extra": {
"laravel": {
Expand Down
4 changes: 3 additions & 1 deletion tests/MethodCallReactionTest.php
Expand Up @@ -28,7 +28,9 @@ public function testCallingMethodsOnClasses()
$m = Mockery::mock(Logger::class);
$m->shouldReceive('error')->once()->with('sss');
$m->shouldReceive('info')->times(0);
app()->singleton(Logger::class, fn () => $m);
app()->singleton(Logger::class, function () use ($m) {
return $m;
});

HeyMan::whenYouVisitUrl(['welcome', 'welcome_'])
->thisValueShouldAllow(true)
Expand Down
6 changes: 4 additions & 2 deletions tests/Unit/ResponderTest.php
Expand Up @@ -2,8 +2,8 @@

namespace Imanghafoori\HeyManTests\Unit;

use Imanghafoori\HeyMan\Core\Chain;
use Illuminate\Support\Str;
use Imanghafoori\HeyMan\Core\Chain;
use Imanghafoori\HeyMan\Core\ChainCollection;
use Imanghafoori\HeyMan\Core\Reaction;
use Imanghafoori\HeyMan\Plugins\Reactions\Redirect\RedirectionMsg;
Expand Down Expand Up @@ -71,7 +71,9 @@ public function testRedirectMsg()
];

$m = Mockery::mock(Chain::class);
app()->singleton(Chain::class, fn () => $m);
app()->singleton(Chain::class, function () use ($m) {
return $m;
});

foreach ($methods as $method) {
$param = Str::random(2);
Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/YouShouldHaveTest.php
Expand Up @@ -89,7 +89,9 @@ public function testThisMethodShouldAllow()

$m = Mockery::mock(SomeClass::class);
$m->shouldReceive('someMethod')->once()->with('aaa')->andReturn(false);
app()->singleton(SomeClass::class, fn () => $m);
app()->singleton(SomeClass::class, function () use ($m) {
return $m;
});
$condition = app(Chain::class)->get('condition');

$this->assertTrue($condition() === false);
Expand Down

0 comments on commit 8a9bd98

Please sign in to comment.