Skip to content

Commit a6c4290

Browse files
Add StopWords tests and improve CI workflow
1 parent 7740538 commit a6c4290

File tree

5 files changed

+389
-5
lines changed

5 files changed

+389
-5
lines changed

.github/workflows/test.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,29 @@ on:
99
permissions:
1010
contents: read
1111

12-
jobs:
13-
build:
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
1415

16+
jobs:
17+
test:
1518
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
php: ['8.1', '8.3', '8.4', '8.5']
23+
24+
name: PHP ${{ matrix.php }}
1625

1726
steps:
18-
- uses: actions/checkout@v4
27+
- name: Checkout
28+
uses: actions/checkout@v5
29+
30+
- name: Setup PHP
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php }}
34+
coverage: pcov
1935

2036
- name: Validate composer.json and composer.lock
2137
run: composer validate --strict
@@ -37,3 +53,11 @@ jobs:
3753

3854
- name: Run test suite
3955
run: composer run-script test
56+
57+
- name: Run test suite with coverage
58+
run: ./vendor/bin/phpunit --coverage-clover coverage.xml
59+
60+
- name: Upload coverage to Codecov
61+
uses: codecov/codecov-action@v4
62+
with:
63+
files: coverage.xml

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ composer.lock
44

55
# PHPUnit
66
.phpunit.result.cache
7-
.phpunit.cache/
7+
.phpunit.cache/
8+
9+
# Coverage
10+
.coverage/

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
"test" : [
2626
"vendor/bin/phpunit"
2727
],
28+
"coverage": [
29+
"vendor/bin/phpunit --coverage-html .coverage/"
30+
],
2831
"phpstan": [
2932
"vendor/bin/phpstan analyse -l 5 src tests benchmark"
3033
]

src/BM25/StopWords/FileStopWords.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getStopWords(): array
5959
*/
6060
private function loadFromFile(): array
6161
{
62-
$content = file_get_contents($this->filePath);
62+
$content = @file_get_contents($this->filePath);
6363
if ($content === false) {
6464
throw new \RuntimeException(
6565
sprintf('Failed to read stop words file: %s', $this->filePath)

0 commit comments

Comments
 (0)