ci: upload junit formatted test results#5271
Conversation
|
Skipping CI for Draft Pull Request. |
0158ab2 to
fadb365
Compare
c51aec8 to
096ed25
Compare
|
Build succeeded.
|
|
This should be ready... I don't actually know how test result parser workflow will work out since it won't run until it is merged. |
096ed25 to
a36c00f
Compare
|
Build succeeded.
|
a36c00f to
5b45698
Compare
|
Build succeeded.
|
This allows us to dig more details out of test runs and maintain a better history. For this we can use `gotestsum`, which is a utility that wraps `go test` so that it outputs test2json (go's format) and output junit (a format more easily imported into other systems). The PR makes it possible to override the Makefile's use of `go test` to use any other command tto executet the test. For CI we'll use `gotestsum --`, where `gotestsum` expects everything after the `--` to be flags for `go test`. We then use environment variables to configure `gotestsum` (e.g. `GOTESTSUM_JUNITFILE` is an env var accepted by `gotestsum`). For cri tests, the test suite supports outputing test results to a directory, these are in junit format already. The file is not named properly just because the code that creates it (in ginkgo) is not configured well. We can fix that upstream to give us a better name... until then I'm keeping those results in a separate dir. A second workflow is also added so the test results can be summed up and a report added to the workflow run. The 2nd workflow is required for this since PR runs do not have access to do some of this due to safety reasons (https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) Signed-off-by: Brian Goff <cpuguy83@gmail.com>
5b45698 to
af1e2af
Compare
|
Build succeeded.
|
|
How can I access the result? |
| script: | | ||
| var fs = require('fs'); | ||
| var path = require('path'); | ||
| var artifacts_path = path.join('${{github.workspace}}', 'artifacts') | ||
| fs.mkdirSync(artifacts_path, { recursive: true }) | ||
|
|
||
| var artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| run_id: ${{ github.event.workflow_run.id }}, | ||
| }); | ||
|
|
||
| for (const artifact of artifacts.data.artifacts) { | ||
| var download = await github.actions.downloadArtifact({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| artifact_id: artifact.id, | ||
| archive_format: 'zip', | ||
| }); | ||
| var artifact_path = path.join(artifacts_path, `${artifact.name}.zip`) | ||
| fs.writeFileSync(artifact_path, Buffer.from(download.data)); | ||
| console.log(`Downloaded ${artifact_path}`); | ||
| } |
There was a problem hiding this comment.
Is it possible to have that as a standalone file instead of inlining in YAML?
There was a problem hiding this comment.
No, we cannot checkout code in this workflow.
There was a problem hiding this comment.
Also to be fair, I have no idea if this will work and no good way to test it here because the workflow won't run until its merged :(
There was a problem hiding this comment.
I see. It might be better to package that as our own GitHub actions, in future.
|
@estesp PTAL (as you were working on collecting data from CI) |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| GO111MODULE=on go install gotest.tools/gotestsum@v1.6.2 No newline at end of file |


ci: upload junit formatted test results
This allows us to dig more details out of test runs and maintain a
better history.
For this we can use
gotestsum, which is a utility that wrapsgo testso that it outputs test2json (go's format) and output junit (a format
more easily imported into other systems).
The PR makes it possible to override the Makefile's use of
go testtouse any other command tto execute the test. For CI we'll use
gotestsum --, wheregotestsumexpects everything after the--to be flags forgo test.We then use environment variables to configure
gotestsum(e.g.GOTESTSUM_JUNITFILEis an env var accepted bygotestsum).For cri tests, the test suite supports outputing test results to a
directory, these are in junit format already. The file is not named
properly just because the code that creates it (in ginkgo) is not
configured well. We can fix that upstream to give us a better name...
until then I'm keeping those results in a separate dir.
A second workflow is also added so the test results can be summed up and
a report added to the workflow run. The 2nd workflow is required for
this since PR runs do not have access to do some of this due to safety
reasons
(https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)