@@ -66,10 +66,39 @@ public function test(
6666 #[DefaultPath('. ' )] Directory $ source ,
6767 string $ phpVersion = '8.4 ' ,
6868 string $ dependencyVersion = 'highest ' ,
69- ): string {
70- return $ this
69+ ?string $ coverallsRepoToken = null ,
70+ ?string $ ciName = null ,
71+ ?string $ ciJobId = null ,
72+ ?string $ ciBranch = null ,
73+ ): string
74+ {
75+ $ container = $ this
7176 ->build ($ source , $ phpVersion , $ dependencyVersion )
72- ->withExec (['php ' , './vendor/bin/phpunit ' , '--coverage-text ' ])
77+ ->withFile ('/tmp/coveralls-linux.tar.gz ' , dag ()->http ('https://coveralls.io/coveralls-linux.tar.gz ' ))
78+ ->withExec (['tar ' , '-xvzf ' , '/tmp/coveralls-linux.tar.gz ' , '-C ' , '/usr/local/bin ' ]);
79+
80+
81+ $ exec = ['php ' , './vendor/bin/phpunit ' , '--coverage-text ' ];
82+ if ($ coverallsRepoToken ) {
83+ $ exec [] = '--coverage-clover=build/logs/clover.xml ' ;
84+
85+ $ container = $ container ->withEnvVariable ('COVERALLS_REPO_TOKEN ' , $ coverallsRepoToken );
86+ }
87+
88+ if ($ ciName && $ ciJobId && $ ciBranch ) {
89+ $ container = $ container
90+ ->withEnvVariable ('CI_NAME ' , $ ciName )
91+ ->withEnvVariable ('CI_JOB_ID ' , $ ciJobId )
92+ ->withEnvVariable ('CI_BRANCH ' , $ ciBranch );
93+ }
94+
95+ $ container = $ container ->withExec ($ exec );
96+
97+ if ($ coverallsRepoToken ) {
98+ $ container = $ container ->withExec (['coveralls ' , 'report ' ]);
99+ }
100+
101+ return $ container
73102 ->stdout ();
74103 }
75104
0 commit comments