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

Merging streams #8

Open
jamiebuilds opened this issue Aug 6, 2018 · 2 comments
Open

Merging streams #8

jamiebuilds opened this issue Aug 6, 2018 · 2 comments

Comments

@jamiebuilds
Copy link
Member

jamiebuilds commented Aug 6, 2018

Because of the "id" format, it is easy to merge together multiple ZAP streams into a single stream simply by prepending all the "id"'s in each stream with another number for the stream and some sort of label.

Stream 1:

{ ... "id": "0" ... }
{ ... "id": "0.0" ... }
{ ... "id": "0.1" ... }
{ ... "id": "0" ... }
{ ... "id": "1" ... }
{ ... "id": "1.0" ... }
{ ... "id": "1.1" ... }
{ ... "id": "1.2" ... }
{ ... "id": "1" ... }

Stream 2:

{ ... "id": "0" ... }
{ ... "id": "0.0" ... }
{ ... "id": "0" ... }
{ ... "id": "1" ... }
{ ... "id": "1.0" ... }
{ ... "id": "1.1" ... }
{ ... "id": "1" ... }

Merged Streams:

{ ... "id": "0" ... } // 1
{ ... "id": "1" ... } // 2
{ ... "id": "0.0" ... } // 1
{ ... "id": "1.0" ... } // 2
{ ... "id": "0.0.0" ... } // 1
{ ... "id": "1.0.0" ... } // 2
{ ... "id": "1.0" ... } // 2
{ ... "id": "0.0.1" ... } // 1
{ ... "id": "0.0" ... } // 1
{ ... "id": "0.1" ... } // 1
{ ... "id": "1.1" ... } // 2
{ ... "id": "0.1.0" ... } // 1
{ ... "id": "0.1.1" ... } // 1
{ ... "id": "1.1.0" ... } // 2
{ ... "id": "1.1.1" ... } // 2
{ ... "id": "0.1.2" ... } // 1
{ ... "id": "0.1" ... } // 1
{ ... "id": "0" ... } // 1
{ ... "id": "1.1" ... } // 2
{ ... "id": "1" ... } // 2

This allows ZAP reporters to report the output from multiple tools without any additional changes.

There are no required changes to ZAP to support this behavior, but it seems worth documenting and maybe writing a library to do automatically.

@sindresorhus
Copy link

This is very cool. We could then potentially run linting and tests in parallel.

@jamiebuilds
Copy link
Member Author

I think I'm gonna do it like this:

(./run-tests.sh | zap-wrap 0 "Tests" & ./run-lints.sh | zap-wrap 1 "Lints")

Where ... | zap-wrap <id> <message> accepts stdin and outputs:

// prepends a group "started" event
{"kind":"group","event":"started","id":"<id>","timestamp":"...","content":[{"message":"<message>"}]}
// modifies previous contents as stream:
{ ... "id":"<id>.<previous id>" ... }
// appends a group completion event that "passed" or "failed" based on the process exit code
{"kind":"group","event":"<passed|failed>","id":"<id>","timestamp":"...","content":[{"message":"<message>"}]}

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

No branches or pull requests

2 participants