-
Notifications
You must be signed in to change notification settings - Fork 1
Initial PR to send scheduled reports to a Slack channel, #PG-4491 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5e707e7
Initial PR to send scheduled reports to a Slack channel, #PG-4491
AltamashShaikh edadd47
test fixes
AltamashShaikh 6e8dd35
Added UI test
AltamashShaikh 699a841
updated UI screenshot
AltamashShaikh 30720e9
Fixes for test
AltamashShaikh d3629e1
Test fix
AltamashShaikh 1b674ec
Test fixes
AltamashShaikh 0158fca
UI test fixes
AltamashShaikh 99c5115
Fixes UI test
AltamashShaikh 70e3172
Ui test
AltamashShaikh ed18883
Updated UI screenshot
AltamashShaikh 2349db0
Image uodated
AltamashShaikh 8bec9b9
UI screenshot updated
AltamashShaikh 862733f
Applied PR feedback
AltamashShaikh 67c420f
Fixes UI test
AltamashShaikh f5b5c2a
Fix typo
AltamashShaikh 3cf03a3
Adds missing group and updated UI screenshot
AltamashShaikh 5e47178
adds code for display and evolution graph to work
AltamashShaikh c74d2d2
Fixes failing tests
AltamashShaikh 35cd206
Updated code to send file to multiple slack channels
AltamashShaikh ebbbc48
Adds PHPStan to Slack plugin (#2)
AltamashShaikh 37fd322
Release date updated
AltamashShaikh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Action for running tests | ||
| # This file has been automatically created. | ||
| # To recreate it you can run this command | ||
| # ./console generate:test-action --plugin="Slack" --php-versions="7.2,8.4" --schedule-cron="0 5 * * 6" | ||
|
|
||
| name: Plugin Slack Tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
| push: | ||
| branches: | ||
| - '**.x-dev' | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: "0 5 * * 6" | ||
|
|
||
| permissions: | ||
| actions: read | ||
| checks: none | ||
| contents: read | ||
| deployments: none | ||
| issues: read | ||
| packages: none | ||
| pull-requests: read | ||
| repository-projects: none | ||
| security-events: none | ||
| statuses: none | ||
|
|
||
| concurrency: | ||
| group: php-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| PluginTests: | ||
| runs-on: ubuntu-24.04 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| php: [ '7.2', '8.4' ] | ||
| target: ['minimum_required_matomo', 'maximum_supported_matomo'] | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| lfs: true | ||
| 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: 'Slack' | ||
| php-version: ${{ matrix.php }} | ||
| test-type: 'PluginTests' | ||
| matomo-test-branch: ${{ matrix.target }} | ||
| redis-service: true | ||
| artifacts-pass: ${{ secrets.ARTIFACTS_PASS }} | ||
| upload-artifacts: ${{ matrix.php == '7.2' && matrix.target == 'maximum_supported_matomo' }} | ||
| UI: | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| lfs: true | ||
| persist-credentials: false | ||
| - name: running tests | ||
| uses: matomo-org/github-action-tests@main | ||
| with: | ||
| plugin-name: 'Slack' | ||
| matomo-test-branch: 'maximum_supported_matomo' | ||
| test-type: 'UI' | ||
| php-version: '7.2' | ||
| node-version: '16' | ||
| redis-service: true | ||
| artifacts-pass: ${{ secrets.ARTIFACTS_PASS }} | ||
| upload-artifacts: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: PHPCS check | ||
|
|
||
| on: pull_request | ||
|
|
||
| permissions: | ||
| actions: read | ||
| checks: read | ||
| contents: read | ||
| deployments: none | ||
| issues: read | ||
| packages: none | ||
| pull-requests: read | ||
| repository-projects: none | ||
| security-events: none | ||
| statuses: read | ||
|
|
||
| jobs: | ||
| phpcs: | ||
| name: PHPCS | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| lfs: false | ||
| persist-credentials: false | ||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '7.4' | ||
| tools: cs2pr | ||
| - name: Install dependencies | ||
| run: | ||
| composer init --name=matomo/slack --quiet; | ||
| composer --no-plugins config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true -n; | ||
| composer config repositories.matomo-coding-standards vcs https://github.com/matomo-org/matomo-coding-standards -n; | ||
| composer require matomo-org/matomo-coding-standards:dev-master; | ||
| composer install --dev --prefer-dist --no-progress --no-suggest | ||
| - name: Check PHP code styles | ||
| id: phpcs | ||
| run: ./vendor/bin/phpcs --report-full --standard=phpcs.xml --report-checkstyle=./phpcs-report.xml | ||
| - name: Show PHPCS results in PR | ||
| if: ${{ always() && steps.phpcs.outcome == 'failure' }} | ||
| run: cs2pr ./phpcs-report.xml --prepend-filename | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /tests/System/processed/ | ||
| /tests/Integration/Importers/processed/ | ||
| /tests/UI/processed-ui-screenshots/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ## Changelog | ||
|
|
||
| 5.0.0 - 2025-09-01 | ||
| - Initial release to send scheduled reports to a Slack channel |
AltamashShaikh marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Matomo - free/libre analytics platform | ||
| * | ||
| * @link https://matomo.org | ||
| * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
| */ | ||
|
|
||
AltamashShaikh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Piwik\Plugins\Slack; | ||
|
|
||
| class ScheduleReportSlack | ||
| { | ||
| /** | ||
| * @var string | ||
| */ | ||
| private $subject; | ||
| /** | ||
| * @var string | ||
| */ | ||
| private $fileName; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| private $fileContents; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| private $channel; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| private $token; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
|
|
||
| public function __construct( | ||
| string $subject, | ||
| string $fileName, | ||
| string $fileContents, | ||
| string $channel, | ||
| #[\SensitiveParameter] | ||
| string $token | ||
| ) { | ||
AltamashShaikh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $this->subject = $subject; | ||
| $this->fileName = $fileName; | ||
| $this->fileContents = $fileContents; | ||
| $this->channel = $channel; | ||
| $this->token = $token; | ||
| } | ||
|
|
||
| public function send(): bool | ||
| { | ||
| $slackApi = new SlackApi($this->token); | ||
| return $slackApi->uploadFile($this->subject, $this->fileName, $this->fileContents, $this->channel); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.