CI: Add rustfmt and cargo clippy to CI #329
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
fmt: | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: Swatinem/rust-cache@v2 | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.69.0 | |
components: rustfmt, clippy | |
- name: Setup OCI runtime build env | |
run: | | |
sudo apt -y update | |
sudo apt install -y pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev | |
- name: Setup WasmEdge build env | |
run: | | |
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- --version=0.11.2 | |
echo "LD_LIBRARY_PATH=$HOME/.wasmedge/lib" >> $GITHUB_ENV | |
- name: Run cargo fmt | |
run: | | |
cargo fmt --all -- --check | |
- name: Run cargo clippy | |
run: | | |
cargo clippy --all --all-targets -- -D warnings | |
build: | |
strategy: | |
matrix: | |
os: ["ubuntu-20.04", "ubuntu-22.04"] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: Swatinem/rust-cache@v2 | |
- name: "check cgroup version" | |
run: "mount | grep cgroup" | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.69.0 | |
- name: Setup OCI runtime build env | |
run: | | |
sudo apt -y update | |
sudo apt install -y pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev | |
- name: Setup WasmEdge build env | |
run: | | |
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- --version=0.11.2 | |
echo "LD_LIBRARY_PATH=$HOME/.wasmedge/lib" >> $GITHUB_ENV | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --all --verbose | |
- name: Validate docs | |
run: ./scripts/validate-docs.sh | |
- name: Run tests | |
run: | | |
sudo -E LD_LIBRARY_PATH=/home/runner/.wasmedge/lib /home/runner/.cargo/bin/cargo test --all --verbose | |
e2e: | |
needs: [build] | |
strategy: | |
matrix: | |
# 20.04 uses cgroupv1, 22.04 uses cgroupv2 | |
os: ["ubuntu-20.04", "ubuntu-22.04"] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: "check cgroup version" | |
run: "mount | grep cgroup" | |
- uses: actions/checkout@v3 | |
- name: setup rust-wasm target | |
run: rustup target add wasm32-wasi | |
- name: run | |
run: make test/k8s/deploy | |
- name: cleanup | |
if: always() | |
run: make test/k8s/clean |