Skip to content

Commit 5dfdf2a

Browse files
authored
Add timestamp to fireci logging headers. (#2790)
1 parent 1ad5e3a commit 5dfdf2a

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

ci/fireci/fireci/gradle.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import logging
1616
import os
1717
import subprocess
18-
import sys
19-
2018

2119
_logger = logging.getLogger('fireci.gradle')
2220

@@ -39,9 +37,19 @@ def run(*args, gradle_opts='', workdir=None, check=True):
3937
command = ['./gradlew'] + list(args)
4038
_logger.info('Executing gradle command: "%s" in directory: "%s"',
4139
" ".join(command), workdir if workdir else '.')
42-
return subprocess.run(
40+
41+
with subprocess.Popen(
4342
command,
4443
cwd=workdir,
4544
env=new_env,
46-
check=check,
47-
)
45+
stdout=subprocess.PIPE,
46+
stderr=subprocess.STDOUT,
47+
) as p:
48+
for line in p.stdout:
49+
_logger.info(line.decode().rstrip())
50+
51+
p.communicate()
52+
53+
if check and p.returncode:
54+
raise subprocess.CalledProcessError(p.returncode, p.args, p.stdout, p.stderr)
55+
return subprocess.CompletedProcess(p.args, p.returncode, p.stdout, p.stderr)

ci/fireci/fireci/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from .internal import main
2020

2121
logging.basicConfig(
22-
format='%(name)s: [%(levelname)s] %(message)s',
22+
datefmt='%Y-%m-%d %H:%M:%S %z %Z',
23+
format='[%(levelname).1s] %(asctime)s %(name)s: %(message)s',
2324
level=logging.INFO,
2425
)
2526
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)