diff --git a/.gitignore b/.gitignore index de300748c01..c85f8018040 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,7 @@ packaging/release/ansible_release /test/results/coverage/coverage* /test/results/reports/coverage.xml /test/results/reports/coverage/ +/test/results/bot/*.json /test/results/junit/*.xml /test/results/logs/*.log /test/integration/inventory.remote diff --git a/test/results/bot/.keep b/test/results/bot/.keep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/runner/lib/sanity.py b/test/runner/lib/sanity.py index ad554f20138..59b1b349e95 100644 --- a/test/runner/lib/sanity.py +++ b/test/runner/lib/sanity.py @@ -564,6 +564,7 @@ class SanityResult(object): :type args: SanityConfig """ self.write_console() + self.write_bot(args) if args.lint: self.write_lint() @@ -582,12 +583,33 @@ class SanityResult(object): """Write lint results to stdout.""" pass + def write_bot(self, args): + """ + :type args: SanityConfig + """ + pass + def write_junit(self, args): """ :type args: SanityConfig """ pass + def create_path(self, directory, extension): + """ + :type directory: str + :type extension: str + :rtype: str + """ + path = 'test/results/%s/ansible-test-%s' % (directory, self.test) + + if self.python_version: + path += '-python-%s' % self.python_version + + path += extension + + return path + def save_junit(self, args, test_case, properties=None): """ :type args: SanityConfig @@ -595,12 +617,7 @@ class SanityResult(object): :type properties: dict[str, str] | None :rtype: str | None """ - path = 'test/results/junit/ansible-test-%s' % self.test - - if self.python_version: - path += '-python-%s' % self.python_version - - path += '.xml' + path = self.create_path('junit', '.xml') test_suites = [ self.junit.TestSuite( @@ -704,9 +721,6 @@ class SanityFailure(SanityResult): title = self.format_title() output = self.format_block() - # Hack to remove ANSI color reset code from SubprocessError messages. - output = output.replace(display.clear, '') - test_case = self.junit.TestCase(classname='sanity', name=self.test) # Include a leading newline to improve readability on Shippable "Tests" tab. @@ -715,6 +729,31 @@ class SanityFailure(SanityResult): self.save_junit(args, test_case) + def write_bot(self, args): + """ + :type args: SanityConfig + """ + message = self.format_title() + output = self.format_block() + + bot_data = dict( + results=[ + dict( + message=message, + output=output, + ), + ], + ) + + path = self.create_path('bot', '.json') + + if args.explain: + return + + with open(path, 'wb') as bot_fd: + json.dump(bot_data, bot_fd, indent=4, sort_keys=True) + bot_fd.write('\n') + def format_command(self): """ :rtype: str @@ -752,6 +791,9 @@ class SanityFailure(SanityResult): message = block.strip() + # Hack to remove ANSI color reset code from SubprocessError messages. + message = message.replace(display.clear, '') + return message diff --git a/test/utils/shippable/shippable.sh b/test/utils/shippable/shippable.sh index 084175eaa79..05efc942def 100755 --- a/test/utils/shippable/shippable.sh +++ b/test/utils/shippable/shippable.sh @@ -35,6 +35,7 @@ function cleanup rmdir shippable/testresults/ cp -a test/results/junit/ shippable/testresults/ + cp -aT test/results/bot/ shippable/testresults/ } trap cleanup EXIT