-
Notifications
You must be signed in to change notification settings - Fork 109
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
Generate unique xml file names #108
Conversation
@andrcuns thanks for the PR! The second change looks good but I cannot have jest-junit generate a unique xml by default. The vast majority of folks using this rely on junit.xml being generated and a lot of CI systems rely on this file being there for integration. There is currently the JEST_JUNIT_OUTPUT_NAME and JEST_JUNIT_OUTPUT_DIR configurations which give you the ability to specify a different filename and location respectively for this purpose. |
@palmerj3 Indeed, I did not think about folks relying on the default value. Can we make it as a separate option? Something like The problem with JEST_JUNIT_OUTPUT_NAME, is that if you have multiple commands in single CI job, each of those commands would have to be prefixed with this variable like But our problem is actually with the mentioned knapsack pro, it splits runs in to batches programmatically and there is no way to feed it unique values via ENV variable. So junit.xml ends up with values from the last batch only. Another solution would be to merge result if the file already exists, but I don't think it's a good one. Similar approach to what I am proposing, is used by Cucumber junit reporter for example. |
@andrcuns I wouldn't be against adding it as an option as long as it's turned off by default. But before we do that I would like to ask you to try something. I dug through the knapsack code a bit and it seems it might be possible to pass along some info from knapsack to jest-junit so you get a unique filename. Knapsack sets an environment variable Sample jest.config.js file:
I don't have a knapsack account to test this with but it appears something similar should work either using this via environment variables or with the jest config like I showed. Let me know how that goes. |
@palmerj3 variable I could most likely generate some unique name just by using some uuid like in Your example, but I don't even add |
Yes it's once per CI node but isn't that what you want? It is a unique identifier for each batch of tests that knapsack runs. The one that is shared between all runs is ciNodeBuildId. Perhaps I'm not understanding your use-case if you need something beyond that or I don't understand knapsack well enough. |
Nop, the issue is not that there is a batch per CI node (which wouldn't be an issue really), but that it also splits test execution inside this single node in to sort of sub batches, it doesn't execute all of the tests as single jest run. I haven't looked in code why (most likely related to algorithms to evenly split tests by execution time). For example: |
I see. Thanks for explaining that to me. Feel free to amend this PR and add the option for a unique filename that is off by default. Thank you |
@palmerj3 Added separate option |
Looks good to me thanks for the PR! |
@andrcuns ok this change has been published in v9.0.0 https://github.com/jest-community/jest-junit/releases/tag/v9.0.0 |
Bumps [jest-junit](https://github.com/jest-community/jest-junit) from 8.0.0 to 9.0.0. <details> <summary>Release notes</summary> *Sourced from [jest-junit's releases](https://github.com/jest-community/jest-junit/releases).* > ## v9.0.0 > Ability to generate unique filenames for junit.xml by [@​andrcuns](https://github.com/andrcuns) [jest-community/jest-junit#108](https://github-redirect.dependabot.com/jest-community/jest-junit/pull/108) </details> <details> <summary>Commits</summary> - [`1ee5b29`](jest-community/jest-junit@1ee5b29) Merge pull request [#109](https://github-redirect.dependabot.com/jest-community/jest-junit/issues/109) from palmerj3/v9.0.0 - [`9cc91c2`](jest-community/jest-junit@9cc91c2) v9.0.0 - [`414ddbb`](jest-community/jest-junit@414ddbb) Merge pull request [#108](https://github-redirect.dependabot.com/jest-community/jest-junit/issues/108) from andrcuns/uniq_xml_name - [`325abed`](jest-community/jest-junit@325abed) Add separate option to generate unique file names for xml report files - [`32ba516`](jest-community/jest-junit@32ba516) Remove unsupported node versions, update readme - [`2a60ded`](jest-community/jest-junit@2a60ded) Generate unique xml file by default - See full diff in [compare view](jest-community/jest-junit@v8.0.0...v9.0.0) </details> <br /> [![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=jest-junit&package-manager=npm_and_yarn&previous-version=8.0.0&new-version=9.0.0)](https://dependabot.com/compatibility-score.html?dependency-name=jest-junit&package-manager=npm_and_yarn&previous-version=8.0.0&new-version=9.0.0) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme Additionally, you can set the following in the `.dependabot/config.yml` file in this repo: - Update frequency - Automerge options (never/patch/minor, and dev/runtime dependencies) - Out-of-range updates (receive only lockfile updates, if desired) - Security updates (receive only security updates, if desired) </details>
Feature proposal
There might be several cases when having a static xml name is undesirable, for example if single CI job runs multiple test suites as multiple commands, reports get overwritten. Another use case is knapsack-pro which splits test execution in batches. This seems to solve issue describe in #106
This PR does following things: