From 99520cbe9fbc92f6e117e353743443557c942049 Mon Sep 17 00:00:00 2001 From: Altamash Shaikh Date: Tue, 12 Mar 2024 04:13:05 +0530 Subject: [PATCH 1/2] Added tests to check direct use of core dependencies, #PG-3334 --- .github/workflows/matomo-tests.yml | 2 + .../CheckDirectDependencyUseCommandTest.php | 53 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tests/System/CheckDirectDependencyUseCommandTest.php diff --git a/.github/workflows/matomo-tests.yml b/.github/workflows/matomo-tests.yml index 2413de5..00d1d54 100644 --- a/.github/workflows/matomo-tests.yml +++ b/.github/workflows/matomo-tests.yml @@ -39,6 +39,8 @@ jobs: with: lfs: true persist-credentials: false + - name: Install package ripgrep + run: sudo apt-get install ripgrep - name: running tests uses: matomo-org/github-action-tests@main with: diff --git a/tests/System/CheckDirectDependencyUseCommandTest.php b/tests/System/CheckDirectDependencyUseCommandTest.php new file mode 100644 index 0000000..60c53bc --- /dev/null +++ b/tests/System/CheckDirectDependencyUseCommandTest.php @@ -0,0 +1,53 @@ +markTestSkipped('tests:check-direct-dependency-use is not available in this version'); + } + + $pluginName = 'InvalidateReports'; + $checkDirectDependencyUse = new CheckDirectDependencyUse(); + + $console = new \Piwik\Console(self::$fixture->piwikEnvironment); + $console->addCommands([$checkDirectDependencyUse]); + $command = $console->find('tests:check-direct-dependency-use'); + $arguments = [ + 'command' => 'tests:check-direct-dependency-use', + '--plugin' => $pluginName, + '--grep-vendor', + ]; + + $inputObject = new ArrayInput($arguments); + $command->run($inputObject, new NullOutput()); + + $this->assertEquals([ + 'Symfony\Component\Console' => [ + 'InvalidateReports/tests/System/CheckDirectDependencyUseCommandTest.php' + ], + ], $checkDirectDependencyUse->usesFoundList[$pluginName]); + } +} \ No newline at end of file From dca0420e376d33a707235d8b431e4945a3578de6 Mon Sep 17 00:00:00 2001 From: Altamash Shaikh Date: Tue, 12 Mar 2024 04:24:52 +0530 Subject: [PATCH 2/2] Updated yml file to run tests --- .github/workflows/matomo-tests.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/matomo-tests.yml b/.github/workflows/matomo-tests.yml index 00d1d54..5dfd3dc 100644 --- a/.github/workflows/matomo-tests.yml +++ b/.github/workflows/matomo-tests.yml @@ -32,8 +32,13 @@ concurrency: cancel-in-progress: true jobs: - UI: + PluginTests: runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + php: [ '7.2', '8.2' ] + target: ['minimum_required_matomo', 'maximum_supported_matomo'] steps: - uses: actions/checkout@v3 with: @@ -41,10 +46,26 @@ jobs: persist-credentials: false - name: Install package ripgrep run: sudo apt-get install ripgrep + - name: Run tests + uses: matomo-org/github-action-tests@main + with: + plugin-name: 'InvalidateReports' + php-version: ${{ matrix.php }} + test-type: 'PluginTests' + matomo-test-branch: ${{ matrix.target }} + artifacts-pass: ${{ secrets.ARTIFACTS_PASS }} + upload-artifacts: ${{ matrix.php == '7.2' && matrix.target == 'maximum_supported_matomo' }} + artifacts-protected: true + UI: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + lfs: true + persist-credentials: false - name: running tests uses: matomo-org/github-action-tests@main with: - testomatio: ${{ secrets.TESTOMATIO }} plugin-name: 'InvalidateReports' matomo-test-branch: 'maximum_supported_matomo' test-type: 'UI'