diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..87b6c63 --- /dev/null +++ b/.github/workflows/main.yml @@ -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 diff --git a/composer.json b/composer.json index cfd42a2..cbc8068 100644 --- a/composer.json +++ b/composer.json @@ -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" } - } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..028080c --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,8 @@ + + + + + tests + + + diff --git a/tests/StaticAnalysisTest.php b/tests/StaticAnalysisTest.php new file mode 100644 index 0000000..507a7a0 --- /dev/null +++ b/tests/StaticAnalysisTest.php @@ -0,0 +1,33 @@ +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 + } +}