Skip to content

Commit

Permalink
build: Upload test reports and coverage (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
advancedxy authored Mar 5, 2024
1 parent a131c44 commit 56ccf6a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
24 changes: 21 additions & 3 deletions .github/actions/java-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
name: "Java Test"
description: "Run Java tests"
inputs:
MAVEN_OPTS:
maven_opts:
description: 'Maven options passed to the mvn command'
required: false
default: ''
upload-test-reports:
description: 'Whether to upload test results including coverage to GitHub'
required: false
default: 'false'

runs:
using: "composite"
steps:
Expand All @@ -44,9 +49,22 @@ runs:
- name: Run Maven compile
shell: bash
run: |
./mvnw -B compile test-compile scalafix:scalafix -Psemanticdb ${{ inputs.MAVEN_OPTS }}
./mvnw -B compile test-compile scalafix:scalafix -Psemanticdb ${{ inputs.maven_opts }}
- name: Run tests
shell: bash
run: |
SPARK_HOME=`pwd` ./mvnw -B clean install ${{ inputs.MAVEN_OPTS }}
SPARK_HOME=`pwd` ./mvnw -B clean install ${{ inputs.maven_opts }}
- name: Upload test results
if: ${{ inputs.upload-test-reports == 'true' }}
uses: actions/upload-artifact@v4
with:
name: java-test-reports-${{ github.run_id }}
path: "**/target/surefire-reports/*.txt"
retention-days: 7 # 1 week for test reports
overwrite: true

- name: Upload coverage results
if: ${{ inputs.upload-test-reports == 'true' }}
uses: codecov/codecov-action@v3 # uses v3 as it allows tokenless uploading
12 changes: 7 additions & 5 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ jobs:
name: Java test steps
uses: ./.github/actions/java-test
with:
MAVEN_OPTS: -Pspark-${{ matrix.spark-version }}
maven_opts: -Pspark-${{ matrix.spark-version }}
# upload test reports only for java 17
upload-test-reports: ${{ matrix.java_version == '17' }}

linux-test-with-old-spark:
strategy:
Expand Down Expand Up @@ -98,7 +100,7 @@ jobs:
- name: Java test steps
uses: ./.github/actions/java-test
with:
MAVEN_OPTS: -Pspark-${{ matrix.spark-version }}
maven_opts: -Pspark-${{ matrix.spark-version }}

macos-test:
strategy:
Expand All @@ -125,7 +127,7 @@ jobs:
name: Java test steps
uses: ./.github/actions/java-test
with:
MAVEN_OPTS: -Pspark-${{ matrix.spark-version }}
maven_opts: -Pspark-${{ matrix.spark-version }}

macos-aarch64-test:
strategy:
Expand Down Expand Up @@ -157,7 +159,7 @@ jobs:
name: Java test steps
uses: ./.github/actions/java-test
with:
MAVEN_OPTS: -Pspark-${{ matrix.spark-version }}
maven_opts: -Pspark-${{ matrix.spark-version }}

macos-aarch64-test-with-old-spark:
strategy:
Expand Down Expand Up @@ -186,5 +188,5 @@ jobs:
name: Java test steps
uses: ./.github/actions/java-test
with:
MAVEN_OPTS: -Pspark-${{ matrix.spark-version }}
maven_opts: -Pspark-${{ matrix.spark-version }}

28 changes: 26 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ under the License.
<arrow.version>14.0.2</arrow.version>
<codehaus.jackson.version>1.9.13</codehaus.jackson.version>
<spotless.version>2.43.0</spotless.version>
<jacoco.version>0.8.11</jacoco.version>
<jni.dir>${project.basedir}/../core/target/debug</jni.dir>
<platform>darwin</platform>
<arch>x86_64</arch>
Expand Down Expand Up @@ -84,6 +85,7 @@ under the License.
--add-opens=java.base/sun.util.calendar=ALL-UNNAMED
-Djdk.reflect.useDirectMethodHandle=false
</extraJavaTestArgs>
<argLine>-ea -Xmx4g -Xss4m ${extraJavaTestArgs}</argLine>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -672,7 +674,6 @@ under the License.
<stdout>D</stdout>
<stderr/>
<tagsToExclude>org.apache.comet.IntegrationTestSuite</tagsToExclude>
<argLine>-ea -Xmx4g -Xss4m ${extraJavaTestArgs}</argLine>
<systemProperties>
<!-- emit test logs to target/unit-tests.log -->
<log4j.configurationFile>file:src/test/resources/log4j2.properties</log4j.configurationFile>
Expand Down Expand Up @@ -714,7 +715,6 @@ under the License.
<systemPropertyVariables>
<log4j.configurationFile>file:src/test/resources/log4j2.properties</log4j.configurationFile>
</systemPropertyVariables>
<argLine>-ea -Xmx4g -Xss4m ${extraJavaTestArgs}</argLine>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -772,6 +772,11 @@ under the License.
<artifactId>flatten-maven-plugin</artifactId>
<version>1.3.0</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down Expand Up @@ -964,6 +969,25 @@ under the License.
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 56ccf6a

Please sign in to comment.