Skip to content

Commit 8f3a9b9

Browse files
committed
feat(build): problem matcher for twig & icu errors
1 parent b9354b1 commit 8f3a9b9

File tree

5 files changed

+86
-3
lines changed

5 files changed

+86
-3
lines changed

.github/matchers/lint-icu.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "lint-icu",
5+
"fileLocation": "absolute",
6+
"pattern": [
7+
{
8+
"regexp": "^\\s(ERROR)\\s+in\\s+([^\\s]+\\.php)\\((\\d+)\\):\\s+(.+)$",
9+
"severity": 1,
10+
"file": 2,
11+
"line": 3,
12+
"message": 4
13+
}
14+
]
15+
}
16+
]
17+
}

.github/matchers/lint-twig.json

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "lint-twig1",
5+
"fileLocation": "relative",
6+
"pattern": [
7+
{
8+
"regexp": "^\\s+(ERROR|WARNING)\\s+in\\s(.+\\.twig)\\s\\(line\\s(\\d+)\\)$",
9+
"severity": 1,
10+
"file": 2,
11+
"line": 3
12+
},
13+
{ "regexp": "." }, { "regexp": "." }, { "regexp": ">>" },
14+
{
15+
"regexp": "^\\s+>>\\s(.+)$",
16+
"message": 1
17+
}
18+
]
19+
},
20+
{
21+
"owner": "lint-twig2",
22+
"fileLocation": "relative",
23+
"pattern": [
24+
{
25+
"regexp": "^\\s+(ERROR|WARNING)\\s+in\\s(.+\\.twig)\\s\\(line\\s(\\d+)\\)$",
26+
"severity": 1,
27+
"file": 2,
28+
"line": 3
29+
},
30+
{ "regexp": "." }, { "regexp": ">>" },
31+
{
32+
"regexp": "^\\s+>>\\s(.+)$",
33+
"message": 1
34+
}
35+
]
36+
},
37+
{
38+
"owner": "lint-twig3",
39+
"fileLocation": "relative",
40+
"pattern": [
41+
{
42+
"regexp": "^\\s+(ERROR|WARNING)\\s+in\\s(.+\\.twig)\\s\\(line\\s(\\d+)\\)$",
43+
"severity": 1,
44+
"file": 2,
45+
"line": 3
46+
},
47+
{ "regexp": ">>" },
48+
{
49+
"regexp": "^\\s+>>\\s(.+)$",
50+
"message": 1
51+
}
52+
]
53+
}
54+
]
55+
}

.github/workflows/build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
echo "::add-matcher::.github/matchers/phplint.json"
4343
echo "::add-matcher::.github/matchers/phpcs.json"
4444
echo "::add-matcher::.github/matchers/phpunit.json"
45+
echo "::add-matcher::.github/matchers/lint-twig.json"
46+
echo "::add-matcher::.github/matchers/lint-icu.json"
4547
4648
- name: Install dependencies
4749
run: composer install --prefer-dist --no-progress

src/Command/TranslationExtractCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
class TranslationExtractCommand extends Command
3939
{
4040
protected static $defaultName = 'translation:extract';
41-
protected const FORMAT = 'php';
41+
public const FORMAT = 'php';
4242
public const DOMAIN = 'messages';
4343
public const LOCALES = [
4444
'en',

src/Command/TranslationMissingCommand.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4949
{
5050
$io = new SymfonyStyle($input, $output);
5151
$debugCmd = $this->getApplication()->find('debug:translation');
52+
$domain = TranslationExtractCommand::DOMAIN;
53+
$format = TranslationExtractCommand::FORMAT;
5254
$args = [
53-
'--domain' => TranslationExtractCommand::DOMAIN,
55+
'--domain' => $domain,
5456
'--only-missing' => true,
5557
];
5658
$failures = [];
@@ -64,8 +66,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6466
$content = $out->fetch();
6567
if (str_contains($content, 'missing')) {
6668
$failures[] = $locale;
69+
$io->writeln("<error> ERROR </error> in translations/$domain+intl-icu.$locale.$format");
70+
$matches = [];
71+
preg_match_all("/^\\s*missing\\s+(fallback\\s+)?$domain\\s+([^\\s].+)\\s{3}.*$/Um", $content, $matches);
72+
foreach ($matches[2] as $line) {
73+
$str = var_export($line, true);
74+
$io->writeln("missing: $str");
75+
}
76+
$io->writeln('');
6777
}
68-
$io->write($content);
6978
}
7079
if (sizeof($failures) === 0) {
7180
$io->success('The translations are up to date.');

0 commit comments

Comments
 (0)