Skip to content

Commit 5debde9

Browse files
HyukjinKwondongjoon-hyun
authored andcommitted
[SPARK-32357][INFRA] Publish failed and succeeded test reports in GitHub Actions
### What changes were proposed in this pull request? 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. ### Why are the changes needed? Currently, it's difficult to check the failed tests. You should scroll down long logs from GitHub Actions logs. ### Does this PR introduce _any_ user-facing change? No, dev-only. ### How was this patch tested? Manually tested at: HyukjinKwon#17, HyukjinKwon#18, HyukjinKwon#19, HyukjinKwon#20, and master branch of my forked repository. Closes #29333 from HyukjinKwon/SPARK-32357-fix. Lead-authored-by: Hyukjin Kwon <gurwls223@apache.org> Co-authored-by: HyukjinKwon <gurwls223@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent 6ae2cb2 commit 5debde9

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
- master
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, pyspark-resource
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: [""]
@@ -144,14 +143,15 @@ jobs:
144143
# PyArrow is not supported in PyPy yet, see ARROW-2651.
145144
# TODO(SPARK-32247): scipy installation with PyPy fails for an unknown reason.
146145
run: |
147-
python3.6 -m pip install numpy pyarrow pandas scipy
146+
python3.6 -m pip install numpy pyarrow pandas scipy xmlrunner
148147
python3.6 -m pip list
148+
# PyPy does not have xmlrunner
149149
pypy3 -m pip install numpy pandas
150150
pypy3 -m pip list
151151
- name: Install Python packages (Python 3.8)
152152
if: contains(matrix.modules, 'pyspark') || (contains(matrix.modules, 'sql') && !contains(matrix.modules, 'sql-'))
153153
run: |
154-
python3.8 -m pip install numpy pyarrow pandas scipy
154+
python3.8 -m pip install numpy pyarrow pandas scipy xmlrunner
155155
python3.8 -m pip list
156156
# SparkR
157157
- name: Install R 4.0
@@ -170,13 +170,19 @@ jobs:
170170
# Show installed packages in R.
171171
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]'
172172
# Run the tests.
173-
- name: "Run tests: ${{ matrix.modules }}"
173+
- name: Run tests
174174
run: |
175175
# Hive tests become flaky when running in parallel as it's too intensive.
176176
if [[ "$MODULES_TO_TEST" == "hive" ]]; then export SERIAL_SBT_TESTS=1; fi
177177
mkdir -p ~/.m2
178178
./dev/run-tests --parallelism 2 --modules "$MODULES_TO_TEST" --included-tags "$INCLUDED_TAGS" --excluded-tags "$EXCLUDED_TAGS"
179179
rm -rf ~/.m2/repository/org/apache/spark
180+
- name: Upload test results to report
181+
if: always()
182+
uses: actions/upload-artifact@v2
183+
with:
184+
name: test-results-${{ matrix.modules }}-${{ matrix.comment }}-${{ matrix.java }}-${{ matrix.hadoop }}-${{ matrix.hive }}
185+
path: "**/target/test-reports/*.xml"
180186

181187
# Static analysis, and documentation build
182188
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)