Skip to content

Commit bdfa7f3

Browse files
matthijskooijmancmaglie
authored andcommitted
CI: Publish HTML report of tests as an artifact
This also lets ant print a message pointing to this artifact and explaining the files inside briefly. To make sure this is only printed inside the github action, an extra `-D` option is passed to `ant test` from the workflow file. To allow `if` / `unless` on the echo element, this adds some namespace definitions (this allows them on *any* element, not just the ones that explicitly allow it). See https://ant.apache.org/manual/ifunless.html
1 parent a665a3b commit bdfa7f3

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.github/workflows/ant.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ jobs:
2424
run: sudo apt-get install -y xvfb
2525
- name: Run tests
2626
working-directory: ./app
27-
run: xvfb-run --auto-servernum --server-args "-screen 0 1024x768x24" ant test
27+
run: xvfb-run --auto-servernum --server-args "-screen 0 1024x768x24" ant test -Drunning-from-github-action=1
28+
- name: Publish results
29+
uses: actions/upload-artifact@v1
30+
with:
31+
name: html-results
32+
path: app/test-bin/results/html/
2833
- name: Cleanup xvfb
2934
uses: bcomnes/cleanup-xvfb@v1

app/build.xml

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<project name="Arduino PDE" default="build">
2+
<project name="Arduino PDE" xmlns:if="ant:if" xmlns:unless="ant:unless" default="build">
33

44
<path id="class.path">
55
<fileset dir="lib">
@@ -160,14 +160,18 @@
160160
<fileset dir="${test.reportdir}">
161161
<include name="TEST-*.xml" />
162162
</fileset>
163-
<report todir="${test.htmldir}" />
163+
<!-- Create a browsable frame-based HTML -->
164+
<report format="frames" todir="${test.htmldir}" />
165+
<!-- Also create a single-page version, to use as CI test result -->
166+
<report format="noframes" todir="${test.htmldir}" />
164167
</junitreport>
165168

166169
<!-- Make these paths relative to user.dir, which is the current directory when invoking ant (so the resulting paths are relative to the environment of the user. -->
167170
<property name="test.htmldir.display" location="${test.htmldir}" relative="true" basedir="${user.dir}"/>
168171
<property name="test.reportdir.display" location="${test.reportdir}" relative="true" basedir="${user.dir}"/>
169-
<echo message="Detailed test results can be found in ${test.reportdir.display}"/>
170-
<echo message="A browsable HTML summary is generated in ${test.htmldir.display}/index.html"/>
172+
<echo unless:set="running-from-github-action" message="Detailed test results can be found in ${test.reportdir.display}"/>
173+
<echo unless:set="running-from-github-action" message="A browsable HTML summary is generated in ${test.htmldir.display}/index.html"/>
174+
<echo if:set="running-from-github-action" message="Detailed test results can be downloaded as an asset from this github action. Easiest to view is the single-file version in junit-noframes.html. Alternatively, the multi-file version can be viewed from index.html and includes full stdout/stderr output of tests."/>
171175

172176
<fail if="test.failed"/>
173177
</target>

build/build.xml

+1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
<!-- Forward these to subant. Use propertyset/propertyref instead of a direct property so we do not need to specify a value -->
189189
<propertyref name="single-test-class"/>
190190
<propertyref name="single-test-methods"/>
191+
<propertyref name="running-from-github-actions"/>
191192
</propertyset>
192193
</subant>
193194
</target>

0 commit comments

Comments
 (0)