File tree Expand file tree Collapse file tree 7 files changed +44
-8
lines changed Expand file tree Collapse file tree 7 files changed +44
-8
lines changed Original file line number Diff line number Diff line change 1
1
name : CI
2
2
3
- on : [push, pull_request]
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ pull_request :
8
+ branches :
9
+ - ' *'
4
10
5
11
jobs :
6
12
testsuite :
Original file line number Diff line number Diff line change @@ -17,13 +17,16 @@ jobs:
17
17
- name : Setup PHP
18
18
uses : shivammathur/setup-php@v2
19
19
with :
20
- php-version : ' 8.2 '
20
+ php-version : ' 8.4 '
21
21
extensions : json, fileinfo
22
22
tools : composer
23
23
24
24
- name : Install dependencies
25
25
run : composer install --no-dev --optimize-autoloader
26
26
27
+ - name : Inject version from tag
28
+ run : sed -i "s/public const VERSION = .*/public const VERSION = '\${{ github.ref_name }}';/" src/Application.php
29
+
27
30
- name : Build PHAR
28
31
run : composer build-phar
29
32
Original file line number Diff line number Diff line change 10
10
.env
11
11
infection.log
12
12
phive.phar
13
- cognitive-analysis .phar
13
+ phpcca .phar
Original file line number Diff line number Diff line change 1
1
{
2
- "main": "./ bin/phpcca",
2
+ "main": "bin/phpcca",
3
3
"compression": "GZ",
4
4
"output": "phpcca.phar",
5
5
"force-autodiscovery": true,
6
+ "compactors": [
7
+ "KevinGH\\Box\\Compactor\\Json",
8
+ "KevinGH\\Box\\Compactor\\Php",
9
+ "KevinGH\\Box\\Compactor\\PhpScoper"
10
+ ],
6
11
"files": [
7
12
"config.yml",
8
13
"composer.json",
Original file line number Diff line number Diff line change
1
+ # Get the latest tag reachable from the previous commit
2
+ TAG=$( git describe --tags --abbrev=0 HEAD^ 2> /dev/null)
3
+
4
+ if [ -n " $TAG " ]; then
5
+ sed -i " s/public const VERSION = .*/public const VERSION = '$TAG ';/" src/Application.php
6
+ git add src/Application.php
7
+ echo " Version set to $TAG "
8
+ else
9
+ echo " No previous tag found."
10
+ fi
Original file line number Diff line number Diff line change 49
49
*/
50
50
class Application
51
51
{
52
+ public const VERSION = '1.3.0 ' ;
53
+
52
54
private ContainerBuilder $ containerBuilder ;
53
55
54
56
public function __construct ()
@@ -231,6 +233,10 @@ private function registerCommands(): void
231
233
private function configureApplication (): void
232
234
{
233
235
$ this ->containerBuilder ->register (SymfonyApplication::class, SymfonyApplication::class)
236
+ ->setArguments ([
237
+ 'Cognitive Code Analysis ' ,
238
+ self ::VERSION
239
+ ])
234
240
->setPublic (true )
235
241
->addMethodCall ('add ' , [new Reference (CognitiveMetricsCommand::class)])
236
242
->addMethodCall ('add ' , [new Reference (ChurnCommand::class)]);
Original file line number Diff line number Diff line change @@ -25,10 +25,7 @@ public function __construct(
25
25
26
26
public function __invoke (SourceFilesFound |FileProcessed $ event ): void
27
27
{
28
- if (
29
- $ this ->input ->hasOption (CognitiveMetricsCommand::OPTION_DEBUG )
30
- && $ this ->input ->getOption (CognitiveMetricsCommand::OPTION_DEBUG ) === false
31
- ) {
28
+ if (!$ this ->isDebugEnabled ()) {
32
29
return ;
33
30
}
34
31
@@ -62,4 +59,13 @@ private function formatBytes(int $size): string
62
59
63
60
return round ($ size , 2 ) . ' ' . $ units [$ index ];
64
61
}
62
+
63
+ /**
64
+ * @return bool
65
+ */
66
+ public function isDebugEnabled (): bool
67
+ {
68
+ return $ this ->input ->hasOption (CognitiveMetricsCommand::OPTION_DEBUG )
69
+ && $ this ->input ->getOption (CognitiveMetricsCommand::OPTION_DEBUG ) === false ;
70
+ }
65
71
}
You can’t perform that action at this time.
0 commit comments