Skip to content

Commit f98c01b

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 aa1da40 commit f98c01b

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,22 +24,22 @@ 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,
3837
streaming-flume, streaming-flume-sink, streaming-kafka-0-8
39-
- |-
38+
- >-
4039
pyspark-sql, pyspark-mllib
41-
- |-
40+
- >-
4241
pyspark-core, pyspark-streaming, pyspark-ml
43-
- |-
42+
- >-
4443
sparkr
4544
- >-
4645
sql
@@ -127,14 +126,15 @@ jobs:
127126
# PyArrow is not supported in PyPy yet, see ARROW-2651.
128127
# TODO(SPARK-32247): scipy installation with PyPy fails for an unknown reason.
129128
run: |
130-
python3.8 -m pip install numpy pyarrow pandas scipy
129+
python3.8 -m pip install numpy pyarrow pandas scipy xmlrunner
131130
python3.8 -m pip list
131+
# PyPy does not have xmlrunner
132132
pypy3 -m pip install numpy pandas
133133
pypy3 -m pip list
134134
- name: Install Python packages (Python 2.7)
135135
if: contains(matrix.modules, 'pyspark') || (contains(matrix.modules, 'sql') && !contains(matrix.modules, 'sql-'))
136136
run: |
137-
python2.7 -m pip install numpy pyarrow pandas scipy
137+
python2.7 -m pip install numpy pyarrow pandas scipy xmlrunner
138138
python2.7 -m pip list
139139
# SparkR
140140
- name: Install R 4.0
@@ -153,13 +153,19 @@ jobs:
153153
# Show installed packages in R.
154154
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]'
155155
# Run the tests.
156-
- name: "Run tests: ${{ matrix.modules }}"
156+
- name: Run tests
157157
run: |
158158
# Hive tests become flaky when running in parallel as it's too intensive.
159159
if [[ "$MODULES_TO_TEST" == "hive" ]]; then export SERIAL_SBT_TESTS=1; fi
160160
mkdir -p ~/.m2
161161
./dev/run-tests --parallelism 2 --modules "$MODULES_TO_TEST" --included-tags "$INCLUDED_TAGS" --excluded-tags "$EXCLUDED_TAGS"
162162
rm -rf ~/.m2/repository/org/apache/spark
163+
- name: Upload test results to report
164+
if: always()
165+
uses: actions/upload-artifact@v2
166+
with:
167+
name: test-results-${{ matrix.modules }}-${{ matrix.comment }}-${{ matrix.java }}-${{ matrix.hadoop }}
168+
path: "**/target/test-reports/*.xml"
163169

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