actions / actions/toolkit

Add xpath support for Problem Matcher

Open
#260 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement external
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the enhancement
Sniffing through logs using RegExp can be hairy especially if your need multiline line matching. In my particular use case I want to write a Problem Matcher for jest. The output from jest is very human friendly.

 FAIL  ./app.spec.js
  compare a and b
    ✕ should fail (7ms)

  ● compare a and b › should fail

    expect(received).toBe(expected) // Object.is equality

    Expected: "b"
    Received: "a"

      1 | describe('compare a and b', function() {
      2 |     it('should fail', function() {
    > 3 |         expect('a').toBe('b');
        |                     ^
      4 |     });
      5 | });
      6 |

      at Object.<anonymous> (app.spec.js:3:21)

Jest provides a CLI argument to print the test results in JSON. However, parsing this output using RegExp isn't that simple either.

What if the Problem Matcher API would allow us to use xpath to grep values from a json file on disc. Such an API would be useful and quite powerful addition.

Code Snippet

{
    "problemMatcher": [
        {
            "owner": "jest",
            "pattern": [
                {
                    "source": "./path/to/file.json",
                    "file": $.testResults[*].name,
                    "message": $.testResults[*].assertionResults[*].failureMessages
                }
            ]
        }
    ]
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Problem Matcher API and reviewing how its current pattern configuration is parsed. The issue names no files or tests; done would require a decided design for extracting values from JSON files with XPath-like selectors, documented configuration behavior, and coverage for the proposed matching cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
json, typescript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.