Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add patterns to extract various warning pattern #509

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dirk-thomas
Copy link
Member

@dirk-thomas dirk-thomas commented Aug 27, 2020

Fixes #418.

Atm various kind of warnings are present in the job output (specifically the stderr log of the test invocation) but being ignored.

This patch adds multiple patterns to each job to match different kinds of warnings:

  • memory leaks reported by foonathan
  • pytest warnings - with/without a reference to a specific file:lineno
  • Python deprecation warnings

These pattern cover all the cases mentioned in #447 (comment):

In order to work the Jenkins master needs to define the following custom Groovy parsers in io.jenkins.plugins.analysis.warnings.groovy.ParserConfiguration.xml:

<?xml version='1.1' encoding='UTF-8'?>
<io.jenkins.plugins.analysis.warnings.groovy.ParserConfiguration plugin="[email protected]">
  <parsers>
    <io.jenkins.plugins.analysis.warnings.groovy.GroovyParser>
      <id>foonathan-memory-leaks</id>
      <name>foonathan memory leaks</name>
      <regexp>^\[foonathan::memory\] Allocator foonathan::memory::(?&lt;allocator&gt;[^ ]+).* leaked (?&lt;amount&gt;.+)\.$</regexp>
      <script>import edu.hm.hafner.analysis.Severity
builder.setCategory(&quot;foonathan::memory&quot;)
    .setMessage(matcher.group(&quot;amount&quot;))
    .setSeverity(Severity.WARNING_NORMAL)
    .setType(matcher.group(&quot;allocator&quot;))
return builder.buildOptional();</script>
      <example>[foonathan::memory] Allocator foonathan::memory::new_allocator (at 0000000000000000) leaked 3840 bytes.</example>
    </io.jenkins.plugins.analysis.warnings.groovy.GroovyParser>
    <io.jenkins.plugins.analysis.warnings.groovy.GroovyParser>
      <id>pytest-warnings</id>
      <name>pytest warnings</name>
      <regexp>^(?&lt;path&gt;[^ ]+\.py)::(?&lt;function&gt;[^ ]+)\n  Warning: (?&lt;message&gt;.+)\n$</regexp>
      <script>import edu.hm.hafner.analysis.Severity
builder.setFileName(matcher.group(&quot;path&quot;))
    .setCategory(matcher.group(&quot;function&quot;))
    .setMessage(matcher.group(&quot;message&quot;))
    .setSeverity(Severity.WARNING_NORMAL)
    .setType(&quot;Warning&quot;)
return builder.buildOptional();</script>
      <example>test/test_launch_ros/actions/test_composable_node_container.py::test_composable_node_container
  Warning: unclosed event loop &lt;ProactorEventLoop running=False closed=False debug=False&gt;

</example>
    </io.jenkins.plugins.analysis.warnings.groovy.GroovyParser>
    <io.jenkins.plugins.analysis.warnings.groovy.GroovyParser>
      <id>pytest-warnings-with-location</id>
      <name>pytest warnings with location</name>
      <regexp>^(?&lt;testpath&gt;[^ ]+\.py)::(?&lt;function&gt;[^ ]+)\n  (?&lt;path&gt;[^:]*.py):(?&lt;lineno&gt;\d+): (?&lt;type&gt;[^:]+Warning): (?&lt;message&gt;.+(\n    .+)*)\n$</regexp>
      <script>import edu.hm.hafner.analysis.Severity
builder.setFileName(matcher.group(&quot;path&quot;))
        .setLineStart(Integer.parseInt(matcher.group(&quot;lineno&quot;)))
        .setCategory(matcher.group(&quot;function&quot;))
        .setMessage(matcher.group(&quot;message&quot;))
        .setSeverity(Severity.WARNING_NORMAL)
        .setType(matcher.group(&quot;type&quot;))
return builder.buildOptional();</script>
      <example>test/test_launch_ros/actions/test_node.py::TestNode::test_launch_node_with_parameter_descriptions
  /home/jenkins-agent/workspace/nightly_linux_debug/ws/src/ros2/launch_ros/test_launch_ros/test/test_launch_ros/actions/test_node.py:186: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
    parameters.append((name, yaml.load(value)))
</example>
    </io.jenkins.plugins.analysis.warnings.groovy.GroovyParser>
    <io.jenkins.plugins.analysis.warnings.groovy.GroovyParser>
      <id>python-deprecation-warnings</id>
      <name>Python deprecation warnings</name>
      <regexp>^Warning: (?&lt;message&gt;.+ is deprecated.+(\n.+)*)\n$</regexp>
      <script>import edu.hm.hafner.analysis.Severity
builder.setCategory(&quot;Python deprecation warning&quot;)
    .setMessage(matcher.group(&quot;message&quot;))
    .setSeverity(Severity.WARNING_NORMAL)
return builder.buildOptional();</script>
      <example>Warning: The TerminalReporter.writer attribute is deprecated, use TerminalReporter._tw instead at your own risk.
See https://docs.pytest.org/en/stable/deprecations.html#terminalreporter-writer for more information.
</example>
    </io.jenkins.plugins.analysis.warnings.groovy.GroovyParser>
  </parsers>
</io.jenkins.plugins.analysis.warnings.groovy.ParserConfiguration>

Before this change can be merged the reported errors should be addressed to not regress the job states:

@dirk-thomas
Copy link
Member Author

dirk-thomas commented Aug 28, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python warnings are not reported by CI
2 participants