Skip to content

Commit 390430e

Browse files
authored
add conformance reporting (#1333)
* add conformance reporting
1 parent c5dae43 commit 390430e

File tree

8 files changed

+298
-146
lines changed

8 files changed

+298
-146
lines changed

.github/workflows/conformance-report.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ on: [push, pull_request]
33

44
env:
55
PATH_TO_TEST_RUNNER: test/partiql-tests-runner
6-
CONFORMANCE_REPORT_NAME: conformance_test_results.ion
6+
CONFORMANCE_REPORT_RELATIVE_PATH: build/conformance-test-report
77
COMPARISON_REPORT_NAME: comparison_report.md
8+
COMPARISON_REPORT_NAME_WITH_LIMIT: comparison_report_limited.md
9+
COMMENT_SIZE_LIMIT: 10
810

911
jobs:
1012
conformance-report:
@@ -13,6 +15,7 @@ jobs:
1315
steps:
1416
- uses: actions/checkout@v3
1517
with:
18+
ref: ${{ github.event.pull_request.head.sha }}
1619
submodules: recursive
1720
- name: Use Java 17
1821
uses: actions/setup-java@v3
@@ -27,12 +30,12 @@ jobs:
2730
# Run the conformance tests and save to an Ion file.
2831
- name: gradle test of the conformance tests (can fail) and save to Ion file
2932
continue-on-error: true
30-
run: gradle :test:partiql-tests-runner:test --tests "*ConformanceTestReport" -PconformanceReport
33+
run: gradle :test:partiql-tests-runner:generateTestReport
3134
# Upload conformance report for future viewing and comparison with future runs.
32-
- name: Upload `conformance_test_results.ion`
35+
- name: Upload `conformance-test-report` folder
3336
uses: actions/upload-artifact@v3
3437
with:
35-
path: ${{ env.PATH_TO_TEST_RUNNER }}/${{ env.CONFORMANCE_REPORT_NAME }}
38+
path: ${{ env.PATH_TO_TEST_RUNNER }}/build/conformance-test-report
3639
# Cache the conformance report for `conformance-report-comparison` job (pull_request event only)
3740
- name: Cache conformance report and build
3841
if: github.event_name == 'pull_request'
@@ -86,23 +89,34 @@ jobs:
8689
continue-on-error: true
8790
run: |
8891
cd ${{ github.event.pull_request.base.sha }}
89-
gradle :test:partiql-tests-runner:test --tests "*ConformanceTestReport" -PconformanceReport
92+
gradle :test:partiql-tests-runner:generateTestReport
9093
- name: (If download of target branch conformance report fails) Move conformance test report of target branch to ./artifact directory
9194
if: ${{ steps.download-report.outcome == 'failure' }}
9295
continue-on-error: true
9396
run: |
9497
mkdir -p $GITHUB_WORKSPACE/artifact
95-
cp -r $GITHUB_WORKSPACE/${{ github.event.pull_request.base.sha }}/$PATH_TO_TEST_RUNNER/$CONFORMANCE_REPORT_NAME $GITHUB_WORKSPACE/artifact/$CONFORMANCE_REPORT_NAME
98+
cp -r $GITHUB_WORKSPACE/${{ github.event.pull_request.base.sha }}/$PATH_TO_TEST_RUNNER/$CONFORMANCE_REPORT_RELATIVE_PATH $GITHUB_WORKSPACE/artifact/$CONFORMANCE_REPORT_RELATIVE_PATH
9699
# Run conformance report comparison. Generates `comparison_report.md`
97-
- name: Run conformance report comparison. Generates `comparison_report.md`
100+
- name: Run conformance report comparison for artifact. Generates `comparison_report.md`
98101
continue-on-error: true
99102
run: |
100-
ARGS="$GITHUB_WORKSPACE/artifact/$CONFORMANCE_REPORT_NAME $CONFORMANCE_REPORT_NAME ${{ github.event.pull_request.base.sha }} $GITHUB_SHA $COMPARISON_REPORT_NAME"
103+
ARGS="$GITHUB_WORKSPACE/artifact $CONFORMANCE_REPORT_RELATIVE_PATH ${{ github.event.pull_request.base.sha }} $GITHUB_SHA $COMPARISON_REPORT_NAME"
101104
gradle :test:partiql-tests-runner:run --args="$ARGS"
102105
# Print conformance report to GitHub actions workflow summary page
103106
- name: Print markdown in run
104107
continue-on-error: true
105108
run: cat $PATH_TO_TEST_RUNNER/$COMPARISON_REPORT_NAME >> $GITHUB_STEP_SUMMARY
109+
# Upload the full comparison report to CI artifact
110+
- name: Upload `comparison_report.md`
111+
uses: actions/upload-artifact@v3
112+
with:
113+
path: ${{ env.PATH_TO_TEST_RUNNER }}/comparison_report.md
114+
# Rebuild the test report with a size limit for comment
115+
- name: Run conformance report comparison for comment. Generates `comparison_report_limited.md`
116+
continue-on-error: true
117+
run: |
118+
ARGS="$GITHUB_WORKSPACE/artifact $CONFORMANCE_REPORT_RELATIVE_PATH ${{ github.event.pull_request.base.sha }} $GITHUB_SHA $COMPARISON_REPORT_NAME_WITH_LIMIT $COMMENT_SIZE_LIMIT"
119+
gradle :test:partiql-tests-runner:run --args="$ARGS"
106120
# Find comment w/ conformance comparison if previous comment published
107121
- name: Find Comment
108122
uses: peter-evans/find-comment@v2
@@ -119,5 +133,5 @@ jobs:
119133
with:
120134
comment-id: ${{ steps.fc.outputs.comment-id }}
121135
issue-number: ${{ github.event.pull_request.number }}
122-
body-file: ${{ env.PATH_TO_TEST_RUNNER }}/${{ env.COMPARISON_REPORT_NAME }}
136+
body-file: ${{ env.PATH_TO_TEST_RUNNER }}/${{ env.COMPARISON_REPORT_NAME_WITH_LIMIT }}
123137
edit-mode: replace

test/partiql-tests-runner/README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,18 @@ This package enables:
1212

1313
```shell
1414
# default, test data from partiql-tests submodule will be used
15-
./gradlew :test:partiql-tests-runner:test --tests "*ConformanceTestReport" -PconformanceReport
15+
./gradlew :test:partiql-tests-runner:ConformanceTestReport
1616

1717
# override test data location
1818
PARTIQL_TESTS_DATA=/path/to/partiql-tests/data \
19-
./gradlew :test:partiql-tests-runner:test --tests "*ConformanceTestReport" -PconformanceReport
19+
./gradlew :test:partiql-tests-runner:ConformanceTestReport
2020
```
21-
The report is written into file `test/partiql-tests-runner/conformance_test_results.ion`.
22-
23-
## Run Conformance Tests in UI
24-
25-
The above project property `-PconformanceReport` is checked in `test/partiql-tests-runner/build.gradle.kts`,
26-
to exclude the conformance test suite from executing during a normal project-build test run.
27-
Unfortunately, this also disables running `ConformanceTestReport` in a UI runner.
28-
To make that possible locally, temporarily comment out the check in `test/partiql-tests-runner/build.gradle.kts`.
21+
The report is written into folder `test/partiql-tests-runner/build/conformance_test_results`.
2922

3023
## Compare Conformance Reports locally
24+
The report contains two type of comparison:
25+
1. Cross Commit: Comparing using the same engine based on the pull request commit and head of target branch commit.
26+
2. Cross Engine: Comparing using different engine based on the pull request commit.
3127

3228
```shell
3329
./gradlew :test:partiql-tests-runner:run --args="pathToFirstConformanceTestResults pathToSecondConformanceTestResults firstCommitId secondCommitId pathToComparisonReport"

test/partiql-tests-runner/build.gradle.kts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies {
3131
}
3232

3333
val tests = System.getenv()["PARTIQL_TESTS_DATA"] ?: "../partiql-tests/partiql-tests-data"
34+
val reportDir = file("$buildDir/conformance-test-report").absolutePath
3435

3536
object Env {
3637
const val PARTIQL_EVAL = "PARTIQL_EVAL_TESTS_DATA"
@@ -43,10 +44,34 @@ tasks.test {
4344
environment(Env.PARTIQL_EQUIV, file("$tests/eval-equiv/").absolutePath)
4445

4546
// To make it possible to run ConformanceTestReport in unit test UI runner, comment out this check:
46-
if (!project.hasProperty("conformanceReport")) {
47-
exclude("org/partiql/runner/ConformanceTestReport.class")
48-
}
47+
exclude("org/partiql/runner/ConformanceTestEval.class", "org/partiql/runner/ConformanceTestLegacy.class")
4948

5049
// May 2023: Disabled conformance testing during regular project build, because fail lists are out of date.
5150
exclude("org/partiql/runner/ConformanceTest.class")
5251
}
52+
53+
val createReportDir by tasks.registering {
54+
if (File(reportDir).exists()) {
55+
delete(File(reportDir))
56+
}
57+
mkdir(reportDir)
58+
}
59+
60+
val generateTestReport by tasks.registering(Test::class) {
61+
dependsOn(createReportDir)
62+
useJUnitPlatform()
63+
environment(Env.PARTIQL_EVAL, file("$tests/eval/").absolutePath)
64+
environment(Env.PARTIQL_EQUIV, file("$tests/eval-equiv/").absolutePath)
65+
environment("conformanceReportDir", reportDir)
66+
include("org/partiql/runner/ConformanceTestEval.class", "org/partiql/runner/ConformanceTestLegacy.class")
67+
if (project.hasProperty("Engine")) {
68+
val engine = property("Engine")!! as String
69+
if (engine.toLowerCase() == "legacy") {
70+
exclude("org/partiql/runner/ConformanceTestEval.class")
71+
} else if (engine.toLowerCase() == "eval") {
72+
exclude("org/partiql/runner/ConformanceTestLegacy.class")
73+
} else {
74+
throw InvalidUserDataException("Expect engine property to be either Legacy or Eval, received $engine")
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)