PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / trunk
Matomo Analytics – Powerful, Privacy-First Insights for WordPress vtrunk
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / vendor / prefixed / symfony / console / CI / GithubActionReporter.php
matomo / app / vendor / prefixed / symfony / console / CI Last commit date
GithubActionReporter.php 1 year ago
GithubActionReporter.php
77 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace Matomo\Dependencies\Symfony\Component\Console\CI;
12
13 use Matomo\Dependencies\Symfony\Component\Console\Output\OutputInterface;
14 /**
15 * Utility class for Github actions.
16 *
17 * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
18 */
19 class GithubActionReporter
20 {
21 private $output;
22 /**
23 * @see https://github.com/actions/toolkit/blob/5e5e1b7aacba68a53836a34db4a288c3c1c1585b/packages/core/src/command.ts#L80-L85
24 */
25 private const ESCAPED_DATA = ['%' => '%25', "\r" => '%0D', "\n" => '%0A'];
26 /**
27 * @see https://github.com/actions/toolkit/blob/5e5e1b7aacba68a53836a34db4a288c3c1c1585b/packages/core/src/command.ts#L87-L94
28 */
29 private const ESCAPED_PROPERTIES = ['%' => '%25', "\r" => '%0D', "\n" => '%0A', ':' => '%3A', ',' => '%2C'];
30 public function __construct(OutputInterface $output)
31 {
32 $this->output = $output;
33 }
34 public static function isGithubActionEnvironment() : bool
35 {
36 return \false !== getenv('GITHUB_ACTIONS');
37 }
38 /**
39 * Output an error using the Github annotations format.
40 *
41 * @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
42 */
43 public function error(string $message, ?string $file = null, ?int $line = null, ?int $col = null) : void
44 {
45 $this->log('error', $message, $file, $line, $col);
46 }
47 /**
48 * Output a warning using the Github annotations format.
49 *
50 * @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message
51 */
52 public function warning(string $message, ?string $file = null, ?int $line = null, ?int $col = null) : void
53 {
54 $this->log('warning', $message, $file, $line, $col);
55 }
56 /**
57 * Output a debug log using the Github annotations format.
58 *
59 * @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-a-debug-message
60 */
61 public function debug(string $message, ?string $file = null, ?int $line = null, ?int $col = null) : void
62 {
63 $this->log('debug', $message, $file, $line, $col);
64 }
65 private function log(string $type, string $message, ?string $file = null, ?int $line = null, ?int $col = null) : void
66 {
67 // Some values must be encoded.
68 $message = strtr($message, self::ESCAPED_DATA);
69 if (!$file) {
70 // No file provided, output the message solely:
71 $this->output->writeln(sprintf('::%s::%s', $type, $message));
72 return;
73 }
74 $this->output->writeln(sprintf('::%s file=%s,line=%s,col=%s::%s', $type, strtr($file, self::ESCAPED_PROPERTIES), strtr($line ?? 1, self::ESCAPED_PROPERTIES), strtr($col ?? 0, self::ESCAPED_PROPERTIES), $message));
75 }
76 }
77