Skip to content

Commit f3a8725

Browse files
committed
adding tests and github action
1 parent f0130c1 commit f3a8725

22 files changed

+467
-38
lines changed

.github/workflows/tests.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
php: ['8.3', '8.4', '8.5']
17+
18+
name: PHP ${{ matrix.php }}
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php }}
27+
extensions: redis
28+
coverage: none
29+
30+
- name: Install dependencies
31+
run: composer install --no-interaction --prefer-dist
32+
33+
- name: Run tests
34+
run: vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/.phpunit.cache/
44
.idea/
55
.DS_Store
6+
.phpcs-cache

.phpcs-cache

Lines changed: 0 additions & 1 deletion
This file was deleted.

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:8.5-cli
2+
3+
WORKDIR /app
4+
5+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
6+
7+
# Install PHP extensions
8+
RUN install-php-extensions redis

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# airlock-php
2+
![Tests](https://github.com/clegginabox/airlock-php/actions/workflows/tests.yaml/badge.svg)
23

34
A distributed mutex with civilized waiting
45

Taskfile.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
version: '3'
22

33
tasks:
4+
test:
5+
desc: Runs all tests
6+
cmds:
7+
- docker run --rm -v $(pwd):/app -v /var/run/docker.sock:/var/run/docker.sock airlock php vendor/bin/phpunit
8+
49
phpstan:
510
desc: Runs PHPStan
611
cmds:

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@
3737
"slevomat/coding-standard": "^8.26",
3838
"squizlabs/php_codesniffer": "^4.0",
3939
"symfony/framework-bundle": "^8.0",
40-
"symfony/mercure": "^0.7.2"
40+
"symfony/mercure": "^0.7.2",
41+
"testcontainers/testcontainers": "^1.0"
4142
},
4243
"suggest": {
4344
"symfony/mercure": "Required to use the MercureAirlockNotifier."
4445
},
4546
"config": {
4647
"sort-packages": true,
4748
"allow-plugins": {
48-
"dealerdirect/phpcodesniffer-composer-installer": true
49+
"dealerdirect/phpcodesniffer-composer-installer": true,
50+
"php-http/discovery": true
4951
}
5052
},
5153
"minimum-stability": "stable"

phpunit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
4+
bootstrap="tests/bootstrap.php"
55
colors="true"
66
cacheDirectory=".phpunit.cache">
77
<testsuites>
@@ -14,4 +14,4 @@
1414
<directory>src</directory>
1515
</include>
1616
</source>
17-
</phpunit>
17+
</phpunit>

src/Bridge/Amphp/Seal/AmpMutexSeal.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public function __construct(
2828
private readonly Mutex $mutex,
2929
private readonly string $resource = 'airlock',
3030
private readonly ?float $ttlInSeconds = null, // optional "soft TTL" you enforce yourself
31-
) {}
31+
) {
32+
}
3233

3334
public function tryAcquire(): ?string
3435
{

src/Bridge/Laravel/Seal/LaravelAtomicLockSeal.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
declare(strict_types=1);
44

5-
65
namespace Clegginabox\Airlock\Bridge\Laravel\Seal;
76

8-
class LaravelAtomicLockSeal {}
7+
class LaravelAtomicLockSeal
8+
{
9+
}

0 commit comments

Comments
 (0)