Skip to content

Update CI to test with a newer Rust version #349

Update CI to test with a newer Rust version

Update CI to test with a newer Rust version #349

---
# 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
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 --all-targets
- run: cargo check --no-default-features --all-targets
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:\mysql\lib
MYSQLCLIENT_LIB_DIR: C:\tools\mysql\current\lib
steps:
- uses: actions/checkout@v2
- name: List files
run: |
pwd
ls
echo print /
ls /
winget.exe install sharkdp.fd
echo "find mysql"
fd mysql /
echo "find mdb"
fd mariadb /
# echo print dir
# test -d /mysql && ls /mysql
- if: runner.os == 'windows-latest'
run: winget install -e --id MariaDB
# use a version later than MSRV for trybuild consistency
- run: rustup default 1.70 && rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo test
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
- 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 }}