Skip to content

Commit

Permalink
GitHub: Add test runner workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbearman committed Feb 15, 2024
1 parent ae0b8ae commit 6723a74
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ on:
pull_request:
paths:
- '**.php'
- 'pint.json'
push:
paths:
- '**.php'
- 'pint.json'
workflow_dispatch:

jobs:
php-code-styling:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Run Laravel Pint
uses: aglipanci/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'
coverage: none

- uses: ramsey/composer-install@v2
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: PHPUnit

on:
pull_request:
paths:
- '**.php'
- 'phpunit.xml.dist'
push:
paths:
- '**.php'
- 'phpunit.xml.dist'
workflow_dispatch:

jobs:
phpunit:
runs-on: ubuntu-latest

strategy:
matrix:
php:
- 8.2
- 8.3
dependencies:
- "highest"
- "lowest"

name: PHP ${{ matrix.php }} (dependency-versions - ${{ matrix.dependencies }})


steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, fileinfo
coverage: none

- uses: ramsey/composer-install@v2
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: Installed dependencies
run: composer show -D

- name: Run PHPUnit
run: ./vendor/bin/phpunit
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Eloquent Calamari

[![Latest Stable Version](https://poser.pugx.org/rossbearman/eloquent-calamari/v/stable?style=flat-square)](https://packagist.org/packages/rossbearman/eloquent-calamari)
[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Test Status](https://img.shields.io/github/actions/workflow/status/rossbearman/eloquent-calamari/phpunit.yml?label=tests&style=flat-square)](https://github.com/rossbearman/eloquent-calamari/actions/workflows/phpunit.yml?query=branch:main)
[![Analysis Status](https://img.shields.io/github/actions/workflow/status/rossbearman/eloquent-calamari/phpstan.yml?label=analysis&style=flat-square)](https://github.com/rossbearman/eloquent-calamari/actions/workflows/phpstan.yml?query=branch:main)
[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/rossbearman/eloquent-calamari/blob/main/LICENSE.md)

Eloquent Calamari integrates the [Sqids](https://sqids.org/php)[^1] algorithm into Laravel and Eloquent, enabling you to seamlessly use obfuscated, unique IDs in place of your internal auto-incrementing IDs.

Expand Down
16 changes: 9 additions & 7 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

namespace RossBearman\Sqids\Tests;

use Illuminate\Foundation\Application;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Routing\Router;
use Orchestra\Testbench\TestCase as OrchestraTestCase;
use RossBearman\Sqids\SqidsServiceProvider;
use RossBearman\Sqids\Tests\Testbench\Models\Calamari;
use RossBearman\Sqids\Tests\Testbench\Models\Ocean;
use RossBearman\Sqids\Tests\Testbench\Models\Squad;

class TestCase extends OrchestraTestCase
{
protected $enablesPackageDiscoveries = true;

protected function setUp(): void
{
parent::setUp();
Expand All @@ -25,11 +25,13 @@ protected function setUp(): void
$this->loadMigrationsFrom(__DIR__ . '/Testbench/database/migrations');
}

/**
* Define routes setup.
*
* @param Router $router
*/
protected function getPackageProviders($app): array
{
return [
SqidsServiceProvider::class,
];
}

protected function defineRoutes($router): void
{
$router->get('/calamari/{calamari}', function (Calamari $calamari) {
Expand Down

0 comments on commit 6723a74

Please sign in to comment.