Skip to content

Commit 11d170f

Browse files
committed
[SPARK-32357][INFRA] Publish failed and succeeded test reports in GitHub Actions
This PR proposes to report the failed and succeeded tests in GitHub Actions in order to improve the development velocity by leveraging [ScaCap/action-surefire-report](https://github.com/ScaCap/action-surefire-report). See the example below: ![Screen Shot 2020-08-13 at 8 17 52 PM](https://user-images.githubusercontent.com/6477701/90128649-28f7f280-dda2-11ea-9211-e98e34332f6b.png) Note that we cannot just use [ScaCap/action-surefire-report](https://github.com/ScaCap/action-surefire-report) in Apache Spark because PRs are from the forked repository, and GitHub secrets are unavailable for the security reason. This plugin and all similar plugins require to have the GitHub token that has the write access in order to post test results but it is unavailable in PRs. To work around this limitation, I took this approach: 1. In workflow A, run the tests and upload the JUnit XML test results. GitHub provides to upload and download some files. 2. GitHub introduced new event type [`workflow_run`](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/) 10 days ago. By leveraging this, it triggers another workflow B. 3. Workflow B is in the main repo instead of fork repo, and has the write access the plugin needs. In workflow B, it downloads the artifact uploaded from workflow A (from the forked repository). 4. Workflow B generates the test reports to port from JUnit xml files. 5. Workflow B looks up the PR and posts the test reports. The `workflow_run` event is very new feature, and looks not so many GitHub Actions plugins support. In order to make this working with [ScaCap/action-surefire-report](https://github.com/ScaCap/action-surefire-report), I had to fork two GitHub Actions plugins to use: - [ScaCap/action-surefire-report](https://github.com/ScaCap/action-surefire-report) to have this custom fix: HyukjinKwon/action-surefire-report@c96094c It added `commit` argument to specify the commit to post the test reports. With `workflow_run`, it can access, in workflow B, to the commit from workflow A. - [dawidd6/action-download-artifact](https://github.com/dawidd6/action-download-artifact) to have this custom fix: HyukjinKwon/action-download-artifact@750b71a It added the support of downloading all artifacts from workflow A, in workflow B. By default, it only supports to specify the name of artifact. Note that I was not able to use the official [actions/download-artifact](https://github.com/actions/download-artifact) because: - It does not support to download artifacts between different workflows, see also actions/download-artifact#3. Once this issue is resolved, we can switch it back to [actions/download-artifact](https://github.com/actions/download-artifact). I plan to make a pull request for both repositories so we don't have to rely on forks. Currently, it's difficult to check the failed tests. You should scroll down long logs from GitHub Actions logs. No, dev-only. Manually tested at: #17, #18, #19, #20, and master branch of my forked repository. Closes apache#29333 from HyukjinKwon/SPARK-32357-fix. Lead-authored-by: Hyukjin Kwon <[email protected]> Co-authored-by: HyukjinKwon <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent a278c5e commit 11d170f

File tree

2 files changed

+52
-11
lines changed

2 files changed

+52
-11
lines changed

.github/workflows/master.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: master
1+
name: Build and test
22

33
on:
44
push:
@@ -9,7 +9,6 @@ on:
99
- branch-3.0
1010

1111
jobs:
12-
# TODO(SPARK-32248): Recover JDK 11 builds
1312
# Build: build Spark and run the tests for specified modules.
1413
build:
1514
name: "Build modules: ${{ matrix.modules }} ${{ matrix.comment }} (JDK ${{ matrix.java }}, ${{ matrix.hadoop }}, ${{ matrix.hive }})"
@@ -27,21 +26,21 @@ jobs:
2726
# Kinesis tests depends on external Amazon kinesis service.
2827
# Note that the modules below are from sparktestsupport/modules.py.
2928
modules:
30-
- |-
29+
- >-
3130
core, unsafe, kvstore, avro,
3231
network-common, network-shuffle, repl, launcher,
3332
examples, sketch, graphx
34-
- |-
33+
- >-
3534
catalyst, hive-thriftserver
36-
- |-
35+
- >-
3736
streaming, sql-kafka-0-10, streaming-kafka-0-10,
3837
mllib-local, mllib,
3938
yarn, mesos, kubernetes, hadoop-cloud, spark-ganglia-lgpl
40-
- |-
39+
- >-
4140
pyspark-sql, pyspark-mllib
42-
- |-
41+
- >-
4342
pyspark-core, pyspark-streaming, pyspark-ml
44-
- |-
43+
- >-
4544
sparkr
4645
# Here, we split Hive and SQL tests into some of slow ones and the rest of them.
4746
included-tags: [""]
@@ -146,14 +145,15 @@ jobs:
146145
# PyArrow is not supported in PyPy yet, see ARROW-2651.
147146
# TODO(SPARK-32247): scipy installation with PyPy fails for an unknown reason.
148147
run: |
149-
python2.7 -m pip install numpy pyarrow pandas scipy
148+
python2.7 -m pip install numpy pyarrow pandas scipy xmlrunner
150149
python2.7 -m pip list
150+
# PyPy does not have xmlrunner
151151
pypy3 -m pip install numpy pandas
152152
pypy3 -m pip list
153153
- name: Install Python packages (Python 3.8)
154154
if: contains(matrix.modules, 'pyspark') || (contains(matrix.modules, 'sql') && !contains(matrix.modules, 'sql-'))
155155
run: |
156-
python3.8 -m pip install numpy pyarrow pandas scipy
156+
python3.8 -m pip install numpy pyarrow pandas scipy xmlrunner
157157
python3.8 -m pip list
158158
# SparkR
159159
- name: Install R 4.0
@@ -172,13 +172,19 @@ jobs:
172172
# Show installed packages in R.
173173
sudo Rscript -e 'pkg_list <- as.data.frame(installed.packages()[, c(1,3:4)]); pkg_list[is.na(pkg_list$Priority), 1:2, drop = FALSE]'
174174
# Run the tests.
175-
- name: "Run tests: ${{ matrix.modules }}"
175+
- name: Run tests
176176
run: |
177177
# Hive tests become flaky when running in parallel as it's too intensive.
178178
if [[ "$MODULES_TO_TEST" == "hive" ]]; then export SERIAL_SBT_TESTS=1; fi
179179
mkdir -p ~/.m2
180180
./dev/run-tests --parallelism 2 --modules "$MODULES_TO_TEST" --included-tags "$INCLUDED_TAGS" --excluded-tags "$EXCLUDED_TAGS"
181181
rm -rf ~/.m2/repository/org/apache/spark
182+
- name: Upload test results to report
183+
if: always()
184+
uses: actions/upload-artifact@v2
185+
with:
186+
name: test-results-${{ matrix.modules }}-${{ matrix.comment }}-${{ matrix.java }}-${{ matrix.hadoop }}-${{ matrix.hive }}
187+
path: "**/target/test-reports/*.xml"
182188

183189
# Static analysis, and documentation build
184190
lint:

.github/workflows/test_report.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Report test results
2+
on:
3+
workflow_run:
4+
workflows: ["Build and test"]
5+
types:
6+
- completed
7+
8+
jobs:
9+
test_report:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Download test results to report
13+
# TODO(SPARK-32605): It was forked to have a custom fix
14+
# https://github.com/HyukjinKwon/action-surefire-report/commit/c96094cc35061fcf154a7cb46807f2f3e2339476
15+
# in order to add the support of custom target commit SHA. It should be contributed back to the original
16+
# plugin and avoid using the fork.
17+
uses: HyukjinKwon/action-download-artifact@master
18+
with:
19+
github_token: ${{ secrets.GITHUB_TOKEN }}
20+
workflow: ${{ github.event.workflow_run.workflow_id }}
21+
commit: ${{ github.event.workflow_run.head_commit.id }}
22+
- name: Publish test report
23+
# TODO(SPARK-32606): It was forked to have a custom fix
24+
# https://github.com/HyukjinKwon/action-download-artifact/commit/750b71af351aba467757d7be6924199bb08db4ed
25+
# in order to add the support to download all artifacts. It should be contributed back to the original
26+
# plugin and avoid using the fork.
27+
# Alternatively, we can use the official actions/download-artifact once they support to download artifacts
28+
# between different workloads, see also https://github.com/actions/download-artifact/issues/3
29+
uses: HyukjinKwon/action-surefire-report@master
30+
with:
31+
check_name: Test report
32+
github_token: ${{ secrets.GITHUB_TOKEN }}
33+
report_paths: "**/target/test-reports/*.xml"
34+
commit: ${{ github.event.workflow_run.head_commit.id }}
35+

0 commit comments

Comments
 (0)