Skip to content

Commit 2d606d0

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 <gurwls223@apache.org> Co-authored-by: HyukjinKwon <gurwls223@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent 567fb5f commit 2d606d0

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-2.4
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 }})"
@@ -25,21 +24,21 @@ jobs:
2524
# Kinesis tests depends on external Amazon kinesis service.
2625
# Note that the modules below are from sparktestsupport/modules.py.
2726
modules:
28-
- |-
27+
- >-
2928
core, unsafe, kvstore, avro,
3029
network-common, network-shuffle, repl, launcher,
3130
examples, sketch, graphx
32-
- |-
31+
- >-
3332
catalyst, hive-thriftserver
34-
- |-
33+
- >-
3534
streaming, sql-kafka-0-10, streaming-kafka-0-10,
3635
mllib-local, mllib,
3736
yarn, mesos, kubernetes, hadoop-cloud, spark-ganglia-lgpl
38-
- |-
37+
- >-
3938
pyspark-sql, pyspark-mllib
40-
- |-
39+
- >-
4140
pyspark-core, pyspark-streaming, pyspark-ml
42-
- |-
41+
- >-
4342
sparkr
4443
# Here, we split Hive and SQL tests into some of slow ones and the rest of them.
4544
included-tags: [""]
@@ -137,14 +136,15 @@ jobs:
137136
# PyArrow is not supported in PyPy yet, see ARROW-2651.
138137
# TODO(SPARK-32247): scipy installation with PyPy fails for an unknown reason.
139138
run: |
140-
python2.7 -m pip install numpy pyarrow pandas scipy
139+
python2.7 -m pip install numpy pyarrow pandas scipy xmlrunner
141140
python2.7 -m pip list
141+
# PyPy does not have xmlrunner
142142
pypy3 -m pip install numpy pandas
143143
pypy3 -m pip list
144144
- name: Install Python packages (Python 3.8)
145145
if: contains(matrix.modules, 'pyspark') || (contains(matrix.modules, 'sql') && !contains(matrix.modules, 'sql-'))
146146
run: |
147-
python3.8 -m pip install numpy pyarrow pandas scipy
147+
python3.8 -m pip install numpy pyarrow pandas scipy xmlrunner
148148
python3.8 -m pip list
149149
# SparkR
150150
- name: Install R 4.0
@@ -163,13 +163,19 @@ jobs:
163163
# Show installed packages in R.
164164
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]'
165165
# Run the tests.
166-
- name: "Run tests: ${{ matrix.modules }}"
166+
- name: Run tests
167167
run: |
168168
# Hive tests become flaky when running in parallel as it's too intensive.
169169
if [[ "$MODULES_TO_TEST" == "hive" ]]; then export SERIAL_SBT_TESTS=1; fi
170170
mkdir -p ~/.m2
171171
./dev/run-tests --parallelism 2 --modules "$MODULES_TO_TEST" --included-tags "$INCLUDED_TAGS" --excluded-tags "$EXCLUDED_TAGS"
172172
rm -rf ~/.m2/repository/org/apache/spark
173+
- name: Upload test results to report
174+
if: always()
175+
uses: actions/upload-artifact@v2
176+
with:
177+
name: test-results-${{ matrix.modules }}-${{ matrix.comment }}-${{ matrix.java }}-${{ matrix.hadoop }}
178+
path: "**/target/test-reports/*.xml"
173179

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