Skip to content

Commit 6b5a45b

Browse files
authored
Merge pull request #4 from Lomkit/feature/unit-tests
Feature/unit tests
2 parents ea12db5 + 47c0f65 commit 6b5a45b

File tree

5 files changed

+151
-1
lines changed

5 files changed

+151
-1
lines changed

.github/ISSUE_TEMPLATE/Bug_report.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Bug Report
2+
description: "Report something that's broken."
3+
body:
4+
- type: input
5+
attributes:
6+
label: Laravel Rest Api Version
7+
description: Provide the Laravel Rest Api version that you are using.
8+
placeholder: 1.0.0
9+
validations:
10+
required: true
11+
- type: input
12+
attributes:
13+
label: Laravel Version
14+
description: Provide the Laravel version that you are using.
15+
placeholder: 10.4.1
16+
validations:
17+
required: true
18+
- type: input
19+
attributes:
20+
label: PHP Version
21+
description: Provide the PHP version that you are using.
22+
placeholder: 8.1.4
23+
validations:
24+
required: true
25+
- type: input
26+
attributes:
27+
label: Database Driver & Version
28+
description: If applicable, provide the database driver and version you are using.
29+
placeholder: "MySQL 8.0.31 for macOS 13.0 on arm64 (Homebrew)"
30+
validations:
31+
required: false
32+
- type: textarea
33+
attributes:
34+
label: Description
35+
description: Provide a detailed description of the issue you are facing.
36+
validations:
37+
required: true
38+
- type: textarea
39+
attributes:
40+
label: Steps To Reproduce
41+
description: Provide detailed steps to reproduce your issue. If necessary, please provide a GitHub repository to demonstrate your issue.
42+
validations:
43+
required: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Question / Enchancement proposal
2+
description: "Ask a question or for a feature"
3+
body:
4+
- type: textarea
5+
attributes:
6+
label: Description
7+
description: Leave a comment
8+
validations:
9+
required: true

.github/ISSUE_TEMPLATE/config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Documentation issue
4+
url: https://github.com/Lomkit/laravel-rest-api-doc
5+
about: For documentation issues, open a pull request at the lomkit/laravel-rest-api-doc repository

.github/workflows/tests.yml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches: [ master, next ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
php-version: [ '8.1', '8.2', '8.3' ]
18+
laravel-version: [ '^10.0' ]
19+
database: [ 'sqlite', 'mysql', 'pgsql' ]
20+
21+
name: Tests on PHP ${{ matrix.php-version }} with Laravel ${{ matrix.laravel-version }} and ${{ matrix.database }}
22+
23+
services:
24+
mysql:
25+
image: mysql:8
26+
env:
27+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
28+
MYSQL_DATABASE: rest
29+
ports:
30+
- 3306:3306
31+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
32+
33+
pgsql:
34+
image: postgres:16
35+
env:
36+
POSTGRES_USER: postgres
37+
POSTGRES_PASSWORD: postgres
38+
POSTGRES_DB: rest
39+
ports:
40+
- 5432:5432
41+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
42+
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v3
46+
47+
- name: Setup PHP
48+
uses: shivammathur/setup-php@v2
49+
with:
50+
php-version: ${{ matrix.php-version }}
51+
coverage: none
52+
53+
- name: Validate composer.json and composer.lock
54+
run: composer validate
55+
56+
- name: Cache Composer packages
57+
id: composer-cache
58+
uses: actions/cache@v3
59+
with:
60+
path: vendor
61+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}-${{ hashFiles('**/composer.lock') }}
62+
restore-keys: |
63+
${{ runner.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}-
64+
65+
- name: Install dependencies
66+
if: steps.composer-cache.outputs.cache-hit != 'true'
67+
run: composer require laravel/framework:${{ matrix.laravel-version }} -W --prefer-dist --no-progress
68+
69+
- name: Run test suite with Sqlite
70+
if: matrix.database == 'sqlite'
71+
run: vendor/bin/phpunit
72+
env:
73+
DB_CONNECTION: sqlite
74+
DB_DATABASE: ':memory:'
75+
76+
- name: Run test suite with MySQL
77+
if: matrix.database == 'mysql'
78+
run: vendor/bin/phpunit
79+
env:
80+
DB_CONNECTION: mysql
81+
DB_PORT: ${{ job.services.mysql.ports[3306] }}
82+
DB_DATABASE: rest
83+
DB_USERNAME: root
84+
85+
- name: Run test suite with PostgreSQL
86+
if: matrix.database == 'pgsql'
87+
run: vendor/bin/phpunit
88+
env:
89+
DB_CONNECTION: pgsql
90+
DB_PORT: ${{ job.services.pgsql.ports[5432] }}
91+
DB_DATABASE: rest
92+
DB_USERNAME: postgres
93+
DB_PASSWORD: postgres

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^8.0",
13+
"php": "^8.1",
1414
"ext-json": "*",
1515
"laravel/framework": "^10.0"
1616
},

0 commit comments

Comments
 (0)