-
Notifications
You must be signed in to change notification settings - Fork 2
184 lines (170 loc) · 5.64 KB
/
validation-rust.yaml
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
---
# Main "useful" actions config file
# Cache config comes from https://github.com/actions/cache/blob/main/examples.md#rust---cargo
# actions-rs/toolchain configures rustup
# actions-rs/cargo actually runs cargo
on:
push:
branches:
- main
pull_request:
name: Rust Validation
env:
# RUSTDOCFLAGS: -D warnings
# RUSTFLAGS: -D warnings -C debuginfo=1
RUST_BACKTRACE: 1
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
jobs:
clippy:
name: "Clippy (cargo clippy)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup default 1.78.0 && rustup component add clippy && rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-features --all-targets
- run: cargo clippy --no-default-features --all-targets
msrv:
name: "Check MSRV"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup default 1.65.0 && rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo check --all-features -p udf
- run: cargo check --no-default-features -p udf
test:
strategy:
fail-fast: true
matrix:
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
extension: ''
# - build: macos
# os: macos-latest
# target: x86_64-apple-darwin
# extension: ''
- build: windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
name: "Test on ${{ matrix.os }} (cargo test)"
runs-on: ${{ matrix.os }}
env:
MYSQLCLIENT_LIB_DIR: 'C:\Program Files\MySQL\MySQL Server 8.0\lib'
# will be accepted by a later Diesel version
MYSQLCLIENT_LIB_DIR_X86_64_PC_WINDOWS_MSVC: 'C:\Program Files\MySQL\MySQL Server 8.0\lib'
steps:
- uses: actions/checkout@v2
# use a version later than MSRV for trybuild consistency
- run: rustup default 1.70 && rustup update
- run: rustc -vV
- uses: Swatinem/rust-cache@v2
- run: cargo test -vvv
integration:
name: "Integration testing (docker)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup default stable && rustup update
- uses: Swatinem/rust-cache@v2
- name: Cache Docker layers
uses: actions/cache@v2
id: cache-docker
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Enable logging-debug-calls
run: |
perl -0777 -i -pe 's/(udf =.*features = \[)/\1"logging-debug-calls",\3/g' udf-examples/Cargo.toml
cat udf-examples/Cargo.toml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Image
uses: docker/build-push-action@v3
with:
load: true
tags: mdb-example-so:latest
file: Dockerfile.examples
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
context: .
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Start docker
run: >
docker run --rm -d
-p 12300:3306
-e MARIADB_ROOT_PASSWORD=example
-e RUST_LIB_BACKTRACE=1
--name mdb-example-container
mdb-example-so
&& sleep 4
# verify we started successfully
- run: mysql -uroot -pexample -h0.0.0.0 -P12300 --protocol=tcp -e 'show databases'
- name: Run integration testing
# Run only integration tests with `--test '*'`
run: cargo test -p udf-examples --test '*' --features backend
- name: Print docker logs
if: always()
run: |
docker logs mdb-example-container
# If any critical / debug options were printed, error out
docker logs mdb-example-container 2>&1 | grep -E '\[(Critical|Error)\]' || exit 0 && exit 1;
docker stop mdb-example-container
miri:
name: Miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup default nightly && rustup component add miri && rustup update
- uses: Swatinem/rust-cache@v2
- name: Run Miri
env:
# Can't use chrono for time in isolation
MIRIFLAGS: -Zmiri-disable-isolation
run: cargo miri test
fmt:
name: "Format (cargo fmt)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup default nightly && rustup component add rustfmt && rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check
- uses: actions/setup-python@v3
- name: Validate pre-commit
uses: pre-commit/[email protected]
doc:
name: "Docs (cargo doc)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup default nightly && rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo doc
outdated:
name: Outdated
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: dtolnay/install@cargo-outdated
- uses: Swatinem/rust-cache@v2
- run: cargo outdated --workspace --exit-code 1 --ignore lipsum
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: rustsec/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}