-
Notifications
You must be signed in to change notification settings - Fork 9
200 lines (194 loc) · 8.83 KB
/
ci_build_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: CI Build
on: [push, pull_request]
env:
CARGO_TEST_RESULT_NAME: cargo_test_results.json
CONFORMANCE_REPORT_NAME: cts_report.json
COMPARISON_REPORT_NAME: cts-comparison-report.md
RUST_TEST_TIME_UNIT: 150,5000
RUST_TEST_TIME_INTEGRATION: 150,5000
jobs:
build:
name: Build and Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
steps:
- name: Remove MSys64 MingW64 Binaries
if: runner.os == 'Windows'
# remove this because there is a bad libclang.dll that confuses bindgen
run: Remove-Item -LiteralPath "C:\msys64\mingw64\bin" -Force -Recurse
- name: Install Dependencies
if: runner.os == 'Windows'
run: choco install llvm -y
- name: Git Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy, rustfmt
- name: Cargo Build
run: cargo build --verbose --workspace
- name: Cargo Test excluding conformance tests
run: cargo test --verbose --workspace
- name: Rustfmt Check
if: matrix.os == 'ubuntu-20.04'
run: cargo fmt --verbose --all -- --check
- name: Run Clippy
if: matrix.os == 'ubuntu-20.04'
uses: actions-rs/clippy-check@v1
with:
# Adding comments to the PR requires the GITHUB_TOKEN secret.
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
# Cache the `cargo build` so future jobs can reuse build
- name: Cache cargo build
if: matrix.os == 'ubuntu-20.04'
uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
# Run cargo-deny check and report.
# Fails if any of the following are found used in the crate or its dependencies.
# - any banned crates
# - disallowed open source licenses
# - use of disallowed repository sources
# Reports, but does not fail on:
# - security advisories
# See: https://embarkstudios.github.io/cargo-deny/index.html
cargo-deny:
runs-on: ubuntu-latest
strategy:
matrix:
checks:
- advisories
- bans licenses sources
# Prevent sudden announcement of a new advisory from failing ci:
continue-on-error: ${{ matrix.checks == 'advisories' }}
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}
# Conformance report generation and comparison report generation job will run only after the `Build and Test` job
# succeeds.
conformance-report:
name: Create conformance report for `push` and `pull_request` events
runs-on: ubuntu-20.04
steps:
# Pull down the cached `partiql-lang-rust` build from the `Build and Test` job. This allows us to reuse without
# needing to rebuild. If pulling the build fails, the subsequent `cargo test` will rebuild.
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-03-09
- uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
# Run the conformance tests (i.e. `cargo test`) and save to a json file. This uses the "format" unstable compile
# option to save as json. In the future, may want to use the `cargo_metadata` crate (https://crates.io/crates/cargo_metadata)
# to format and use the output.
- name: Cargo Test of the conformance tests (can fail) and save to json file
continue-on-error: true
run: cargo test --verbose --package partiql-conformance-tests --features "conformance_test" --release -- -Z unstable-options --ensure-time --format json > ${{ env.CARGO_TEST_RESULT_NAME }}
# Create a conformance report from the `cargo test` json file
- run: cargo run --features report_tool --bin generate_cts_report ${{ env.CARGO_TEST_RESULT_NAME }} ${GITHUB_SHA} ${{ env.CONFORMANCE_REPORT_NAME }}
# Upload conformance report for comparison with future runs
- name: Upload conformance report
uses: actions/upload-artifact@v3
with:
path: ${{ env.CONFORMANCE_REPORT_NAME }}
# Cache the `cargo build` and conformance report for `conformance-report-comparison` job (pull_request event only)
- name: Cache `cargo build` and conformance report
if: github.event_name == 'pull_request'
uses: actions/cache@v3
id: restore-build-and-conformance
with:
path: ./*
key: ${{ github.sha }}-conformance-report
conformance-report-comparison:
name: Create comparison report for `pull_request` event
runs-on: ubuntu-20.04
needs: [conformance-report]
if: github.event_name == 'pull_request'
steps:
# Pull down cached `cargo build` and conformance report
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-03-09
- uses: actions/cache@v3
id: restore-build-and-conformance
with:
path: ./*
key: ${{ github.sha }}-conformance-report
# Download conformance report from target branch to create comparison report. If target branch has no conformance
# report, pull down target branch and rebuild conformance report.
- name: Download conformance report from target branch
uses: dawidd6/action-download-artifact@v2
id: download-report
continue-on-error: true
with:
workflow: ci_build_test.yml
commit: ${{ github.event.pull_request.base.sha }}
# (If download of target branch report fails) Run the conformance tests (i.e. `cargo test`) and save to a JSON file.
- name: (If download of target branch conformance report fails) Checkout target branch
uses: actions/checkout@v3
if: ${{ steps.download-report.outcome == 'failure' }}
with:
submodules: recursive
path: ${{ github.event.pull_request.base.sha }}
ref: ${{ github.event.pull_request.base.sha }}
- name: (If download of target branch conformance report fails) Run conformance tests for target branch
if: ${{ steps.download-report.outcome == 'failure' }}
continue-on-error: true
run: |
cd ${{ github.event.pull_request.base.sha }}
cargo test --verbose --package partiql-conformance-tests --features "conformance_test" --release -- -Z unstable-options --ensure-time --format json > ${{ env.CARGO_TEST_RESULT_NAME }}
- name: (If download of target branch conformance report fails) Generate conformance test report for target branch
if: ${{ steps.download-report.outcome == 'failure' }}
continue-on-error: true
run: |
cd ${{ github.event.pull_request.base.sha }}
cargo run --features report_tool --bin generate_cts_report ${{ env.CARGO_TEST_RESULT_NAME }} ${GITHUB_SHA} ${{ env.CONFORMANCE_REPORT_NAME }}
- name: (If download of target branch conformance report fails) Move conformance test report of target branch to ./artifact directory
if: ${{ steps.download-report.outcome == 'failure' }}
continue-on-error: true
run: |
mkdir -p $GITHUB_WORKSPACE/artifact
cp -r $GITHUB_WORKSPACE/${{ github.event.pull_request.base.sha }}/$CONFORMANCE_REPORT_NAME $GITHUB_WORKSPACE/artifact/$CONFORMANCE_REPORT_NAME
# Run conformance report comparison. Generates comparison report
- run: cargo run --features report_tool --bin generate_comparison_report ./artifact/${{ env.CONFORMANCE_REPORT_NAME }} ${{ env.CONFORMANCE_REPORT_NAME }} ${{ env.COMPARISON_REPORT_NAME }}
# Print conformance report to GitHub actions workflow summary page
- name: print markdown in run
run: cat ${{ env.COMPARISON_REPORT_NAME }} >> $GITHUB_STEP_SUMMARY
# Find comment w/ conformance comparison if previous comment published
- name: Find Comment
uses: peter-evans/find-comment@v2
continue-on-error: true
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Conformance
# Create or update (if previous comment exists) with markdown version of comparison report
- name: Create or update comment
continue-on-error: true
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-file: ${{ env.COMPARISON_REPORT_NAME }}
edit-mode: replace