Core Summary should be more flexible
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
If your issue is relevant to this repository, please include the information below:
Describe the enhancement
The summary tools in @actions/core should be more flexible in their application. There are formatting things that should be possible which are currently not supported by the interface and implementation. Some choice examples are enumerated here:
- You cannot produce markdown links with
summary.addLink()in a table being produced bysummary.addTable() - There is no table builder and you cannot produce a table through the
summarytool row-by-row, everything has to be provided to the addTable method at once. - You cannot wrap elements in the
<detail>block usingaddDetailas it only accepts a string.
These are just a few of the gripes I've run into while using the summary tools in @actions/core, I'm sure there are plenty others.
I would suggest that the approach to how the summary is handled be altered such that "a summary" be composed of an array of composable elements. When it comes time to write the summary, the elements resolve themselves to their string representations and then be written.
Code Snippet
Example follows:
import * as core from '@actions/core'
core.summary
.addHeading('Top Level Heading')
.startDetail('Details Summary Text')
.addTable(
new core.summary.table
.withHeaderRow(['column header', 'column header', 'column header'])
.withRow(['a', 'single', 'row'])
.withRows([['or', 'an', 'array'], ['of', 'rows', 'together']])
.withRow(['or', 'even', core.summary.addLink('a link!', 'https://www.zombo.com')])
.finalize()
)
.write()
Additional information
If a fully developed composable element library isn't feasible, can we at least expose a method to export the string representation of what core.summary.addX() methods would write so that we can patch together a desired output?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the summary tools in @actions/core, especially addLink(), addTable(), addDetail(), and write(). Review the existing interface and implementation to identify how these methods currently compose output; done requires a defined, maintainable approach for flexible composition, along with tests covering the supported formatting cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100