@@ -3,6 +3,9 @@ name: CI Build
3
3
on : [push, pull_request]
4
4
5
5
env :
6
+ CARGO_TEST_RESULT_NAME : cargo_test_results.json
7
+ CONFORMANCE_REPORT_NAME : cts_report.json
8
+ COMPARISON_REPORT_NAME : cts-comparison-report.md
6
9
RUST_TEST_TIME_UNIT : 150,5000
7
10
RUST_TEST_TIME_INTEGRATION : 150,5000
8
11
@@ -102,14 +105,14 @@ jobs:
102
105
# to format and use the output.
103
106
- name : Cargo Test of the conformance tests (can fail) and save to json file
104
107
continue-on-error : true
105
- run : cargo test --verbose --package partiql-conformance-tests --features "conformance_test" --release -- -Z unstable-options --ensure-time --format json > cargo_test_results.json
108
+ run : cargo test --verbose --package partiql-conformance-tests --features "conformance_test" --release -- -Z unstable-options --ensure-time --format json > ${{ env.CARGO_TEST_RESULT_NAME }}
106
109
# Create a conformance report from the `cargo test` json file
107
- - run : cargo run --features report_tool --bin generate_cts_report cargo_test_results.json ${GITHUB_SHA} cts_report.json
110
+ - run : cargo run --features report_tool --bin generate_cts_report ${{ env.CARGO_TEST_RESULT_NAME }} ${GITHUB_SHA} ${{ env.CONFORMANCE_REPORT_NAME }}
108
111
# Upload conformance report for comparison with future runs
109
- - name : Upload cts_report.json
112
+ - name : Upload conformance report
110
113
uses : actions/upload-artifact@v3
111
114
with :
112
- path : cts_report.json
115
+ path : ${{ env.CONFORMANCE_REPORT_NAME }}
113
116
# Cache the `cargo build` and conformance report for `conformance-report-comparison` job (pull_request event only)
114
117
- name : Cache `cargo build` and conformance report
115
118
if : github.event_name == 'pull_request'
@@ -137,27 +140,46 @@ jobs:
137
140
with :
138
141
path : ./*
139
142
key : ${{ github.sha }}-conformance-report
140
- # Download conformance report from `main` to create comparison report. If `main` has no report, use a backup
141
- # report (stored in partiql-conformance-tests/backup_conformance_report.json). Alternatively, we could consider
142
- # - pulling `main` branch and rerun the tests
143
- # - pulling latest release and rerun the tests
144
- # - compare to an empty file
145
- # - don't perform comparisons
146
- - name : Download cts_report.json from `main` branch
143
+ # Download conformance report from target branch to create comparison report. If target branch has no conformance
144
+ # report, pull down target branch and rebuild conformance report.
145
+ - name : Download conformance report from target branch
147
146
uses : dawidd6/action-download-artifact@v2
148
147
id : download-report
149
148
continue-on-error : true
150
149
with :
151
150
workflow : ci_build_test.yml
152
- branch : main
153
- - name : backup case if download fails
151
+ commit : ${{ github.event.pull_request.base.sha }}
152
+ # (If download of target branch report fails) Run the conformance tests (i.e. `cargo test`) and save to a JSON file.
153
+ - name : (If download of target branch conformance report fails) Checkout target branch
154
+ uses : actions/checkout@v3
154
155
if : ${{ steps.download-report.outcome == 'failure' }}
155
- run : mkdir -p artifact && cp -r ./partiql-conformance-tests/backup_conformance_report.json ./artifact/cts_report.json
156
- # Run conformance report comparison. Generates cts-comparison-report.md
157
- - run : cargo run --features report_tool --bin generate_comparison_report ./artifact/cts_report.json cts_report.json cts-comparison-report.md
156
+ with :
157
+ submodules : recursive
158
+ path : ${{ github.event.pull_request.base.sha }}
159
+ ref : ${{ github.event.pull_request.base.sha }}
160
+ - name : (If download of target branch conformance report fails) Run conformance tests for target branch
161
+ if : ${{ steps.download-report.outcome == 'failure' }}
162
+ continue-on-error : true
163
+ run : |
164
+ cd ${{ github.event.pull_request.base.sha }}
165
+ cargo test --verbose --package partiql-conformance-tests --features "conformance_test" --release -- -Z unstable-options --ensure-time --format json > ${{ env.CARGO_TEST_RESULT_NAME }}
166
+ - name : (If download of target branch conformance report fails) Generate conformance test report for target branch
167
+ if : ${{ steps.download-report.outcome == 'failure' }}
168
+ continue-on-error : true
169
+ run : |
170
+ cd ${{ github.event.pull_request.base.sha }}
171
+ cargo run --features report_tool --bin generate_cts_report ${{ env.CARGO_TEST_RESULT_NAME }} ${GITHUB_SHA} ${{ env.CONFORMANCE_REPORT_NAME }}
172
+ - name : (If download of target branch conformance report fails) Move conformance test report of target branch to ./artifact directory
173
+ if : ${{ steps.download-report.outcome == 'failure' }}
174
+ continue-on-error : true
175
+ run : |
176
+ mkdir -p $GITHUB_WORKSPACE/artifact
177
+ cp -r $GITHUB_WORKSPACE/${{ github.event.pull_request.base.sha }}/$CONFORMANCE_REPORT_NAME $GITHUB_WORKSPACE/artifact/$CONFORMANCE_REPORT_NAME
178
+ # Run conformance report comparison. Generates comparison report
179
+ - run : cargo run --features report_tool --bin generate_comparison_report ./artifact/${{ env.CONFORMANCE_REPORT_NAME }} ${{ env.CONFORMANCE_REPORT_NAME }} ${{ env.COMPARISON_REPORT_NAME }}
158
180
# Print conformance report to GitHub actions workflow summary page
159
181
- name : print markdown in run
160
- run : cat cts-comparison-report.md >> $GITHUB_STEP_SUMMARY
182
+ run : cat ${{ env.COMPARISON_REPORT_NAME }} >> $GITHUB_STEP_SUMMARY
161
183
# Find comment w/ conformance comparison if previous comment published
162
184
- name : Find Comment
163
185
uses : peter-evans/find-comment@v2
@@ -174,5 +196,5 @@ jobs:
174
196
with :
175
197
comment-id : ${{ steps.fc.outputs.comment-id }}
176
198
issue-number : ${{ github.event.pull_request.number }}
177
- body-file : cts-comparison-report.md
199
+ body-file : ${{ env.COMPARISON_REPORT_NAME }}
178
200
edit-mode : replace
0 commit comments