-
Notifications
You must be signed in to change notification settings - Fork 29
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
add summary as an action output #22
base: master
Are you sure you want to change the base?
add summary as an action output #22
Conversation
index.test.js
Outdated
const ip = path.join(__dirname, 'index.js'); | ||
cp.exec(`node ${ip}`, {env: process.env}, (error, stdout, stderr) => { | ||
try { | ||
console.log(`STDOUT: ${stdout}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to log the stdout here ? In case of failure, the assertion should already give a helpful message to identify the root cause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that was just an oversight. Will correct.
Hello and thank you for this contribution The CI does not work on PR coming from fork. To see the visual result of your PR, do you mind activating the GitHub Action on your fork repository (you need to go in the Action tab if I remember well). So we might be able to see visually what this is providing. |
47407ed
to
ab495f1
Compare
I've removed the errant debug statement and enabled actions/workflows on the repo: |
Thank you fo the updates. Although, could you provide a link or a screenshot of the new feature. I'm really sorry but I didn't find it in your actions. |
Sorry, I was in a hurry before and didn't give the original PR description my usual level of attention. I have updated it to hopefully provide a better sense of the change. There is no visible change, per se. It just uses the github mechanisms to provide an output variable containing the test results summary that can be used by a workflow author in other steps in their workflow |
Purpose
This PR adds the string obtained from
testSummary.toFormattedMessage()
as an action out named "summary".Additionally, it adds a test for the new output parameter and sets up the framework for additional tests providing coverage of the actual action logic.
Implementation
The changes are implemented in two parts: the declaration of the output parameter and the workflow command actually setting the output parameter
Declaration
The declaration of the output parameter in the action.yml file is optional as described in the Github metadata syntax documentation. It is good practice and communicates clearly what outputs are provided to consumers of the action
Workflow Command
The output parameter is actually set by the one line addition to index.js:
This uses the Github toolkit to execute a workflow command to set the output parameter as described in the Github workflow commands reference documentation.
Example
This would allow a user to, for instance, take the summary output from the action and use it in a slack notification action later in the workflow
The above example of an imaginary workflow job contains three steps:
report
for later reference, uses this action to read the test results, annotate the job, and output a summaryIt will be something like: