Skip to content

Commit c424745

Browse files
committed
Prepend time to fireci log records.
Fixed some typos in the src.
1 parent eff44b3 commit c424745

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

ci/fireci/fireci/gradle.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import logging
1616
import os
1717
import subprocess
18-
import sys
1918

2019

2120
_logger = logging.getLogger('fireci.gradle')
@@ -39,9 +38,20 @@ def run(*args, gradle_opts='', workdir=None, check=True):
3938
command = ['./gradlew'] + list(args)
4039
_logger.info('Executing gradle command: "%s" in directory: "%s"',
4140
" ".join(command), workdir if workdir else '.')
42-
return subprocess.run(
41+
42+
with subprocess.Popen(
4343
command,
4444
cwd=workdir,
4545
env=new_env,
46-
check=check,
47-
)
46+
encoding='utf-8',
47+
stdout=subprocess.PIPE,
48+
stderr=subprocess.PIPE,
49+
) as p:
50+
while p.poll() is None:
51+
for line in p.stdout:
52+
_logger.info('[%s] [stdout] %s', p.pid, line.strip())
53+
for line in p.stderr:
54+
_logger.info('[%s] [stderr] %s', p.pid, line.strip())
55+
if check and p.returncode:
56+
raise subprocess.CalledProcessError(p.returncode, p.args, p.stdout, p.stderr)
57+
return subprocess.CompletedProcess(p.args, p.returncode, p.stdout, p.stderr)

ci/fireci/fireci/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
from . import plugins
1919
from .internal import main
2020

21+
2122
logging.basicConfig(
22-
format='%(name)s: [%(levelname)s] %(message)s',
23+
datefmt='%Y-%m-%d %H:%M:%S %z %Z',
24+
format='[%(levelname).1s] %(asctime)s %(name)s: %(message)s',
2325
level=logging.INFO,
2426
)
2527
logging.getLogger('fireci').setLevel(logging.DEBUG)

ci/fireci/tests/gradle_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
class GradleTest(unittest.TestCase):
2929

3030
@in_tempdir
31-
def test_when_gradle_suceeds_should_not_throw(self):
31+
def test_when_gradle_succeeds_should_not_throw(self):
3232
create_artifacts(
3333
Artifact('gradlew', content=scripts.with_exit(0), mode=0o744))
3434
self.assertEqual(gradle.run('tasks').returncode, 0)
3535

3636
@in_tempdir
37-
def test_when_gradle_suceeds_should_not_throw(self):
37+
def test_when_gradle_fails_should_throw(self):
3838
create_artifacts(
3939
Artifact('gradlew', content=scripts.with_exit(1), mode=0o744))
4040
self.assertRaises(subprocess.CalledProcessError,

ci/fireci/tests/integ_tests.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
1615
import pathlib
17-
import subprocess
1816
import unittest
1917

2018
from click.testing import CliRunner
@@ -41,7 +39,7 @@ def test_gradle_invocation(self):
4139
['./gradlew'] + args,
4240
{'GRADLE_OPTS': 'opts'},
4341
('sdk1/build/output/file1', 'content1'),
44-
('sdk1/build/outputss/file2', 'content2'),
42+
('sdk1/build/outputs/file2', 'content2'),
4543
),
4644
mode=0o744))
4745
result = self.runner.invoke(cli, [
@@ -53,7 +51,7 @@ def test_gradle_invocation(self):
5351
artifacts = pathlib.Path('_artifacts')
5452
self.assertTrue(artifacts.exists())
5553

56-
output_file = artifacts / 'sdk1_build_outputss' / 'file2'
54+
output_file = artifacts / 'sdk1_build_outputs' / 'file2'
5755
self.assertFalse(output_file.exists())
5856

5957
output_file = artifacts / 'sdk1_build_output' / 'file1'

0 commit comments

Comments
 (0)