From 45bac8d4999d756d497f573d0d5bc173a19c7710 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Fri, 7 Feb 2025 18:15:36 +0900 Subject: [PATCH 1/6] Add GitHub Actions-based CI --- .github/workflows/main.yml | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..94e925b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,56 @@ +# 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 + run: | + vendor/bin/parallel-lint --exclude .git --exclude app --exclude vendor . + From 841e193458c95a265689c9b14c0afa4d0bb0ec1a Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Fri, 7 Feb 2025 18:29:54 +0900 Subject: [PATCH 2/6] Static analysis test --- .github/workflows/main.yml | 4 +++- composer.json | 5 ++++- phpunit.xml.dist | 12 ++++++++++++ tests/StaticAnalysisTest.php | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 phpunit.xml.dist create mode 100644 tests/StaticAnalysisTest.php diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 94e925b..3bdf1a0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,7 +50,9 @@ jobs: run: | composer update --prefer-dist --no-interaction --no-progress ${{ matrix.dependencies }} - - name: Lint + - name: Lint and test run: | vendor/bin/parallel-lint --exclude .git --exclude app --exclude vendor . + vendor/bin/phpunit --migrate-configuration + vendor/bin/phpunit --testdox diff --git a/composer.json b/composer.json index cfd42a2..50ffa51 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" } - } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..3d1e6b4 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,12 @@ + + + + + + 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 + } +} From 642b170a7c3a94ea75acbf112014cbc5ceca20c9 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Fri, 7 Feb 2025 18:31:53 +0900 Subject: [PATCH 3/6] CS --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3bdf1a0..fac710d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,4 +55,3 @@ jobs: vendor/bin/parallel-lint --exclude .git --exclude app --exclude vendor . vendor/bin/phpunit --migrate-configuration vendor/bin/phpunit --testdox - From f7b12aa70226178e9659a9d7ddd4501f532a1662 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Fri, 7 Feb 2025 18:33:18 +0900 Subject: [PATCH 4/6] Update phpunit.xml.dist --- phpunit.xml.dist | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3d1e6b4..028080c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,8 @@ - - - - - tests - - + + + + tests + + From 66745885ac316ac71b7225af2965376808f90b40 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Fri, 7 Feb 2025 18:33:51 +0900 Subject: [PATCH 5/6] Fix migrate-configuration --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fac710d..87b6c63 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,5 +53,5 @@ jobs: - name: Lint and test run: | vendor/bin/parallel-lint --exclude .git --exclude app --exclude vendor . - vendor/bin/phpunit --migrate-configuration + vendor/bin/phpunit --migrate-configuration || true vendor/bin/phpunit --testdox From 8a59395c058d99756628c0d383cf7721ff4b9a16 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Fri, 7 Feb 2025 18:35:43 +0900 Subject: [PATCH 6/6] Does not work with PHPUnit 12 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 50ffa51..cbc8068 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,6 @@ }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.4", - "phpunit/phpunit": ">4" + "phpunit/phpunit": ">4 <12" } }