allure-framework / allure-framework/allure3
Allow temp attachment files cleanup
- Dominant language
- HTML
- Stars
- 401
- Forks
- 58
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 34
Description
Allure doesn't copy the underlying file passed to `visitAttachmentFile`. This is not a problem if the file is permanent (e.g., resides in an Allure 1/2 results directory).
However, some input formats (notably, `xcresult`), require exporting attachments to the file system to access their content.
Currently, we only have two options to manage this:
- Attach as `BufferResultFile`, clean up the exported files (the current behavior of the `xcresult` reader) - eats RAM
- Keep exported files, attach as `PathResultFile` - eats disk space
#### Proposal
The problem is that readers have a short lifetime relative to Allure itself. Once the `read` function is done, nothing can be done to do the cleanup before Allure exits.
On the other hand, Allure needs attachment files to persist the whole time it serves it (in awesome/allure2/classic, doesn't matter).
The solution would be any mechanism that extends readers' lifetime to completely include the file serving period of the Allure execution time. Three options come to my mind.
**Option 1.**
Implement Allure-managed temp dir, allow readers to write there (e.g., define something like `writeTmpAllureFile` or `allureTmpDir` pointing to the dir). This completely removes the FS cleanup logic from readers.
**Option 2.**
Allow readers to defer clean up routines. Something like `registerCleanup: (cleanup: () => Promise): void`. Readers can then schedule arbitrary cleanups (not limited to removing tmp files).
**Option 3.**
Notify readers when Allure is about to exit. Similar to Option 2, but the API is different, and Allure must know who exactly may handle the event (unlike Option 2, where Allure plays passively).
I like option two combined with option one as a special case. But ultimately, all that will work.
Contributor guide
Research direction
Start by tracing the read function, visitAttachmentFile, BufferResultFile, and PathResultFile behavior, including the xcresult reader. Compare the proposed cleanup lifecycles and define which mechanism keeps attachments available for serving while allowing cleanup after Allure exits; the issue does not identify specific files or tests.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100