Skip to content

Commit 0fb4ee3

Browse files
authored
Merge pull request #5 from sweptsquash/feat/ImprovementsAndTests
Improvements and tests
2 parents 7d4b89f + ddbc40b commit 0fb4ee3

20 files changed

+5171
-162
lines changed

.github/workflows/lint.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ jobs:
1212
with:
1313
ref: ${{ github.head_ref }}
1414

15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: 8.4
19+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
20+
coverage: none
21+
22+
- name: Get composer cache directory
23+
id: composer-cache
24+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
25+
26+
- name: Cache dependencies
27+
uses: actions/cache@v4
28+
with:
29+
path: ${{ steps.composer-cache.outputs.dir }}
30+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
31+
restore-keys: ${{ runner.os }}-composer-
32+
33+
- name: Install Composer dependencies
34+
run: |
35+
composer install --no-progress --no-scripts -n -o
36+
1537
- name: Fix PHP code style issues
1638
uses: aglipanci/[email protected]
1739
with:

.github/workflows/run-tests.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
php: [8.4, 8.3, 8.2, 8.1]
12+
dependency-version: [prefer-lowest, prefer-stable]
13+
14+
name: P${{ matrix.php }} - ${{ matrix.dependency-version }}
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
25+
coverage: none
26+
27+
- name: Get composer cache directory
28+
id: composer-cache
29+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
30+
31+
- name: Cache dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: ${{ steps.composer-cache.outputs.dir }}
35+
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
36+
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
37+
38+
- name: Setup Problem Matches
39+
run: |
40+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
41+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
42+
- name: Install dependencies
43+
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
44+
45+
- name: Execute tests
46+
run: vendor/bin/pest

README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
# lan-party-publisher-php
22

3-
This is a PHP library that implements the LAN party publishing standard, making it easy to pull your own list of events from your own database, and publish those to the world, in a standard format that can be consumed by other sites (like http://lanlist.info).
3+
This package enables the creation of the LAN party publishing standard, making it easy to pull your own list of events and publish those to the world in a standard format that can be consumed by other sites (like [LANList](http://lanlist.info/)).
44

55
## Using the PHP Library
66

7-
Normally you should put your calling script and the library in the same subdirectory to keep things together. You should not need to edit the library yourself, as it makes upgrades a real pain in the future. If there are problems with the library, just raise an issue on GitHub.
8-
9-
**Create a new folder for your publisher**, and `cd` into it.
10-
117
```shell
12-
user@host: mkdir lan-party-publishing-standard/
13-
user@host: composer require jamesread/lan-party-publisher-php
8+
composer require jamesread/lan-party-publisher-php
149
```
1510

16-
**Write a "calling script"** called "index.php" that that uses the library to build the list of JSON events. Look at the several [php examples](examples) to help get you started. The example below shows a simple `index.php` file using PDO to connect to a MySQL database.
17-
18-
**index.php** - Start with the example code; [withPdoMySQLDatabase.php](examples/withPdoMySQLDatabase.php)
19-
20-
Adapt the above code to your own database structure, and view the resulting JSON in your browser.
11+
Look at the [examples](examples) to help get you started.

composer.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
"composer-runtime-api": "^2.2"
1616
},
1717
"require-dev": {
18-
"phpstan/phpstan": "^1.11",
19-
"laravel/pint": "^1.18"
18+
"laravel/pint": "^1.18",
19+
"orchestra/testbench-core": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
20+
"pestphp/pest": "^1.22 || ^2.0",
21+
"phpstan/phpstan": "^1.10.57 || ^2.0.2",
22+
"phpunit/phpunit": "^9.3 || ^10.1"
2023
},
2124
"minimum-stability": "dev",
2225
"prefer-stable": true,
@@ -26,12 +29,16 @@
2629
}
2730
},
2831
"config": {
29-
"allow-plugins": {},
32+
"allow-plugins": {
33+
"pestphp/pest-plugin": true
34+
},
3035
"sort-packages": true
3136
},
3237
"scripts": {
3338
"analyse": "./vendor/bin/phpstan analyse --memory-limit=512M",
3439
"lint": "vendor/bin/pint --preset psr12",
35-
"lint:test": "vendor/bin/pint --preset psr12 --test"
40+
"lint:test": "vendor/bin/pint --preset psr12 --test",
41+
"test": "./vendor/bin/pest",
42+
"test:coverage": "vendor/bin/pest --coverage"
3643
}
3744
}

0 commit comments

Comments
 (0)