Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces
name: CI

on:
pull_request:
push:
branches:
- main
- master

jobs:
tests:
name: Test with PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}
runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
- '8.4'
coverage: ['pcov']
dependencies: ['']

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: ${{ matrix.coverage }}
tools: composer:v2

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/composer
key: composer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ matrix.php-version }}-
composer-

- name: Install dependencies
run: |
composer update --prefer-dist --no-interaction --no-progress ${{ matrix.dependencies }}

- name: Lint and test
run: |
vendor/bin/parallel-lint --exclude .git --exclude app --exclude vendor .
vendor/bin/phpunit --migrate-configuration || true
vendor/bin/phpunit --testdox
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"org\\apache\\hadoop\\": "src/",
"org\\apache\\hadoop\\tools": "app/models/"
}
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpunit/phpunit": ">4 <12"
}

}
8 changes: 8 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
33 changes: 33 additions & 0 deletions tests/StaticAnalysisTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use PHPUnit\Framework\TestCase;

/**
* @coversNothing
*/
class StaticAnalysisTest extends TestCase
{
public static function provideFiles(): iterable
{
$directory = new RecursiveDirectoryIterator('./src/');
$iterator = new RecursiveIteratorIterator($directory);
$regexIterator = new RegexIterator($iterator, '/\.php$/');

foreach ($regexIterator as $file) {
/** @var SplFileInfo $file */
$filePath = $file->getRealPath();
$relativePath = str_replace(getcwd(), '.', $filePath);

yield $relativePath => [$relativePath];
}
}

/**
* @dataProvider provideFiles
*/
public function testFileIncludesSuccessfully($filename)
{
require $filename;
$this->addToAssertionCount(1); // Add a count for each successful inclusion
}
}